How does one implement these within OpenCL kernel? Is 'return;' equivalent to 'break;'?
I am using openCL 1.2
I want to implement this with 3 nested for loops that cycle through a typedef struct of nested arrays.
EDIT
Realised I need to show some code to be better understood
IN KERNEL...
typedef struct tag_sfextras
{
float *high;
float *low;
}sfextras;
typedef struct tag_sdirection
{
int time;
float result;
sfextras *fextras;
}sdirection;
__kernel void Call(sdirection *_direction,
int _index,
int _start,
int _stop,
__global float *_result)
{
float _sum = 0.0f;
if (_index > 1)
{
_result[0] = 0.0f;
int i = get_global_id(0);
if (_direction[i].time >= _stop)
{
break;//or return?...
}
if (_direction[i].time < _start)
{
continue;// what to put here?...
}
else
{
_start = _direction[i].time + (1440 * 60);
}
int d = get_global_id(1);
int f = get_global_id(2);
float _fextras_weight = 0.0f;// need to zeroize on each inner loop (for f)
_fextras_weight += (float)pow(_direction[_index - 1].fextras[d].high[f] - _direction[i].fextras[d].high[f], 2.0f);
_fextras_weight += (float)pow(_direction[_index - 1].fextras[d].low[f] - _direction[i].fextras[d].low[f], 2.0f);
_result[0] += _fextras_weight*_direction[i].result;
_sum += _fextras_weight;
}
if (_sum > 0.0f)
{
_result[0] /= _sum;
}
}
IN HOST (the code I am trying to replicate in kernel for efficiency)
if(_direction_index > 1)
{
_fextras = 0.0f;
for(int i=0;i<_direction_index-1;i++)
{
if(_direction[i].time >= _stop)
{
break;
}
if(_direction[i].time < _start)
{
continue;
}
else
{
_direction_start = _direction[i].time + (1440*60);
}
for(int d=0;d<_DIRECTION;d++)
{
for(int f=0;f<_FEXTRAS;f++)
{
float _fextras_weight = 0.0f;
_fextras_weight += (float)pow(_direction[_direction_index-1].fextras[d].high[f]-_direction[i].fextras[d].high[f],2.0f);
_fextras_weight += (float)pow(_direction[_direction_index-1].fextras[d].low[f]-_direction[i].fextras[d].low[f],2.0f);
_fextras += _fextras_weight*_direction[i].result;
_sum += _fextras_weight;
}
}
}
if(_sum > 0.0f)
{
_fextras /= _sum;
}
}