gcc/libgomp/testsuite/libgomp.hsa.c/rotate-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

40 lines
669 B
C

#include <assert.h>
#include <limits.h>
#define T unsigned int
#define BITSIZE CHAR_BIT * sizeof (T)
#define C1 123u
#pragma omp declare target
T
rotate (T value, T shift)
{
T r = (value << shift) | (value >> (BITSIZE - shift));
return (r >> shift) | (r << (BITSIZE - shift));
}
#pragma omp end declare target
int
main (int argc)
{
T v1, v2, v3, v4, v5;
#pragma omp target map(to: v1, v2, v3, v4, v5)
{
v1 = rotate (C1, 10);
v2 = rotate (C1, 2);
v3 = rotate (C1, 5);
v4 = rotate (C1, 16);
v5 = rotate (C1, 32);
}
assert (v1 == C1);
assert (v2 == C1);
assert (v3 == C1);
assert (v4 == C1);
assert (v5 == C1);
return 0;
}