C++ OpenACC依赖项错误
请告诉我这里需要帮助:C++ OpenACC依赖项错误,c++,parallel-processing,openacc,C++,Parallel Processing,Openacc,请告诉我这里需要帮助: void RBM::sample_v_given_h(int *h0_sample, double *mean, int *sample) { int c = 0; double r; for(int i=0; i<n_visible; i++) { mean[i] = propdown(h0_sample, i, vbias[i]); if(mean[i] &l
void RBM::sample_v_given_h(int *h0_sample, double *mean, int *sample) {
int c = 0;
double r;
for(int i=0; i<n_visible; i++) {
mean[i] = propdown(h0_sample, i, vbias[i]);
if(mean[i] < 0 || mean[i] > 1)
sample[i] = 0;
else{
r = rand() / (RAND_MAX + 1.0);
if (r < mean[i]) c++;
sample[i] = c;
}
}
}
或如下
Accelerator restriction: call to 'rand' with no acc routine
当我调用具有rand()的函数时,我想我应该添加“#pragma acc routine”,但如何添加它,因为它在其他库中运行。一般来说,rand()不是线程安全的,所以即使您要用acc routine
来修饰声明,它也可能给加速器带来麻烦。我过去所做的是为随机数分配一个数组,然后使用cuRand并行地预生成一组随机数,然后在我调用rand()的代码中使用这些随机数。我已经研究过从OpenACC打电话到设备端cuRand,但我发现这比它的价值更难做到。
Accelerator restriction: call to 'rand' with no acc routine