KhronosGroup / OpenCL-CTS

The OpenCL Conformance Tests
Apache License 2.0
183 stars 193 forks source link

Look into removing the volatile qualifier from conversions test #1405

Open lakshmih opened 2 years ago

lakshmih commented 2 years ago

int/uint to float host side reference code currently uses volatile qualifier to prevent clang optimizations which cause the test to fail. eg:

static void int2float( void out, void in) { // Use volatile to prevent optimization by Clang compiler volatile cl_int l = ((cl_int *)in)[0]; }

This qualifier appears at several places in the code. Research the problem at a deeper level and propose a solution that does not involve the use of 'volatile'.

bashbaug commented 2 years ago

Thanks!

If possible, could you please also include the clang version that needs this workaround and the target platform?

jlewis-austin commented 2 years ago

An older issue #1057 observed similar behavior with uint2float and ulong2double (but not int2float). We didn't see a cleaner fix at the time since the obvious methods of forcing zeroes to be positive either involve type punning, or are subject to incorrect optimizations like we're seeing here.

I know that the use of volatile is discouraged, especially for atomic use cases, but could this be one of the rare cases where it's the cleanest way to solve the problem?