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
93 lines
1.8 KiB
C
93 lines
1.8 KiB
C
#include <assert.h>
|
|
|
|
#define C 55
|
|
|
|
int i, j, k;
|
|
|
|
static void
|
|
test_bzero (unsigned size)
|
|
{
|
|
unsigned bsize = size * sizeof (int);
|
|
int *x = __builtin_malloc (bsize);
|
|
__builtin_memset (x, C, bsize);
|
|
|
|
#pragma omp target map(tofrom: x[:size]) map(from: bsize)
|
|
{
|
|
__builtin_bzero (x, bsize);
|
|
}
|
|
|
|
char *buffer = (char *) x;
|
|
for (unsigned i = 0; i < bsize; ++i)
|
|
assert (buffer[i] == 0);
|
|
}
|
|
|
|
static void
|
|
test_memcpy (unsigned size)
|
|
{
|
|
unsigned bsize = size * sizeof (int);
|
|
int *x = __builtin_malloc (bsize);
|
|
__builtin_memset (x, C, bsize);
|
|
int *y = __builtin_malloc (bsize);
|
|
|
|
#pragma omp target map(tofrom: x[:size], y[:size]) map(from: bsize)
|
|
{
|
|
__builtin_memcpy (y, x, bsize);
|
|
}
|
|
|
|
char *buffer = (char *) y;
|
|
for (unsigned i = 0; i < bsize; ++i)
|
|
assert (buffer[i] == C);
|
|
}
|
|
|
|
static void
|
|
test_mempcpy (unsigned size)
|
|
{
|
|
unsigned bsize = size * sizeof (int);
|
|
int *x = __builtin_malloc (bsize);
|
|
__builtin_memset (x, C, bsize);
|
|
int *y = __builtin_malloc (bsize);
|
|
int *ptr = 0;
|
|
|
|
#pragma omp target map(tofrom :x[:size], y[:size], ptr) map(from: bsize)
|
|
{
|
|
ptr = __builtin_mempcpy (y, x, bsize);
|
|
}
|
|
|
|
char *buffer = (char *) y;
|
|
for (unsigned i = 0; i < bsize; ++i)
|
|
assert (buffer[i] == C);
|
|
|
|
assert (ptr == y + size);
|
|
}
|
|
|
|
static void
|
|
test_memset (unsigned size)
|
|
{
|
|
unsigned bsize = size * sizeof (int);
|
|
int *x = __builtin_malloc (bsize);
|
|
__builtin_bzero (x, bsize);
|
|
|
|
#pragma omp target map(tofrom : x[:size]) map(from: bsize)
|
|
{
|
|
__builtin_memset (x, C, bsize);
|
|
}
|
|
|
|
char *buffer = (char *) x;
|
|
for (unsigned i = 0; i < bsize; ++i)
|
|
assert (buffer[i] == C);
|
|
}
|
|
|
|
int
|
|
main (void)
|
|
{
|
|
unsigned tests[] = {1, 2, 3, 4, 5, 8, 15, 17, 23, 33, 0};
|
|
|
|
for (unsigned i = 0; tests[i]; i++)
|
|
{
|
|
test_bzero (tests[i]);
|
|
test_memset (tests[i]);
|
|
test_memcpy (tests[i]);
|
|
test_mempcpy (tests[i]);
|
|
}
|
|
}
|