Commit 41f36f22 by Thomas Schwinge Committed by Thomas Schwinge

[PR92511] More testing for OpenACC "present" subarrays

In particular, "subset subarrays".

	libgomp/
	PR libgomp/92511
	* testsuite/libgomp.oacc-c-c++-common/copyin-devptr-1.c: Remove
	this file...
	* testsuite/libgomp.oacc-c-c++-common/copyin-devptr-2.c: ..., and
	this file...
	* testsuite/libgomp.oacc-c-c++-common/lib-22.c: ..., and this
	file...
	* testsuite/libgomp.oacc-c-c++-common/lib-30.c: ..., and this
	file...
	* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-r-p.c:
	... with their content moved into, and extended in this new file.
	* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-d-a.c:
	New file.
	* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-d-p.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-r-a.c:
	Likewise.
	* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-2.c:
	Likewise.

From-SVN: r279122
parent 6effebe1
2019-12-09 Thomas Schwinge <thomas@codesourcery.com>
PR libgomp/92511
* testsuite/libgomp.oacc-c-c++-common/copyin-devptr-1.c: Remove
this file...
* testsuite/libgomp.oacc-c-c++-common/copyin-devptr-2.c: ..., and
this file...
* testsuite/libgomp.oacc-c-c++-common/lib-22.c: ..., and this
file...
* testsuite/libgomp.oacc-c-c++-common/lib-30.c: ..., and this
file...
* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-r-p.c:
... with their content moved into, and extended in this new file.
* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-d-a.c:
New file.
* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-d-p.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-1-r-a.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/subset-subarray-mappings-2.c:
Likewise.
* testsuite/libgomp.oacc-c-c++-common/map-data-1.c: New file.
PR libgomp/92854
......
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include <openacc.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
int main (int argc, char* argv[])
{
char *myblock = (char *) malloc (1024);
int i;
void *dst;
for (i = 0; i < 1024; i++)
myblock[i] = i;
dst = acc_copyin (myblock, 1024);
for (i = 0; i < 1024; i += 256)
{
void *partdst = acc_pcopyin (&myblock[i], 256);
assert ((uintptr_t) partdst == (uintptr_t) dst + i);
}
for (i = 0; i < 1024; i += 256)
acc_delete (&myblock[i], 256);
assert (acc_is_present (myblock, 1024));
acc_delete (myblock, 1024);
assert (!acc_is_present (myblock, 1024));
free (myblock);
return 0;
}
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include <openacc.h>
#include <stdlib.h>
#include <assert.h>
#include <stdint.h>
int main (int argc, char* argv[])
{
char *block1 = (char *) malloc (1024);
char *block2 = (char *) malloc (1024);
char *block3 = (char *) malloc (1024);
int i;
void *dst;
for (i = 0; i < 1024; i++)
block1[i] = block2[i] = block3[i] = i;
#pragma acc data copyin(block1[0:1024]) copyin(block2[0:1024]) \
copyin(block3[0:1024])
{
dst = acc_deviceptr (block2);
for (i = 0; i < 1024; i += 256)
{
void *partdst = acc_pcopyin (&block2[i], 256);
assert ((uintptr_t) partdst == (uintptr_t) dst + i);
}
}
assert (acc_is_present (block2, 1024));
for (i = 0; i < 1024; i += 256)
acc_delete (&block2[i], 256);
assert (!acc_is_present (block2, 1024));
free (block1);
free (block2);
free (block3);
return 0;
}
/* Exercise acc_copyin and acc_copyout on nvidia targets. */
/* { dg-do run { target openacc_nvidia_accel_selected } } */
#include <stdio.h>
#include <stdlib.h>
#include <openacc.h>
int
main (int argc, char **argv)
{
const int N = 256;
int i;
unsigned char *h;
h = (unsigned char *) malloc (N);
for (i = 0; i < N; i++)
{
h[i] = i;
}
(void) acc_copyin (h, N);
fprintf (stderr, "CheCKpOInT\n");
acc_copyout (h + 1, N - 1);
free (h);
return 0;
}
/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
/* Exercise an invalid partial acc_delete on nvidia targets. */
/* { dg-do run { target openacc_nvidia_accel_selected } } */
#include <stdio.h>
#include <stdlib.h>
#include <openacc.h>
int
main (int argc, char **argv)
{
const int N = 256;
unsigned char *h;
void *d;
h = (unsigned char *) malloc (N);
d = acc_create (h, N);
if (!d)
abort ();
fprintf (stderr, "CheCKpOInT\n");
acc_delete (h, N - 2);
free (h);
return 0;
}
/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
/* Test "subset" subarray mappings
{ dg-additional-options "-DOPENACC_DIRECTIVES" } using OpenACC directives,
{ dg-additional-options "-DARRAYS" } using arrays. */
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include "subset-subarray-mappings-1-r-p.c"
/* Test "subset" subarray mappings
{ dg-additional-options "-DOPENACC_DIRECTIVES" } using OpenACC directives,
{ dg-additional-options "-DPOINTERS" } using pointers. */
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include "subset-subarray-mappings-1-r-p.c"
/* Test "subset" subarray mappings
{ dg-additional-options "-DOPENACC_RUNTIME" } using OpenACC Runtime Library routines,
{ dg-additional-options "-DARRAYS" } using arrays. */
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include "subset-subarray-mappings-1-r-p.c"
/* Test "subset" subarray mappings. */
/* { dg-skip-if "" { *-*-* } { "-DACC_MEM_SHARED=1" } } */
#include <openacc.h>
#include <acc_prof.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
static bool cb_ev_alloc_expected;
static size_t cb_ev_alloc_bytes;
static const void *cb_ev_alloc_device_ptr;
static void
cb_ev_alloc (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
{
assert (cb_ev_alloc_expected);
cb_ev_alloc_expected = false;
cb_ev_alloc_bytes = event_info->data_event.bytes;
cb_ev_alloc_device_ptr = event_info->data_event.device_ptr;
}
static bool cb_ev_free_expected;
static const void *cb_ev_free_device_ptr;
static void
cb_ev_free (acc_prof_info *prof_info, acc_event_info *event_info, acc_api_info *api_info)
{
assert (cb_ev_free_expected);
cb_ev_free_expected = false;
cb_ev_free_device_ptr = event_info->data_event.device_ptr;
}
/* Match the alignment processing that
'libgomp/target.c:gomp_map_vars_internal' is doing; simplified, not
considering special alignment requirements of certain data types. */
static size_t
aligned_size (size_t tgt_size)
{
size_t tgt_align = sizeof (void *);
return tgt_size + tgt_align - 1;
}
static const void *
aligned_address (const void *tgt_start)
{
size_t tgt_align = sizeof (void *);
return (void *) (((uintptr_t) tgt_start + tgt_align - 1) & ~(tgt_align - 1));
}
#define SIZE 1024
int
main ()
{
cb_ev_alloc_expected = false;
cb_ev_free_expected = false;
acc_prof_register (acc_ev_alloc, cb_ev_alloc, acc_reg);
acc_prof_register (acc_ev_free, cb_ev_free, acc_reg);
char *block1 = (char *) malloc (SIZE);
char *block2 = (char *) malloc (SIZE);
char *block3 = (char *) malloc (SIZE);
cb_ev_alloc_expected = true;
#pragma acc data create (block1[0:SIZE], block2[0:SIZE], block3[0:SIZE])
{
void *s_block1_d = acc_deviceptr (&block1[1]);
void *s_block2_d = acc_deviceptr (&block2[20]);
void *s_block3_d = acc_deviceptr (&block3[300]);
assert (!cb_ev_alloc_expected);
/* 'block1', 'block2', 'block3' get mapped in one device memory object, in
reverse order. */
assert (cb_ev_alloc_bytes == aligned_size (3 * SIZE));
assert ((void *) ((uintptr_t) aligned_address (cb_ev_alloc_device_ptr) + 2 * SIZE + 1) == s_block1_d);
assert ((void *) ((uintptr_t) aligned_address (cb_ev_alloc_device_ptr) + 1 * SIZE + 20) == s_block2_d);
assert ((void *) ((uintptr_t) aligned_address (cb_ev_alloc_device_ptr) + 0 * SIZE + 300) == s_block3_d);
void *s_block1_p_d = acc_pcopyin (&block1[1], SIZE - 3);
void *s_block2_p_d = acc_pcopyin (&block2[20], SIZE - 33);
void *s_block3_p_d = acc_pcopyin (&block3[300], SIZE - 333);
assert (s_block1_p_d == s_block1_d);
assert (s_block2_p_d == s_block2_d);
assert (s_block3_p_d == s_block3_d);
acc_delete (block1, SIZE);
acc_delete (block2, SIZE);
acc_delete (block3, SIZE);
assert (acc_is_present (block1, SIZE));
assert (acc_is_present (block2, SIZE));
assert (acc_is_present (block3, SIZE));
cb_ev_free_expected = true;
}
assert (!cb_ev_free_expected);
assert (cb_ev_free_device_ptr == cb_ev_alloc_device_ptr);
assert (!acc_is_present (block1, SIZE));
assert (!acc_is_present (block2, SIZE));
assert (!acc_is_present (block3, SIZE));
free (block1);
free (block2);
free (block3);
acc_prof_unregister (acc_ev_alloc, cb_ev_alloc, acc_reg);
acc_prof_unregister (acc_ev_free, cb_ev_free, acc_reg);
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