由于我在GPU中拥有大量的malloc数据,我必须拆分它。就像下面一样,将temp1和temp2从开始到结束分开一次:
for (int start = 0; start < total; start += step) {
int end = start + step > total?total:start+step;
fprintf(stderr, "total %ld start :%ld end :%ld\n", total, start, end);
#pragma acc data pcopyin(sum[0:n_sample], num[0:n_sample*total], lognn[0:preFact])
#pragma acc data copy(temp1[start*n_array1:end*n_array1], temp2[start*n_array2:end*n_array2])
#pragma acc kernels loop independent
for (int index = start; index < end; ++index) {
unsigned long long * t1 = temp1 + index * n_array1;
unsigned long long * t2 = temp2 + index * n_array2;
// fprintf(stderr, "use %d\t", index*n_array1);
int k = count / 32;
int l = count / 64;
t1[k] <<= 2;
t2[l] <<= 1;
int x = num[index * n_sample + i];
int y = num[index * n_sample + j];
}
}
但是当第一个循环完成并且开始运行第二个循环时,我总是被告知分段错误。 索引var应该是[0:end-start]吗?或者在循环完成时应该进行一些同步?
谢谢!
答案 0 :(得分:0)
数据子句 不是[0:end-start]。下限和上限可以是表达式。但是你必须确保lower_bound&lt; UPPER_BOUND