Open Quuxplusone opened 5 years ago
Bugzilla Link | PR42191 |
Status | NEW |
Importance | P normal |
Reported by | Christopher Daley (csdaley@lbl.gov) |
Reported on | 2019-06-07 16:36:19 -0700 |
Last modified on | 2019-07-02 15:00:48 -0700 |
Version | unspecified |
Hardware | PC Linux |
CC | a.bataev@hotmail.com, csdaley@lbl.gov, jdoerfert@anl.gov, llvm-bugs@lists.llvm.org |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
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).
(In reply to Alexey Bataev from comment #1)
> 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
(In reply to Christopher Daley from comment #2)
> (In reply to Alexey Bataev from comment #1)
> > 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;
}
(In reply to Alexey Bataev from comment #3)
> (In reply to Christopher Daley from comment #2)
> > (In reply to Alexey Bataev from comment #1)
> > > 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