96a71bd53c
2016-03-07 Martin Jambor <mjambor@suse.cz> * testsuite/lib/libgomp.exp (check_effective_target_hsa_offloading_selected_nocache): New. (check_effective_target_hsa_offloading_selected): Likewise. * testsuite/libgomp.hsa.c/c.exp: Likewise. * testsuite/libgomp.hsa.c/alloca-1.c: Likewise. * testsuite/libgomp.hsa.c/bitfield-1.c: Likewise. * testsuite/libgomp.hsa.c/builtins-1.c: Likewise. * testsuite/libgomp.hsa.c/complex-1.c: Likewise. * testsuite/libgomp.hsa.c/formal-actual-args-1.c: Likewise. * testsuite/libgomp.hsa.c/function-call-1.c: Likewise. * testsuite/libgomp.hsa.c/get-level-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-1.c: Likewise. * testsuite/libgomp.hsa.c/gridify-2.c: Likewise. * testsuite/libgomp.hsa.c/gridify-3.c: Likewise. * testsuite/libgomp.hsa.c/gridify-4.c: Likewise. * testsuite/libgomp.hsa.c/memory-operations-1.c: Likewise. * testsuite/libgomp.hsa.c/pr69568.c: Likewise. * testsuite/libgomp.hsa.c/rotate-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-1.c: Likewise. * testsuite/libgomp.hsa.c/switch-branch-1.c: Likewise. From-SVN: r234047
84 lines
1.1 KiB
C
84 lines
1.1 KiB
C
#include <assert.h>
|
|
|
|
struct Cube
|
|
{
|
|
int x;
|
|
int y;
|
|
int z;
|
|
};
|
|
|
|
#pragma omp declare target
|
|
int
|
|
foo (short a)
|
|
{
|
|
switch (a)
|
|
{
|
|
case 1:
|
|
return 11;
|
|
break;
|
|
case 33:
|
|
return 333;
|
|
break;
|
|
case 55:
|
|
return 55;
|
|
break;
|
|
default:
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
int
|
|
bar (int a)
|
|
{
|
|
int *ptr = &a;
|
|
|
|
*ptr = 100;
|
|
return a + *ptr;
|
|
}
|
|
|
|
struct Cube
|
|
baz (struct Cube c)
|
|
{
|
|
c.x = 11;
|
|
return c;
|
|
}
|
|
|
|
#pragma omp end declare target
|
|
|
|
#define s 100
|
|
|
|
int
|
|
main (int argc)
|
|
{
|
|
/* Test 1: argument types: char to short. */
|
|
|
|
int array[s];
|
|
#pragma omp target map(tofrom : array[ : s])
|
|
{
|
|
for (char i = 0; i < s; i++)
|
|
array[i] = foo (i);
|
|
}
|
|
|
|
for (int i = 0; i < s; i++)
|
|
assert (array[i] == foo (i));
|
|
|
|
/* Test 2: argument address is taken. */
|
|
int v = 2;
|
|
|
|
#pragma omp target map(tofrom : v)
|
|
v = bar (v);
|
|
|
|
assert (v == 200);
|
|
|
|
/* Test 3: passing a structure as a function argument. */
|
|
struct Cube r;
|
|
struct Cube c = {.x = 1, .y = 2, .z = 3};
|
|
|
|
#pragma omp target map(to : r) map(from : c)
|
|
r = baz (c);
|
|
|
|
assert (r.x == 11);
|
|
assert (r.y == c.y);
|
|
assert (r.z == c.z);
|
|
}
|