how to deal with structure of arrays in the pragma offload model

how to deal with structure of arrays in the pragma offload model

Hi all,

I have an openmp code where many scalars and arrays are encapsulated in a struct, and many function within the parrallel region have that struct as the parameter. But the reference guide mentions that in the pragma offload mode, the offloaded data must be bitwise copyable, meaning the structure of arrays cannot be properly dealt with. I have already explicitly specified the length of each array in the pragma in the form of in/out(struct.array:length(z)), but the compiler still complains that variable "struct" used in this offload region is not bitwise copyable.

So my question is: am I really left no choice but to manually replace all the structs that appear in the parallel region with a large amount of arrays and end up having a code full of bulky parameter lists? Is there any work-around? Thanks!

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Could you provide us with a small reproducing example of the struct and pragma used?

Your description sounds similar to MIC samples (/opt/intel/composer_xe/Samples/en_US/C++/mic_samples/intro_sampleC) sample10.c and sample11.c.

In C, the array name is actually a pointer to the first element of the array. So the compiler is being honest when it says that the struct contains pointers. You may end up having to pass the arrays as individual arrays rather than part of the structure, then put them into a struct when you get into the offload section. Given that you also have scalars in the struct, you might want to put those in a separate struct so that they can be passed as a struct. Without seeing your code, I'm afraid that is the best solution I can come up with.

Thanks, Kevin and Frances. I read the sample code and solved the problem according to Frances' suggestion.

Leave a Comment

Please sign in to add a comment. Not a member? Join today