[gcc/devel/omp/gcc-16] OpenMP: Add omp_get_device_distances routine: Initialize NUMA node for NVIDIA GPUs [PR125877]

Sandra Loosemore via Gcc-cvs <[email protected]>
Newsgroups gmane.comp.gcc.cvs
Message-ID <[email protected]>
https://gcc.gnu.org/g:a205e27a8bdca56771926520d8840fbd451713ff

commit a205e27a8bdca56771926520d8840fbd451713ff
Author: Thomas Schwinge <[email protected]>
Date:   Tue Jun 30 08:55:08 2026 +0200

    OpenMP: Add omp_get_device_distances routine: Initialize NUMA node for NVIDIA GPUs [PR125877]
    
    Fix-up for commit 8af1592882509fbead16e30fd2d056330a9609e4
    "OpenMP: Add omp_get_device_distances routine [PR125877]".  Without this,
    'libgomp/plugin/plugin-nvptx.c:GOMP_OFFLOAD_get_numa_node' returns random junk:
    
        /* Initialized to 0; to distinguish, save with offset.  */
        if (dev->numa_node != 0)
          return dev->numa_node > 0 ? dev->numa_node - 1 : dev->numa_node;
    
            PR libgomp/125877
            libgomp/
            * plugin/plugin-nvptx.c (nvptx_open_device): Initialize 'numa_node'.
    
    (cherry picked from commit 7759d1aaa500e36de9f87c0dc5e453787e07f051)

Diff:
---
 libgomp/plugin/plugin-nvptx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index e6a5d880b171..2f644a0acfcf 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -561,6 +561,8 @@ nvptx_open_device (int n)
 			 CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING, dev);
   assert (r == CUDA_SUCCESS && pi);
 
+  ptx_dev->numa_node = 0;
+
   for (int i = 0; i != GOMP_DIM_MAX; i++)
     ptx_dev->default_dims[i] = 0;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.