Software Archive
Read-only legacy content
17061 Discussions

Offloading argv vector

Nikos_S_
Beginner
571 Views

Hello,

I am trying to offload the argv vector on MIC and I was wondering what would be the right path to follow.

I found out here : https://software.intel.com/en-us/forums/intel-many-integrated-core/topic/534766

that "The offload run-time dynamically determines the length of each string element and transfers each element accordingly."

by using something like:

#pragma offload target(mic) in(argv[0:argc])

error: variable "argv" used in this clause must point to a non-pointer type and not "char *"

Any suggestions?

Nikos

 

 

0 Kudos
3 Replies
Ashwin_D_1
Beginner
571 Views

I faced a similar problem in one of my projects. Check Array of pointers. (argv is a char** )

https://software.intel.com/en-us/articles/effective-use-of-the-intel-compilers-offload-features.

Hope this helps! 

0 Kudos
Nikos_S_
Beginner
571 Views

Thank Ashwin,

Indeed, that was the part I was missing. I managed to offload argv as a normal array of pointers.

Nikos

0 Kudos
Frances_R_Intel
Employee
571 Views

I think either I don't understand what you are doing or what you are doing is not really what you want to do.

In the article Ashwin pointed to, what it was saying was - if you have an array of pointers, then you need to pass each thing pointed to one at a time. They had an array of pointers to blocks of malloc memory. If the compiler allowed them to offload that array, (assuming they are not using _Cilk_shared) what they would see on the coprocessor is an array of pointers pointing to who knows what, but definitely not their blocks of malloc'ed memory. They had to pass each block of memory individually. In your case, this would be the same as passing each argument individually as an array of char.

Typically when you use the offload method of writing code for the coprocessor, you do some work on the host system, then pass the highly parallel parts of the work to the coprocessor. In this case, you would normally have already parsed argv on the host and would pass to the coprocessor the variables you created using those arguments. If you are starting your code up on the host system then immediately passing everything to the coprocessor, you might want to look into running the code natively on the coprocessor.

0 Kudos
Reply