Skip to content

Commit

Permalink
Add OpenACC 'acc_map_data' variant to 'libgomp.oacc-c-c++-common/deep…
Browse files Browse the repository at this point in the history
…-copy-8.c'

	libgomp/
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-8.c: Add OpenACC
	'acc_map_data' variant.
  • Loading branch information
tschwinge authored and ouuleilei-bot committed Oct 31, 2023
1 parent c2d62cd commit 91574a8
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-8.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ struct dc
int *d;
};

int
main ()
static void
test (unsigned variant)
{
int n = 100, i, j, k;
struct dc v = { .a = 3 };
Expand All @@ -22,7 +22,16 @@ main ()
v.c = (int *) malloc (sizeof (int) * n);
v.d = (int *) malloc (sizeof (int) * n);

if (variant & 1)
{
#pragma acc enter data copyin(v)
}
else
{
void *v_d = acc_malloc (sizeof v);
acc_map_data (&v, v_d, sizeof v);
acc_memcpy_to_device (v_d, &v, sizeof v);
}

for (k = 0; k < 16; k++)
{
Expand All @@ -46,9 +55,25 @@ main ()
assert (!acc_is_present (v.d, sizeof (int) * n));
}

if (variant & 1)
{
#pragma acc exit data copyout(v)
}
else
{
void *v_d = acc_deviceptr (&v);
acc_unmap_data (&v);
acc_free (v_d);
}

assert (!acc_is_present (&v, sizeof (v)));
}

int
main ()
{
for (unsigned variant = 0; variant < 2; ++variant)
test (variant);

return 0;
}

0 comments on commit 91574a8

Please sign in to comment.