Ok so i have this kernel function
[codebox]__kernel void CardanoTriple( __global volatile ulong * count )
{
uint a = get_global_id(0) * 3 + 2;
uint b = get_global_id(1);
if ( a + b <= 1000 ) {
ulong top = a + 1;
top *= top * ( 8 * a - 1 );
ulong down = b * b * 27;
if ( top % down == 0 ) {
if ( (top / down) + a + b <= 1000 ) {
(*count)++;
}
}
}
return;
}[/codebox]
I run it in an NDRange 333,1000 global.
It calculates cardano triples. Every time I run the program, I get a different result. Usually somewhere between 100-130. Now, I dont know if I am mistaking the definition of volatile or its a bug or what. Oh I’m also using the C++ wrapper not that it should matter but who knows. I should try with a C version just to be sure. Now that I think about it. I dont think ++ and volatile works because it has to make 2 refrences one to get and one to set … hmm. Maybe…
Ok after the realization of ++ not being a atomic instruction … anyway to get what i want? (found the atomic extensions >.> … im retared)
[codebox]#pragma OPENCL EXTENSION cl_khr_int32_base_atomics : enable
__kernel void CardanoTriple( __global uint * count )
{
uint a = get_global_id(0) * 3 + 2;
uint b = get_global_id(1);
if ( a + b <= 1000 ) {
ulong top = a + 1;
top *= top * ( 8 * a - 1 );
ulong down = b * b * 27;
if ( top % down == 0 ) {
if ( (top / down) + a + b <= 1000 ) {
atom_inc( count );
}
}
}
return;
}[/codebox]
Ok I ditched the 64 bit because I don’t know if it even exists. BUT now i get
prxas ptx input, line 150; error : Instruction ‘atom’ requires .target sm_11 or higher
Does this mean my drivers are out of date or that my graphics card is to old? … ill be very displeased if its the second