That's for omp_get_device_distances – missed to state this in the subject line.

Support for this war written in the original patch, found when
writing the test case, added for Linux - but missed in the non-Linux
fallback before committing it as r17-1702-g8af1592882509f.

Hence, the testcase failed on non-Linux. Thanks to Rainer for
reporting the issue, including using the debugger to pinpoint the
fail!

Committed as r17-1793-g23aa47659828ae

Tobias
commit 23aa47659828ae13898b76b1516f17fef8562a7e
Author: Tobias Burnus <[email protected]>
Date:   Wed Jun 24 06:30:25 2026 +0200

    libgomp: Handle omp_default_device in the fallback case [PR125951]
    
    Support for omp_default_device was added before the commit
    r17-1702-g8af1592882509f for the Linux case, but for the fallback
    case, it was missed - such that the testcase failed on all
    non-Linux systems.
    
    libgomp/ChangeLog:
    
            PR libgomp/125951
    
            * target.c (omp_get_device_distances): Handle omp_default_device
            in the fallback code.
---
 libgomp/target.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/libgomp/target.c b/libgomp/target.c
index 47fdd7458ea..78f390d593f 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -6153,12 +6153,17 @@ omp_get_device_distances (int ndevs, const int *devs, int *distances)
   if (node < 0) /* Not supported. */
     {
       for (int i = 0; i < ndevs; i++)
-	if (devs[i] < omp_initial_device || devs[i] > num_devices)
-	  distances[i] = -1;  /* invalid */
-	else if (devs[i] == omp_initial_device || devs[i] == num_devices)
-	  distances[i] = 0;
-	else
-	  distances[i] = 10;
+	{
+	  int device_num = (devs[i] == omp_default_device
+			    ? gomp_get_default_device () : devs[i]);
+	  if (device_num < omp_initial_device || device_num > num_devices)
+	    distances[i] = -1;  /* invalid */
+	  else if (device_num == omp_initial_device
+		   || device_num == num_devices)
+	    distances[i] = 0;
+	  else
+	    distances[i] = 10;
+	}
       return;
     }
   for (int i = 0; i < ndevs; i++)

Reply via email to