Assigning FLT_MAX or MAXFLOAT to a float4 variable has no effect.
e.g.:
myBuffer->a=(float4)(1,2,3,4);
myBuffer->a=(float4)(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
Will result in no errors, but the value of "a" in the buffer will (1,2,3,4).
Is this another optional feature that needs to be supported (and can be tested for with the appropriate call to clGetDeviceInfo), or is this a problem with the implementation ?
EDIT: Changed my typo, those were meant to be float4s
The code works fine for me. There is something else wrong at your end.
I am assuming 'a' is a float4 variable. Try using float4 instead of float, while assigning values to a float4 variable.
Sorry that was typo. I meant to use float4:
myBuffer->a=(float4)(1,2,3,4);
myBuffer->a=(float4)(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
Where type definitions are something like this:
struct MyStruct
{
float4 a;
float4 b;
float4 c;
}
__global MyStruct *myBuffer;
When I map myBuffer back to the CPU and inspect the value they are the original ones, not MAX_FLT.
Assigning FLT_MAX is giving correct results for me. Could you post your source code(host & kernel code) so that I can try and reproduce your problem?
Hmmm I can't repro in a simple test case either. But in our main codebase we definitely have an example where this will work:
myBuffer->a=(float4)(10000000.0f, 10000000.0f, 10000000.0f, 10000000.0f);
But this will have no effect:
myBuffer->a=(float4)(FLT_MAX, FLT_MAX, FLT_MAX, FLT_MAX);
I have tested multiple times, and the first case always works, and second one always fails. I can't imagine anything we could be doing wrong that could manifest in this way (we don't do anything on that buffer after that line of code).
Originally posted by: griffin2000 Hmmm I can't repro in a simple test case either. But in our main codebase we definitely have an example where this will work:
Does it work for you in a simple test case?
Does it work for you in a simple test case?
Yeah, I tried to replicate what was happening as closely as possible, but it works fine in my testcase. If I can narrow down exactly whats happening.in our actual code I will post more details.