__device__ int A[4];
int main() {
thrust::fill(
thrust::device_ptr<int>(A),
thrust::device_ptr<int>(A) + 4,
1
);
return 0;
}
This simple example fails with the error:
terminate called after throwing an instance of 'thrust::system::system_error'
what(): trivial_device_copy D->H failed: an illegal memory access was encountered
This works:
int main() {
int *A2;
cudaMalloc((void **)&A2, 4 * sizeof(int));
thrust::fill(
thrust::device_ptr<int>(A2),
thrust::device_ptr<int>(A2) + 4,
1
);
return 0;
}