Поскольку у меня есть большие данные для 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];
}
}
но мне всегда говорят, что ошибка сегментации, когда первый цикл завершен и начинается второй цикл. Индексная переменная должна быть [0: конец-начало]? или следует выполнить некоторую синхронизацию после завершения цикла?
Благодарность!!