"test_kernel.cl" - Views: 76 · Hits: 76 - Type: Public

#ifndef TEST_KERNEL_CL
#define TEST_KERNEL_CL

__kernel void
test_kernel_1(__global float4 *result)
{
    bool flag = false;
    //uint flag = false;
    uint gid = get_global_id(0);
    float rnd;
    uint i = 0;
    
#define VARIANT 1
#if (VARIANT == 1)
    while ((i < 2) && (flag == false)){
        rnd = sin((float)(gid + i)) + 0.1;
    
        if ((rnd * rnd)<=0.5){flag=true;}
        i++;
    }
#elif (VARIANT == 2)
    for (i = 0; i < 2; i++){
        if (flag == false){
        rnd = sin((float)(gid + i)) + 0.1;
    
        if ((rnd * rnd)<=0.5){flag=true; i++; break;}
        }
    }
#endif
    
    if(flag){    
        result[gid].x = rnd;
    }
            
    result[gid].y = (float)i;
}

#endif