"Use Fast Math" property seems no effect for ptx generation


Since some recent version of CUDA, Visual Studio integration provides “Use Fast Math” property (CUDA C/C++ > Device > Use Fast Math) but this seems no effect for ptx generation (NVCC Compilation Type == Generate device-only .ptx file (-ptx)).

I tested with CUDA file like:

#include <cstdio>
#include <cstdint>

extern "C" __global__ void test(float* values) {
    uint32_t globalIdx = blockDim.x * blockIdx.x + threadIdx.x;
    values[globalIdx] = std::sin(values[globalIdx]);

Generated ptx file doesn’t contain sin.approx.ftz.f32 instruction even if I set “Use Fast Math” property to true. When I manually specify “–use_fast_math” from the additional options for command line, it contains.

CUDA 11.1
Visual Studio Community 2019 16.7.6


  1. I wouldn’t recommend using std::sin. nvcc doesn’t officially support the use of std library in device code. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#standard-library
  2. According to the programming guide, the function conversion applies to sinf(), not sin(): https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#intrinsic-functions

You may wish to file a bug for your observation.

I filed a bug and the development team is looking at it.

Thanks for filing the bug. I hope this will be fixed.

Regarding to std::sin, indeed I have been wondering why I can use such functions in std even without including the header and I could not have found mentions about them in the official CUDA documentations. I have been using them because they are abstract to float or double therefore feel useful.