Wie implementiert man diese im OpenCL-Kernel? Ist "Rückkehr" entspricht "brechen"?Brechen und Fortfahren im OpenCL-Kernel
Ich bin mit OpenCL 1.2
Ich mag dies für Schleifen, die Sie durch einen typedef struct verschachtelte Arrays verschachtelt mit 3 implementieren.
EDIT
Realisiert Ich brauche einige Code zu erhalten besser verstanden
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 zu sein (der Code, den ich im Kernel zu replizieren bin versucht, für Effizienz)
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;
}
}
* (wie immer) * *** Code anzeigen *** – abelenky
Ich schlage vor, Sie lesen ein Buch über C und lookup break, return und goto (goto darf aus verschachtelten Schleifen ausbrechen, egal was irgendjemand sagt). –
@PaulOgilvie hast du das in openCL __kernel getan? – ssn