https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120753

--- Comment #1 from Benjamin Schulz <schulz.benjamin at googlemail dot com> ---
the context of this is of course that this causes problems if one wants to
create an object or a struct entirely on gpu, say for temporary computations...

A replacement that works is:

#include <omp.h>

struct arraystruct
{
int A;
double* t;
};

int main()
{

arraystruct u;
u.t =new double[20];
#pragma omp target enter data map(alloc:u.t[0:20])
#pragma omp target teams distribute
    for(int i=1;i<20;i++)
    {
        u.t[i]=20;
    }

but that would require to allocate the array on the host, which is just a waste
of storage when this should only be used as a temporary cache for computations
on the gpu. 


Interestingly, map(alloc:u.t follows the dots and notices that u.t is really a
C type Array.


But i guess is_device_ptr should do so too then...


But the version with an allocated deviceptr fails to compile...

I guess a small change of code in is_device_ptr can fix this?

Reply via email to