]> 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)
committerKwok Cheung Yeung <kcy@codesourcery.com>
Tue, 28 Jun 2022 20:55:23 +0000 (13:55 -0700)
commit54c2d861ac62e30ebf34a4e62ee0d55478a742b9
treee33f7c046bb6f5dc1e4a22cd156536b0e10cfeeb
parent84914e197d91a67b3d27db0e4c69a433462983a5
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.cc (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.cc
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]