Help with fastmath

I am trying to understand when and where in the code the fastmath option is enabled. I am working on:

and have a patch that generates the improved sequence ignoring the fastmath option. However when I set the fast math option to True using a decorator and check it using context.fastmath, it is always false. What else do I need to do to correctly check or set fastmath?

Hi @testhound,

Thanks for looking at this ticket. I’ve put a patch here:

Something like:

from numba.cuda import jit
import numpy as np
import math

def foo(x, out):
    out[0] = math.sin(x)

out_arr = np.empty((1,))
foo[1, 1](3.1415, out_arr)

will trigger the lowering for unary math implementations on the CUDA target and it should print (in this example):

Lowering for key <built-in function sin>. Fastmath is True

Note that on the CPU the fastmath “flag” actually comprises a load of options, which may be something to consider depending on what is involved in addition to wiring in these new transcendental functions.

Hope this helps?

Thank you @stuartarchibald , your patch worked perfectly.

No problem, glad it helped :slight_smile: