Skip to content

C math preamble gen

Nick Curtis requested to merge arghdos/loopy:c_math_preamble_gen into master

A minor patch to automatically #include math.h when c-math functions are detected. The primary purpose is to avoid seeing a million of these:

/tmp/tmp_loopys6jyc003/code.c:23:23: warning: incompatible implicit declaration of built-in function ‘fmax’
/tmp/tmp_loopys6jyc003/code.c:23:23: note: include ‘<math.h>’ or provide a declaration of ‘fmax’
/tmp/tmp_loopys78h6qe3/code.c: In function ‘red_pres’:
/tmp/tmp_loopys78h6qe3/code.c:23:26: warning: implicit declaration of function ‘fmax’ [-Wimplicit-function-declaration]
       Pr[j + 8192 * i] = fmax(1e-300, thd_conc[j + 8192 * (4 + i)] * k0 / kinf);

during unit-testing, which is somewhat annoying.

This was implemented by moving the recognized c-math functions to two lists in target/c/__init__.py, and introducing a has_math_header parameter to the CTarget (which OpenCL and ISPC subsquently set to false)

Edited by Nick Curtis

Merge request reports