gcc/libgomp/testsuite/libgomp.hsa.c/switch-1.c
Martin Jambor 96a71bd53c [hsa testsuite] New directory for HSA-specific C testcases
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
2016-03-07 19:45:17 +01:00

146 lines
2.1 KiB
C

#include <assert.h>
#define s 100
#pragma omp declare target
int
switch1 (int a)
{
switch (a)
{
case 1:
return 11;
case 33:
return 333;
case 55:
return 55;
default:
return -1;
}
}
int
switch2 (int a)
{
switch (a)
{
case 1 ... 11:
return 11;
break;
case 33:
return 333;
break;
case 55:
return 55;
break;
default:
return -1;
}
}
int
switch3 (int a)
{
switch (a)
{
case 1 ... 11:
return 11;
case 12 ... 22:
return 22;
case 23 ... 33:
return 33;
case 34 ... 44:
return 44;
default:
return 44;
}
}
int
switch4 (int a, int b)
{
switch (a)
{
case 1 ... 11:
return a;
case 12 ... 22:
return b;
case 23 ... 33:
return a;
case 34 ... 44:
return b;
default:
return 12345;
}
}
int
switch5 (int a, int b)
{
switch (a)
{
case 1 ... 2:
return 1;
case 3 ... 4:
return 2;
case 5 ... 6:
return 3;
case 7 ... 11:
return 4;
}
return -1;
}
#pragma omp end declare target
int
main (int argc)
{
int array[s];
#pragma omp target map(tofrom : array[:s])
{
for (int i = 0; i < s; i++)
array[i] = switch1 (i);
}
for (int i = 0; i < s; i++)
assert (array[i] == switch1 (i));
#pragma omp target map(tofrom : array[:s])
{
for (int i = 0; i < s; i++)
array[i] = switch2 (i);
}
for (int i = 0; i < s; i++)
assert (array[i] == switch2 (i));
#pragma omp target map(tofrom : array[:s])
{
for (int i = 0; i < s; i++)
array[i] = switch3 (i);
}
for (int i = 0; i < s; i++)
assert (array[i] == switch3 (i));
#pragma omp target map(tofrom : array[:s])
{
for (int i = 0; i < s; i++)
array[i] = switch4 (i, i + 1);
}
for (int i = 0; i < s; i++)
assert (array[i] == switch4 (i, i + 1));
#pragma omp target map(tofrom : array[:s])
{
for (int i = 0; i < s; i++)
array[i] = switch5 (i, i + 1);
}
for (int i = 0; i < s; i++)
assert (array[i] == switch5 (i, i + 1));
}