]> git.ipfire.org Git - thirdparty/gcc.git/commit
libgomp: basic pinned memory on Linux
authorAndrew Stubbs <ams@codesourcery.com>
Tue, 4 Jan 2022 12:22:01 +0000 (12:22 +0000)
committerAndrew Stubbs <ams@codesourcery.com>
Wed, 13 Dec 2023 14:27:07 +0000 (14:27 +0000)
commit348874f0baac0f22c98ab11abbfa65fd172f6bdd
treeabeccfd3dd7fd3541983f65ffd2b8bdcba654cc9
parent373a85a82650d9938adb02a14686049cbcbe6892
libgomp: basic pinned memory on Linux

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.

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 <thomas@codesourcery.com>
libgomp/allocator.c
libgomp/config/gcn/allocator.c
libgomp/config/linux/allocator.c
libgomp/config/nvptx/allocator.c
libgomp/libgomp.texi
libgomp/testsuite/libgomp.c/alloc-pinned-1.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/alloc-pinned-2.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/alloc-pinned-3.c [new file with mode: 0644]
libgomp/testsuite/libgomp.c/alloc-pinned-4.c [new file with mode: 0644]