Worse performance when -cl-fast-relaxed-math build flag is enabled

Hi all,

I’ve created a ray tracer using OpenCL and I enable the build flag -cl-fast-relaxed-math by default as it results in a FPS increase of between 15-100% depending on the scene. However, for one specific scene (which includes a C file containing noise functions) I get significantly worse performance when this flag is enabled, specifically 20% worse than when the flag is not enabled. This scene is very simple, only featuring a sphere with the surface displaced by some 3D Perlin noise to create a basic Earth-like planet. The noise library can be found here: perlin-noise/simplexnoise1234.c at master · stegu/perlin-noise · GitHub

Is this expected behaviour to get worse performance when including C files and using this build flag? And if so, what is causing this performance decrease?

For context:

Thanks for the reply but that doesn’t answer my question. I’m asking why the -cl-fast-relaxed-math build flag doesn’t provide a performance boost when used with a kernel that is including a C header file.

After some investigation, it seems my problem lay with some large arrays of constant data in my C file. After changing the .c file to a .cl file, and adding the __constant identifier to these arrays my problem was fixed.

So while you can include .h or .c files in an OpenCL kernel, its probably best to manually update the files to make use of correct OpenCL syntax, as the OpenCL compiler won’t do that for you.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.