2298ca2d3e
This marks all variants of declare variant also declare target if the base functions are called directly in target regions or declare target functions. 2020-10-28 Jakub Jelinek <jakub@redhat.com> gcc/ * omp-offload.c (omp_declare_target_tgt_fn_r): Handle direct calls to declare variant base functions. libgomp/ * testsuite/libgomp.c/target-42.c: New test.
43 lines
618 B
C
43 lines
618 B
C
#include <stdio.h>
|
|
|
|
int
|
|
on_nvptx (void)
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
int
|
|
on_gcn (void)
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
#pragma omp declare variant (on_nvptx) match(construct={target},device={arch(nvptx)})
|
|
#pragma omp declare variant (on_gcn) match(construct={target},device={arch(gcn)})
|
|
int
|
|
on (void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
int v;
|
|
#pragma omp target map(from:v)
|
|
v = on ();
|
|
switch (v)
|
|
{
|
|
default:
|
|
printf ("Host fallback or unknown offloading\n");
|
|
break;
|
|
case 1:
|
|
printf ("Offloading to NVidia PTX\n");
|
|
break;
|
|
case 2:
|
|
printf ("Offloading to AMD GCN\n");
|
|
break;
|
|
}
|
|
return 0;
|
|
}
|