On 11.12.23 18:04, Andrew Stubbs wrote:
Implement the OpenMP pinned memory trait on Linux hosts using the mlock
syscall. Pinned allocations are performed using mmap, not malloc, to ensure
that they can be unpinned safely when freed.
This implementation will work OK for page-scale allocations, and finer-grained
allocations will be implemented in a future patch.
LGTM.
Thanks,
Tobias
libgomp/ChangeLog:
* allocator.c (MEMSPACE_ALLOC): Add PIN.
(MEMSPACE_CALLOC): Add PIN.
(MEMSPACE_REALLOC): Add PIN.
(MEMSPACE_FREE): Add PIN.
(MEMSPACE_VALIDATE): Add PIN.
(omp_init_allocator): Use MEMSPACE_VALIDATE to check pinning.
(omp_aligned_alloc): Add pinning to all MEMSPACE_* calls.
(omp_aligned_calloc): Likewise.
(omp_realloc): Likewise.
(omp_free): Likewise.
* config/linux/allocator.c: New file.
* config/nvptx/allocator.c (MEMSPACE_ALLOC): Add PIN.
(MEMSPACE_CALLOC): Add PIN.
(MEMSPACE_REALLOC): Add PIN.
(MEMSPACE_FREE): Add PIN.
(MEMSPACE_VALIDATE): Add PIN.
* config/gcn/allocator.c (MEMSPACE_ALLOC): Add PIN.
(MEMSPACE_CALLOC): Add PIN.
(MEMSPACE_REALLOC): Add PIN.
(MEMSPACE_FREE): Add PIN.
* libgomp.texi: Switch pinned trait to supported.
(MEMSPACE_VALIDATE): Add PIN.
* testsuite/libgomp.c/alloc-pinned-1.c: New test.
* testsuite/libgomp.c/alloc-pinned-2.c: New test.
* testsuite/libgomp.c/alloc-pinned-3.c: New test.
* testsuite/libgomp.c/alloc-pinned-4.c: New test.
Co-Authored-By: Thomas Schwinge <tho...@codesourcery.com>
---
libgomp/allocator.c | 65 +++++---
libgomp/config/gcn/allocator.c | 21 +--
libgomp/config/linux/allocator.c | 111 +++++++++++++
libgomp/config/nvptx/allocator.c | 21 +--
libgomp/libgomp.texi | 3 +-
libgomp/testsuite/libgomp.c/alloc-pinned-1.c | 115 ++++++++++++++
libgomp/testsuite/libgomp.c/alloc-pinned-2.c | 120 ++++++++++++++
libgomp/testsuite/libgomp.c/alloc-pinned-3.c | 156 +++++++++++++++++++
libgomp/testsuite/libgomp.c/alloc-pinned-4.c | 150 ++++++++++++++++++
9 files changed, 716 insertions(+), 46 deletions(-)
create mode 100644 libgomp/testsuite/libgomp.c/alloc-pinned-1.c
create mode 100644 libgomp/testsuite/libgomp.c/alloc-pinned-2.c
create mode 100644 libgomp/testsuite/libgomp.c/alloc-pinned-3.c
create mode 100644 libgomp/testsuite/libgomp.c/alloc-pinned-4.c
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht
München, HRB 106955