- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My code has two versions, one using the pragma offload, the other using cilk offload. Now I want to simplify the codes such that the common functions and constants are put in the same files. Can this be achieved through conditional compilation? Something like:
#if MACRO_PRAGMA
#pragma offload_attribute(push,target(mic))
#else //MACRO_CILK
#pragma offload_attribute(push,_Cilk_shared)
#endif
Besides, what is the point of inventing two types of key words, target(mic) and _Cilk_shared, as the parameter of the offload_attribute. From my naive thought, doesn't target(mic) alone suffice? Thanks for explanation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Personally, I am a fan of using _Pragma for things like this, since then you can isolate the conditional behaviour in one place, and not have all of your code full of #if ... #else ... #endif noise.
So I'd be tempted to do something like (typed into this post, so not compiled :-))
[cpp]
#if SIMPLE_OFFLOAD
# define OFFLOAD_START _Pragma("offload_attribute(push,target(mic))")
# define OFFLOAD_END _Pragma("offload_attribute(pop)")
#elif CILK_OFFLOAD
# define OFFLOAD_START _Pragma("offload_attribute(push,_Cilk_shared))")
# define OFFLOAD_END _Pragma("offload_attribute(pop)")
#else
# define OFFLOAD_START
# define OFFLOAD_END
#endif
[/cpp]
Then you can ust use OFFLOAD_START and OFFLOAD_END in your code, choosing which offload style to do in one place.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Personally, I am a fan of using _Pragma for things like this, since then you can isolate the conditional behaviour in one place, and not have all of your code full of #if ... #else ... #endif noise.
So I'd be tempted to do something like (typed into this post, so not compiled :-))
[cpp]
#if SIMPLE_OFFLOAD
# define OFFLOAD_START _Pragma("offload_attribute(push,target(mic))")
# define OFFLOAD_END _Pragma("offload_attribute(pop)")
#elif CILK_OFFLOAD
# define OFFLOAD_START _Pragma("offload_attribute(push,_Cilk_shared))")
# define OFFLOAD_END _Pragma("offload_attribute(pop)")
#else
# define OFFLOAD_START
# define OFFLOAD_END
#endif
[/cpp]
Then you can ust use OFFLOAD_START and OFFLOAD_END in your code, choosing which offload style to do in one place.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The implementation for _Cilk_shared and pragma using target(mic) attribute are different. The compiler and runtime library (without going into details) generates additional information in shared memory for functions marked with _Cilk_shared to enable lookup during offload calls using _Cilk_offload.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page