Skip to content

Interface MCAlite - #24

Draft
MinliLiao wants to merge 14 commits into
RIKEN-RCCS:feature/interface-verificarlo-mcafrom
MinliLiao:Interface-mcalite
Draft

MinliLiao wants to merge 14 commits into
RIKEN-RCCS:feature/interface-verificarlo-mcafrom
MinliLiao:Interface-mcalite

Conversation

@MinliLiao

@MinliLiao MinliLiao commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

This pull request adds the interface to use MCAlite as the backend for MCA.
To build RAPTOR with MCAlite support, add -D__RAPTOR_MCALITE_SOURCE_DIR=path/to/MCAlite/src to the cmake command when building RAPTOR.
MCAlite requires linkage to the math library, so -lm linkage option would need to be added when compiling application code with RAPTOR with MCAlite support.

Set the second parameter of __raptor_mca_op_func to 1 to use MCAlite. MCAlite does not use any of the last 3 truncate to parameters, so any valid value can be used, but they won't have any impact on the results.

The environment variables MCA_SEED, MCA_T, MCA_NTRIALS, MCA_MODE would set the random number generator seed rng_seed, virtual precision t, loop count of each operation ntrials and mca mode (RR, PB or FULL) mode respectively at runtime.
The default values are equivalent to MCA_SEED=42 MCA_T=24 MCA_NTRIALS=5 MCA_MODE=PB.

The statistics are calculated with mca_compute_stats function for each operation and aggregated and printed to stdout at the end of execution. Per operation statistic output can be silenced by setting MCA_QUIET environment variable to anything.
No statistics are calculated when ntrials is 1 since the mca_compute_stats function would through errors.

By default, the result from the first iteration of ntrials is used as the result of the operation. This can be changed to using the calculated mean mu from mca_compute_stats function by setting the MCA_USE_MEAN environment variable to anything.

  • Example source code
double myadd(double a, double b) { return a + b; }
double myfunc(double a, double b) { double c = myadd(a, b); return myadd(c, b); }
...
myfunc(a, b);
...
  • Changes to the source code
+ template<typename fty>
+ fty * __raptor_mca_op_func(fty *, int, int, int, int, int);
double myadd(double a, double b) { return a + b; }
double myfunc(double a, double b) { double c = myadd(a, b); return myadd(c, b); }
+ auto mca_func = __raptor_mca_op_func(
+     myfunc, // function to instrument
+     1,      // MCA backend type, 1 for MCAlite
+     64,     // width in bits of the from_type, 64 for double, 32 for float
+     1,      // truncate to floating point type, irrelevant for MCAlite
+     8,      // truncate to floating point exponent bits, irrelevant for MCAlite
+     23      // truncate to floating point mantissa bits, irrelevant for MCAlite
+ ); 
...
+ mca_func(a, b);
- myfunc(a, b); 
...
  • Example compile command
raptor-clang++ -g <src_file> -o <bin> -lm
  • Example run command
MCA_SEED=2 MCA_T=24 MCA_NTRIALS=10 MCA_MODE=FULL <bin> <args>
  • Example output
rng_seed = 2, t = 24, ntrials = 10, mode = FULL, rng_stream 0
MCAlite stats at <src_file>:3:45: mu = 5.0011, sigma = 1.83106e-07, s = 24.7031
MCAlite stats at <src_file>:3:45: mu = 7.0021, sigma = 1.44697e-07, s = 25.5282
MCAlite accumulated stats at <src_file>:3:45: sum(mu) = 12.0032, sum(variance) = 5.44653e-14, call count = 2

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