Hi Sir
I want to use my RandomNumber() function in parallel_for_each() function.
When I Build I get this error
How do I resolve this problem
error C3930: 'RandomNumber' : no overloaded function has restriction specifiers that are compatible with the ambient context 'step_size::<lambda_23f843edc800319054a5b250f2700838>::operator
()'
accelerator pick_accelerator()
{
accelerator chosen_one;
//query all accelerators and pick one based on your criteria
for(accelerator
acc: accelerator::get_all())
if(!acc.has_display)
chosen_one = acc;
//return default or new one
return chosen_one;
}
#define
MBIG 1000000000
// this is rand3() from numerical recipies in 'c'
#define
MSEED 161803398
// initiation is separated from the random number
#define
MZ 0
// generator for speed
#define
FAC 1.0E-9
static
int inext,inextp;
static
long ma[56];
void InitRandNumGen(int
idum)
{
long mj,mk;
int i,ii,k;
if(
idum == -1 ){
// use system time for seed
time_t ltime;
time( <ime );
idum = (int)(ltime);
idum /= 1000;
}
mj=MSEED-(idum
< 0 ? -idum :
idum);
mj %= MBIG;
ma[55]=mj;
mk=1;
for (i=1;i<=54;i++) {
ii=(21*i) % 55;
ma[ii]=mk;
mk=mj-mk;
if (mk <
MZ) mk +=
MBIG;
mj=ma[ii];
}
for (k=1;k<=4;k++)
for (i=1;i<=55;i++) {
ma[i] -= ma[1+(i+30) % 55];
if (ma[i] <
MZ) ma[i] +=
MBIG;
}
inext=0;
inextp=31;
}
inline
double RandomNumber()
{
long mj;
do{
if (++inext == 56) inext=1;
if (++inextp == 56) inextp=1;
mj=ma[inext]-ma[inextp];
if (mj <
MZ) mj +=
MBIG;
ma[inext]=mj;
}while( !mj );
return (double)(mj*FAC);
}
#undef MBIG
#undef MSEED
#undef MZ
#undef FAC
double step_size()
{
accelerator acc = pick_accelerator();
double RNG;
static
const
int rank = 1;
extent<rank> e(1);
array<double,
rank> rand_out_data(e);
parallel_for_each(e, [=, &rand_out_data] (index<1>
idx)
restrict(amp)
{
rand_out_data[idx] = RandomNumber();
});
copy(rand_out_data, RNG);
return RNG;
}
My Best Regards
Huseyin Ozgur Kazanci
Akdeniz University ANTALYA TURKEY