Skip to content

Interface verificarlo mca - #21

Draft
MinliLiao wants to merge 15 commits into
RIKEN-RCCS:fix/lit-execute_externalfrom
MinliLiao:Interface-verificarlo-mca
Draft

Interface verificarlo mca#21
MinliLiao wants to merge 15 commits into
RIKEN-RCCS:fix/lit-execute_externalfrom
MinliLiao:Interface-verificarlo-mca

Conversation

@MinliLiao

@MinliLiao MinliLiao commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

This pull request adds the option to use verificarlo's MCA backends with a new API __raptor_mca_op_func(fty * function, int MCA_backend, int from_type, int to_type, int to_exponent, int to_mantissa) which adds MCA on top of raptor op-mode. The first and the last 4 parameters of this API is the same as __raptor_truncate_op_func, where the second parameter indicates which MCA backend is used. Set the second parameter to 0 for verificarlo's MCA backends.
When MCA on the inbound operand values are needed, the function from __raptor_mca_op_func will have MCA added after the inbound operand values are truncated but before performing the operations.
With MCA on the outbound operand values are needed, the function from __raptor_mca_op_func will have MCA added after performing the operations but before the outbound operand values are converted back to original precision.
To get the similar behavior as verificarlo, the precision need to be increased (increase to double precision for single precision, and 128-bit floating-point for double precision).

To enable the use of verificarlo MCA backend, the path to the verificarlo MCA backend dynamic library libinterflop_mca.so or libinterflop_mca_int.so file need to be passed to the cmake command to compile RAPTOR with -D__RAPTOR_VERIFICARLOMCA_LIB_PATH option. Both libraries can be passed at the same time, with their paths separated with a semi-colon, where which backend is used will be selectable at runtime.

The libinterflop_mca_int.so backend need to have the _mcaint_inexact_binary64 and _mcaint_inexact_binary128 function signatures modified to allow external linkage in verificarlo's src/backends/interflop-backend-mcaint/interflop_mca_int.c to be used by RAPTOR:

diff --git a/src/backends/interflop-backend-mcaint/interflop_mca_int.c b/src/backends/interflop-backend-mcaint/interflop_mca_int.c
index f490a2d..47c62cf 100644
--- a/src/backends/interflop-backend-mcaint/interflop_mca_int.c
+++ b/src/backends/interflop-backend-mcaint/interflop_mca_int.c
@@ -309,13 +309,15 @@ static void _noise_binary128(_Float128 *x, const int exp,
   }
 
 /* Adds the mca noise to da */
-static void _mcaint_inexact_binary64(double *da, void *context) {
+extern void _mcaint_inexact_binary64(double *da, void *context);
+inline void _mcaint_inexact_binary64(double *da, void *context) {
   mcaint_context_t *ctx = (mcaint_context_t *)context;
   _INEXACT(da, ctx->binary32_precision, ctx, rng_state);
 }
 
 /* Adds the mca noise to qa */
-static void _mcaint_inexact_binary128(_Float128 *qa, void *context) {
+extern void _mcaint_inexact_binary128(_Float128 *qa, void *context);
+inline void _mcaint_inexact_binary128(_Float128 *qa, void *context) {
   mcaint_context_t *ctx = (mcaint_context_t *)context;
   _INEXACT(qa, ctx->binary64_precision, ctx, rng_state);
 }

The options to link against the corresponding verificarlo MCA backend is not included in the RAPTOR wrapper raptor-clang etc. and would need to be added manually when compiling applications with RAPTOR. If both libraries were included in -D__RAPTOR_VERIFICARLOMCA_LIB_PATH, both libraries also need to be linked.

Same as verificarlo, the options for MCA can be set with the VFC_BACKENDS environment variable at runtime.

If the VFC_BACKENDS environment variable is not defined or is empty, the default setting is equal to VFC_BACKENDS="default_lib --precision-binary32=24 --precision-binary64=53 --mode=pb --error-mode=rel --max-abs-error-exponent=112 --seed=0 --sparsity=1.0", where default_lib refers to libinterflop_mca_int.so if it is available, libinterflop_mca.so otherwise.

@MinliLiao
MinliLiao changed the base branch from develop to fix/lit-execute_external September 1, 2026 07:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant