0

Can we offload to the graphics hardware using cilk plus with gcc-5.2

g++ -std=c++14 -Wall -O3 -march=native -fcilkplus vec_add.cpp -o vec_add
vec_add.cpp:6:0: warning: ignoring #pragma offload target [-Wunknown-pragmas]
 #pragma offload target(gfx) pin(out, in1, in2 : length(n))

The compiler gives the above warning for the following test code:

#include <iostream>
#include <cilk/cilk.h>

void vec_add(int n, float *out, float *in1, float *in2)
{
#pragma offload target(gfx) pin(out, in1, in2 : length(n))
    cilk_for(int i = 0; i != n; ++i)
    {
        out[i] = in1[i] + in2[i];
    }
}

static int ar_sz = 100000;
int main (int argc, char **argv)
{
    float foo[ar_sz];
    float bar[ar_sz];
    float out[ar_sz];
    for(int i = 0; i != ar_sz; ++i)
    {
        foo[i] = i + ar_sz * 10;
        bar[i] = i;
    }
    vec_add(ar_sz, out, foo, bar);

    for(int i = 0; i != ar_sz; i += 100)
    {
        std::cout << "foo[" << i << "] =" << foo[i] << "\t|\tbar[" << i << "] =" <<  bar[i] << std::endl;
    }
}

Compiled with

FLAGS=-std=c++14 -Wall -O3 -march=native -fcilkplus

all: vec_add fib

vec_add: vec_add.cpp
    g++ $(FLAGS) $< -o $@
Hal
  • 1,061
  • 7
  • 20

2 Answers2

0

GCC does not support offload pragma as far as I know, so it's not possible to do this. Actually, the warning message is explicitly saying that it is an unknown pragma.

  • The release notes for gcc 5 claim "Full support for Cilk Plus has been added to the GCC compiler. Cilk Plus is an extension to the C and C++ languages to support data and task parallelism." Maybe that's false? Either way I still want to know "Can we offload to the graphics hardware using cilk plus with gcc-5.2?" – Hal Apr 20 '16 at 00:55
0

"Full support for Cilk Plus has been added to the GCC compiler." This means full support for only the language extensions of cilk plus. Gcc cannot offload to intel integrated graphics at all. OpenMP reportedly can offload to a Xeon Phi coprocessor and nvidia graphics cards.

https://gcc.gnu.org/ml/gcc/2016-04/msg00182.html

Hal
  • 1,061
  • 7
  • 20