]> git.ipfire.org Git - thirdparty/gcc.git/commit
openmp: Use libgomp memory allocation functions with unified shared memory.
authorHafiz Abid Qadeer <abidh@codesourcery.com>
Fri, 11 Mar 2022 12:50:26 +0000 (12:50 +0000)
committerHafiz Abid Qadeer <abidh@codesourcery.com>
Fri, 11 Mar 2022 23:03:59 +0000 (23:03 +0000)
commit37e77cae79aeb42052453c62d8ea95076f1e22d9
treebc1401aeaa00e727217d9ee9a325c50e28f3a89b
parent3c40959d65df50c5afaf6f22aaca7fac8b39f36b
openmp: Use libgomp memory allocation functions with unified shared memory.

This patches changes calls to malloc/free/calloc/realloc/aligned_alloc and
operator new to memory allocation functions in libgomp with
allocator=ompx_unified_shared_mem_alloc.  This helps existing code to benefit
from the unified shared memory.  The libgomp does the correct thing with all
the mapping constructs and there is no memory copies if the pointer is pointing
to unified shared memory.

We only replace replacable new operator and not the class member or placement new.

Backport of a patch posted at
https://gcc.gnu.org/pipermail/gcc-patches/2022-March/591353.html

gcc/ChangeLog:

* omp-low.c (usm_transform): New function.
(make_pass_usm_transform): Likewise.
(class pass_usm_transform): New.
* passes.def: Add pass_usm_transform.
* tree-pass.h (make_pass_usm_transform): New declaration.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/usm-2.c: New test.
* c-c++-common/gomp/usm-3.c: New test.
* g++.dg/gomp/usm-1.C: New test.
* g++.dg/gomp/usm-2.C: New test.
* g++.dg/gomp/usm-3.C: New test.
* gfortran.dg/gomp/usm-2.f90: New test.
* gfortran.dg/gomp/usm-3.f90: New test.

libgomp/ChangeLog:

* testsuite/libgomp.c/usm-6.c: New test.
* testsuite/libgomp.c++/usm-1.C: Likewise.
15 files changed:
gcc/ChangeLog.omp
gcc/omp-low.c
gcc/passes.def
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/usm-2.c [new file with mode: 0644]
gcc/testsuite/c-c++-common/gomp/usm-3.c [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/usm-1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/usm-2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/gomp/usm-3.C [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/usm-2.f90 [new file with mode: 0644]
gcc/testsuite/gfortran.dg/gomp/usm-3.f90 [new file with mode: 0644]
gcc/tree-pass.h
libgomp/ChangeLog.omp
libgomp/testsuite/libgomp.c++/usm-1.C [new file with mode: 0644]
libgomp/testsuite/libgomp.c/usm-6.c [new file with mode: 0644]