Open cdaley opened 5 years ago
I think, there is a problem in your code when d_ptr is a member data. You need to map the whole object and transfer it to the device or allocate memory for it on the device. Without it, when you're trying to access d_ptr on the GPU, you're dereferencing this pointer, which is nullptr (since d_ptr is a member, you need at first to dereference this pointer to get access to d_ptr).
Thanks Alexey,
Can you please show me the code that should be used when d_ptr is member data?
Is this what you mean?
pragma omp target enter data map(to:this[0:1])
pragma omp target is_device_ptr(this->d_ptr)
pragma omp teams distribute parallel for
for(int i=0; i<size; i++) { d_ptr[i] *= a; }
- This code fails in the same way.
Thanks, Chris
Just this would be enough:
pragma omp target map(to:this[0:1])
pragma omp teams distribute parallel for
for(int i=0; i<size; i++) { d_ptr[i] *= a; }
Thank you. This works as we expect. Please close this bug report if you are confident that "is_device_ptr" should not work on member data pointers.
Thanks, Chris
I think, there is a problem in your code when d_ptr is a member data. You need to map the whole object and transfer it to the device or allocate memory for it on the device. Without it, when you're trying to access d_ptr on the GPU, you're dereferencing this pointer, which is nullptr (since d_ptr is a member, you need at first to dereference this pointer to get access to d_ptr).
Thanks Alexey,
Can you please show me the code that should be used when d_ptr is member data?
Is this what you mean?
pragma omp target enter data map(to:this[0:1])
pragma omp target is_device_ptr(this->d_ptr)
pragma omp teams distribute parallel for
for(int i=0; i<size; i++) { d_ptr[i] *= a; }
- This code fails in the same way.
Thanks, Chris
Just this would be enough:
for(int i=0; i<size; i++) {
d_ptr[i] *= a;
}
I think, there is a problem in your code when d_ptr is a member data. You need to map the whole object and transfer it to the device or allocate memory for it on the device. Without it, when you're trying to access d_ptr on the GPU, you're dereferencing this pointer, which is nullptr (since d_ptr is a member, you need at first to dereference this pointer to get access to d_ptr).
Thanks Alexey,
Can you please show me the code that should be used when d_ptr is member data?
Is this what you mean?
for(int i=0; i<size; i++) {
d_ptr[i] *= a;
}
Thanks, Chris
I think, there is a problem in your code when d_ptr is a member data. You need to map the whole object and transfer it to the device or allocate memory for it on the device. Without it, when you're trying to access d_ptr on the GPU, you're dereferencing this pointer, which is nullptr (since d_ptr is a member, you need at first to dereference this pointer to get access to d_ptr).
Extended Description
Hello all,
I encounter a target region failure when using a class member pointer in the is_device_ptr clause.
The target region is successful when I declare the pointer inside the C++ function instead (using the macro FUNC_DECL).
I think this is a bug but I am happy to be corrected. The code is as follows.
class Widget { public:
ifndef FUNC_DECL
int _size; int _hnum; int _dnum; double* d_ptr; std::vector data;
endif
Widget(int size) {
ifdef FUNC_DECL
endif
pragma omp target is_device_ptr(d_ptr)
pragma omp teams distribute parallel for
} };
int main() { Widget widget(100000); return 0; }
I am using the following version of Clang
Thanks, Chris