The data clause does not have to be [0:end-start]. The lower bound and the upper bound can be expressions. You must ensure, however that lower_bound < upper_bound
openacc say Segmentation fault when split big data
Question
As i have big data to malloc in GPU, i have to split it.Like follows, to split temp1 and temp2 from start to end once:
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];
}
}
but I always be told Segmentation fault when first loop is complete and begin to run second loop. Is the index var should be [0:end-start]? or should do some sync when loop complete?
thanks!!
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow