0

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!!

luxuia
  • 3,459
  • 1
  • 12
  • 8

1 Answers1

0

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

user2054656
  • 151
  • 3
  • I'm sorry, I forget in openacc subarray is defined as arr[start:length]. **thanks very mush** – luxuia Apr 18 '13 at 01:30
  • and....can you tell me how to fix the compiler warning when i use like this : `copyin(temp[starti*n_array:stepi*n_array, temp[startj*n_array:stepj*n_array])` the compiler warning is `PGC-W-0155-two data clauses for array temp` I use PGI,so what can i do.... – luxuia Apr 18 '13 at 01:38