tune&fat: run-time vs. compile-time constant thresholds

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Mon Apr 23 08:23:02 CEST 2012

Yesterday I moved a macro repeated in many files to gmp-impl.h :

/* This is intended for constant THRESHOLDs only, where the compiler
   can completely fold the result.  */
#define LOG2C(n) \

The comment is important. The macro should be used for compile-time
constants only.

Many macros in our code assume that thresholds are compile-time constants,
e.g. the MAYBE_ machinery in toom code, but also the ABOVE_THRESHOLD
macro, with its three stage comparison...

#define ABOVE_THRESHOLD(size,thresh)					\
  ((thresh) == 0							\
   || ((thresh) != MP_SIZE_T_MAX					\
       && (size) >= (thresh)))

Most of this code is disabled #if TUNE_PROGRAM_BUILD, but compiled for

I suggest to define a unique THRESHOLDS_ARE_NOT_HARDCODED macro, to be
used by both tune and fat builds, and start using it instead of the

Is this possible? Do you think it makes sense?



More information about the gmp-devel mailing list