Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

pragma offload target(gfx) error

Mathieu_D
Beginner
359 Views

Hi,

I'm trying to write my first program using pragma offload target(gfx). I tried the exemple from this page, replacing mic with gfx :

subr.c
======
void subr()
{
}

main.c
======
int main()
{
  #pragma offload target(gfx)
  subr();
}

The output :

$ icc -c -qoffload-attribute-target=gfx subr.c
$ icc subr.o main.c
main.c(4): error: function "subr" called in offload region must have been declared with compatible "target" attribute
    subr();
    ^

main.c(4): error: offload target(gfx) or omp target pragma is not followed by a parallel loop
    subr();
    ^

compilation aborted for main.c (code 2)

How can I adapt this example to target "gfx" ?

If it helps, I have icc 17.0.1, from Intel Parallel Studio XE 2017 Cluster edition, and a Broadwell-U GPU (Iris pro 6200).

Thanks,

Mathieu

0 Kudos
2 Replies
Yuan_C_Intel
Employee
359 Views

Hi, Mathieu

The offloaded code on GPU need to run in parallel and vectorizable. The supported programming model in offloaded code for graphics are followings:

  • A Subset of Intel® Cilk™ Plus Language Extensions: The compiler supports the _Cilk_for, _Thread_group and__thread_group_local keywords to specify parallelism in offloaded code and thread group local data, as well as #pragma offload syntax to enable offload.

  • API-based Offload: In this model, you don't use any special syntax for initiating an offload, such as #pragma offload or #pragma omp target. Instead, you express data setup and offload using special API functions implemented in the Intel® Graphics Technology offload runtime. 

You can download and try our graphics processor samples as a start: Intel® C++ Compiler - Samples for Intel® Graphics Technology

Please also make sure you have read the getting started guide for all the requisites:

https://software.intel.com/en-us/articles/getting-started-with-compute-offload-to-intelr-graphics-technology

Hope this helps.

Thanks.

 

0 Kudos
Mathieu_D
Beginner
359 Views

Hi Yolanda,

Thank you for your answer, the samples are very useful.

Mathieu

0 Kudos
Reply