Clone device object with allocatable proprierties

Hi,

I want to pass an array of type variables to cuda kernel. I have a local copy of this array on my host (GLOM) and I want to clone it on my device memory (GLOM_d). For this reason I have declared device type variable as allocatable and after initialized the host variable I try to clone the variables with the following command:

Allocate(GLOM_d(ind_j), source=GLOM(ind_j));

I do not have any error in compilation, but I have a segmentation fault error in running time.

This error is coming out when I have changed some object properties from fixed dimension to allocatable.
Should I change something in my code to clone a type variable with allocatable properties?
Thank you in advance.
Davide

Hi Davide,

Should I change something in my code to clone a type variable with allocatable properties?

Currently user defined types can only be fixed size when used on the device. It’s one of our most requested features, but unfortunately there’s a few technical obstacles that prevents us from implementing it. Hopefully it’s something we can support in the future.

  • Mat

Hi Davide,

Engineering had the following comment/question for you:

From a pure Fortran point of view this should all work…however, I do have a question…

Is the user trying to replicate the ind_ith element into array GLOM_d of size ind_i? If so, their code is correct. If they are trying to clone the entire GLOM array (of size ind_i), then their allocate statement should be the following:

allocate(GLOM_d(ind_i), source=GLOM)

As of PGI 13.9, they can also write this statement as

allocate(GLOM_d, source=GLOM)

assuming they want to clone the entire array of GLOM

  • Mat

Hi Mat,

thank you for your replies.

I was trying to replicate element by element the host array into the device. My compiler version is pgf95 13.7-0 64-bit target on x86-64 Linux -tp gh.

Each element of the array is an user defined type with several properties. At the beginning, I had every property with fixed dimension, and the copy definitely worked. Now, in order to increase the flexibility of the program, I have changed some of these properties to allocatable and the segmentation fault error is appeared.

I use a subroutine to initialize the host elements and after your reply I have tried also to allocate the single allocatable properties of the device element, but without results. Probably, how you said, these allocation are not already supported.
I tried:
a)
ALLOCATE(GLOM_d(ind_i)%property(host_dim))

where ind_i is the index of the array and host_dim is the initialized properties dimension of the host array. In running time, it generates the following error" error 0: copyout Memcpy (host=0x7f32c0dbe020, dev=0x0, size=8394735960) FAILED: 11(invalid argument)", even if host_dim variable is replaced by the correct integer number.
b)

ALLOCATE(GLOM_d(ind_i)%property,GLOM(ind_i)%property)

In this case I get the following running error: “PGF90-S-0198-Illegal use of property in ALLOCATE/DEALLOCATE”

Any suggestions would be appreciated.
Thank you again.
Davide