gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/pr92984-1.c
Thomas Schwinge ddb25eb9ca [PR92726, PR92970, PR92984] [OpenACC] Clarify 'acc_delete' etc. for 'NULL'-in, non-present data, or size zero
PR92970 "OpenACC 2.5: 'acc_delete' etc. on non-present data is a no-op" is an
actual bug fix, and the other ones are fall-out, currently undefined behavior.

	libgomp/
	PR libgomp/92726
	PR libgomp/92970
	PR libgomp/92984
	* oacc-mem.c (delete_copyout): No-op behavior if 'lookup_host'
	fails.
	(GOACC_enter_exit_data): Simplify accordingly.
	* testsuite/libgomp.oacc-c-c++-common/pr92970-1.c: New file,
	subsuming...
	* testsuite/libgomp.oacc-c-c++-common/lib-17.c: ... this file...
	* testsuite/libgomp.oacc-c-c++-common/lib-18.c: ..., and this
	file.
	* testsuite/libgomp.oacc-c-c++-common/pr92984-1.c: New file,
	subsuming...
	* testsuite/libgomp.oacc-c-c++-common/lib-21.c: ... this file...
	* testsuite/libgomp.oacc-c-c++-common/lib-29.c: ..., and this
	file.
	* testsuite/libgomp.oacc-c-c++-common/pr92726-1.c: New file,
	subsuming...
	* testsuite/libgomp.oacc-c-c++-common/lib-28.c: ... this file.

From-SVN: r279532
2019-12-18 18:01:11 +01:00

101 lines
2.5 KiB
C

/* Verify that 'acc_delete' etc. with zero size is a no-op. */
#include <assert.h>
#include <stdlib.h>
#include <openacc.h>
#define UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
static void
verify_mapped_unchanged (unsigned char *a, size_t N)
{
assert (acc_is_present (a, N));
for (size_t i = 0; i < N; ++i)
assert (a[i] == (unsigned char) i);
}
int
main (int argc, char **argv)
{
const size_t N = 256;
unsigned char *a = (unsigned char *) malloc (N);
assert (a);
for (size_t i = 0; i < N; ++i)
a[i] = 51;
void *a_d = acc_copyin (a, N);
assert (a_d);
for (size_t i = 0; i < N; ++i)
a[i] = i;
int async = 0;
const size_t size = 0;
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data copyout (a[0:size])
verify_mapped_unchanged (a, N);
#endif
acc_copyout (a, size);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data copyout (a[0:size]) async (async++)
verify_mapped_unchanged (a, N);
#endif
acc_copyout_async (a, size, async++);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data copyout (a[0:size]) finalize
verify_mapped_unchanged (a, N);
#endif
acc_copyout_finalize (a, size);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data copyout (a[0:size]) finalize async (async++)
verify_mapped_unchanged (a, N);
#endif
acc_copyout_finalize_async (a, size, async++);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data delete (a[0:size])
verify_mapped_unchanged (a, N);
#endif
acc_delete (a, size);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data delete (a[0:size]) async (async++)
verify_mapped_unchanged (a, N);
#endif
acc_delete_async (a, size, async++);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data delete (a[0:size]) finalize
verify_mapped_unchanged (a, N);
#endif
acc_delete_finalize (a, size);
verify_mapped_unchanged (a, N);
#ifndef UNHANDLED_GOMP_MAP_ZERO_LEN_ARRAY_SECTION
#pragma acc exit data delete (a[0:size]) finalize async (async++)
verify_mapped_unchanged (a, N);
#endif
acc_delete_finalize_async (a, size, async++);
verify_mapped_unchanged (a, N);
acc_wait_all ();
acc_delete (a, N);
#if !ACC_MEM_SHARED
assert (!acc_is_present (a, N));
#endif
free (a);
return 0;
}