gcc/libgomp/testsuite/libgomp.oacc-c-c++-common/deep-copy-arrayofstruct.c
Julian Brown 23baa717c9 OpenMP/OpenACC struct sibling list gimplification extension and rework
This patch refactors struct sibling-list processing in gimplify.cc, and
adjusts some related mapping-clause processing in the Fortran FE and
omp-low.cc accordingly.

2022-09-13  Julian Brown  <julian@codesourcery.com>

gcc/fortran/
	* trans-openmp.cc (gfc_trans_omp_clauses): Don't create
	GOMP_MAP_TO_PSET mappings for class metadata, nor GOMP_MAP_POINTER
	mappings for POINTER_TYPE_P decls.

gcc/
	* gimplify.cc (gimplify_omp_var_data): Remove GOVD_MAP_HAS_ATTACHMENTS.
	(GOMP_FIRSTPRIVATE_IMPLICIT): Renumber.
	(insert_struct_comp_map): Refactor function into...
	(build_omp_struct_comp_nodes): This new function.  Remove list handling
	and improve self-documentation.
	(extract_base_bit_offset): Remove BASE_REF, OFFSETP parameters.  Move
	code to strip outer parts of address out of function, but strip no-op
	conversions.
	(omp_mapping_group): Add DELETED field for use during reindexing.
	(omp_strip_components_and_deref, omp_strip_indirections): New functions.
	(omp_group_last, omp_group_base): Add GOMP_MAP_STRUCT handling.
	(omp_gather_mapping_groups): Initialise DELETED field for new groups.
	(omp_index_mapping_groups): Notice DELETED groups when (re)indexing.
	(omp_siblist_insert_node_after, omp_siblist_move_node_after,
	omp_siblist_move_nodes_after, omp_siblist_move_concat_nodes_after): New
	helper functions.
	(omp_accumulate_sibling_list): New function to build up GOMP_MAP_STRUCT
	node groups for sibling lists. Outlined from gimplify_scan_omp_clauses.
	(omp_build_struct_sibling_lists): New function.
	(gimplify_scan_omp_clauses): Remove struct_map_to_clause,
	struct_seen_clause, struct_deref_set.  Call
	omp_build_struct_sibling_lists as pre-pass instead of handling sibling
	lists in the function's main processing loop.
	(gimplify_adjust_omp_clauses_1): Remove GOVD_MAP_HAS_ATTACHMENTS
	handling, unused now.
	* omp-low.cc (scan_sharing_clauses): Handle pointer-type indirect
	struct references, and references to pointers to structs also.

gcc/testsuite/
	* g++.dg/goacc/member-array-acc.C: New test.
	* g++.dg/gomp/member-array-omp.C: New test.
	* g++.dg/gomp/target-3.C: Update expected output.
	* g++.dg/gomp/target-lambda-1.C: Likewise.
	* g++.dg/gomp/target-this-2.C: Likewise.
	* c-c++-common/goacc/deep-copy-arrayofstruct.c: Move test from here.
	* c-c++-common/gomp/target-50.c: New test.

libgomp/
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-15.c: New test.
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-16.c: New test.
	* testsuite/libgomp.oacc-c++/deep-copy-17.C: New test.
	* testsuite/libgomp.oacc-c-c++-common/deep-copy-arrayofstruct.c: Move
	test to here, make "run" test.
2022-09-14 13:59:55 +00:00

83 lines
1.4 KiB
C

/* { dg-do run } */
#include <stdlib.h>
#include <stdio.h>
typedef struct {
int *a;
int *b;
int *c;
} mystruct;
int main(int argc, char* argv[])
{
const int N = 1024;
const int S = 32;
mystruct *m = (mystruct *) calloc (S, sizeof (*m));
int i, j;
for (i = 0; i < S; i++)
{
m[i].a = (int *) malloc (N * sizeof (int));
m[i].b = (int *) malloc (N * sizeof (int));
m[i].c = (int *) malloc (N * sizeof (int));
}
for (j = 0; j < S; j++)
for (i = 0; i < N; i++)
{
m[j].a[i] = 0;
m[j].b[i] = 0;
m[j].c[i] = 0;
}
#pragma acc enter data copyin(m[0:1])
for (int i = 0; i < 99; i++)
{
int j, k;
for (k = 0; k < S; k++)
#pragma acc parallel loop copy(m[k].a[0:N])
for (j = 0; j < N; j++)
m[k].a[j]++;
for (k = 0; k < S; k++)
#pragma acc parallel loop copy(m[k].b[0:N], m[k].c[5:N-10])
for (j = 0; j < N; j++)
{
m[k].b[j]++;
if (j > 5 && j < N - 5)
m[k].c[j]++;
}
}
#pragma acc exit data copyout(m[0:1])
for (j = 0; j < S; j++)
{
for (i = 0; i < N; i++)
{
if (m[j].a[i] != 99)
abort ();
if (m[j].b[i] != 99)
abort ();
if (i > 5 && i < N-5)
{
if (m[j].c[i] != 99)
abort ();
}
else
{
if (m[j].c[i] != 0)
abort ();
}
}
free (m[j].a);
free (m[j].b);
free (m[j].c);
}
free (m);
return 0;
}