Commit 364f46de by Thomas Schwinge

Extend 'libgomp.oacc-c-c++-common/pr92854-1.c' some more [PR92854]

	libgomp/
	PR libgomp/92854
	* testsuite/libgomp.oacc-c-c++-common/pr92854-1.c: Extend some
	more.

(cherry picked from commit af8fd1a99d9a21f8088ebb11250cd06a3f275052)
parent c44c9858
/* Verify that 'acc_unmap_data' unmaps even in presence of dynamic reference /* Verify that 'acc_unmap_data' unmaps even in presence of structured and
counts. */ dynamic reference counts, but the device memory remains allocated. */
/* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */ /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <openacc.h> #include <openacc.h>
int int
main () main ()
{ {
const int N = 180; const int N = 180;
const int N_i = 537;
char *h = (char *) malloc (N); const int C = 37;
char *d = (char *) acc_malloc (N);
if (!d) unsigned char *h = (unsigned char *) malloc (N);
abort (); assert (h);
acc_map_data (h, d, N); unsigned char *d = (unsigned char *) acc_malloc (N);
assert (d);
char *d_ = (char *) acc_create (h + 3, N - 77);
assert (d_ == d + 3); for (int i = 0; i < N_i; ++i)
{
d_ = (char *) acc_create (h, N); acc_map_data (h, d, N);
assert (d_ == d); assert (acc_is_present (h, N));
#pragma acc parallel present(h[0:N])
acc_unmap_data (h); {
assert (!acc_is_present (h, N)); if (i == 0)
memset (h, C, N);
}
unsigned char *d_ = (unsigned char *) acc_create (h + 3, N - 77);
assert (d_ == d + 3);
#pragma acc data create(h[6:N - 44])
{
d_ = (unsigned char *) acc_create (h, N);
assert (d_ == d);
#pragma acc enter data create(h[0:N])
assert (acc_is_present (h, N));
acc_unmap_data (h);
assert (!acc_is_present (h, N));
}
/* We can however still access the device memory. */
#pragma acc parallel loop deviceptr(d)
for (int j = 0; j < N; ++j)
d[j] += i * j;
}
acc_memcpy_from_device(h, d, N);
for (int j = 0; j < N; ++j)
assert (h[j] == ((C + N_i * (N_i - 1) / 2 * j) % 256));
acc_free (d);
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment