[Openmp-commits] [PATCH] D32496: Fix Hwloc API Incompatibility

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Apr 25 11:18:29 PDT 2017


jlpeyton updated this revision to Diff 96608.
jlpeyton added a comment.

Updated the diff.  I had gotten errors when I tried that first, but now I realize that the SOCKET name is used in address2os map creation.  I've changed all of them to HWLOC_OBJ_PACKAGE now and added the `#ifndef` method.


Repository:
  rL LLVM

https://reviews.llvm.org/D32496

Files:
  runtime/src/kmp.h
  runtime/src/kmp_affinity.cpp


Index: runtime/src/kmp_affinity.cpp
===================================================================
--- runtime/src/kmp_affinity.cpp
+++ runtime/src/kmp_affinity.cpp
@@ -343,7 +343,7 @@
 }
 
 // Returns the number of objects of type 'type' below 'obj' within the topology tree structure.
-// e.g., if obj is a HWLOC_OBJ_SOCKET object, and type is HWLOC_OBJ_PU, then
+// e.g., if obj is a HWLOC_OBJ_PACKAGE object, and type is HWLOC_OBJ_PU, then
 //  this will return the number of PU's under the SOCKET object.
 static int
 __kmp_hwloc_get_nobjs_under_obj(hwloc_obj_t obj, hwloc_obj_type_t type) {
@@ -385,7 +385,7 @@
         //
         KMP_ASSERT(__kmp_affinity_type == affinity_none);
 
-        nCoresPerPkg = __kmp_hwloc_get_nobjs_under_obj(hwloc_get_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_SOCKET, 0), HWLOC_OBJ_CORE);
+        nCoresPerPkg = __kmp_hwloc_get_nobjs_under_obj(hwloc_get_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_PACKAGE, 0), HWLOC_OBJ_CORE);
         __kmp_nThreadsPerCore = __kmp_hwloc_get_nobjs_under_obj(hwloc_get_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_CORE, 0), HWLOC_OBJ_PU);
         __kmp_ncores = __kmp_xproc / __kmp_nThreadsPerCore;
         nPackages = (__kmp_xproc + nCoresPerPkg - 1) / nCoresPerPkg;
@@ -424,9 +424,9 @@
     int socket_identifier = 0;
     // re-calculate globals to count only accessible resources
     __kmp_ncores = nPackages = nCoresPerPkg = __kmp_nThreadsPerCore = 0;
-    for(socket = hwloc_get_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_SOCKET, 0);
+    for(socket = hwloc_get_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_PACKAGE, 0);
         socket != NULL;
-        socket = hwloc_get_next_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_SOCKET, socket),
+        socket = hwloc_get_next_obj_by_type(__kmp_hwloc_topology, HWLOC_OBJ_PACKAGE, socket),
         socket_identifier++)
     {
         int core_identifier = 0;
Index: runtime/src/kmp.h
===================================================================
--- runtime/src/kmp.h
+++ runtime/src/kmp.h
@@ -87,7 +87,13 @@
 #endif
 
 #if KMP_USE_HWLOC && KMP_AFFINITY_SUPPORTED
-# include "hwloc.h"
+#include "hwloc.h"
+#ifndef HWLOC_OBJ_NUMANODE
+#define HWLOC_OBJ_NUMANODE HWLOC_OBJ_NODE
+#endif
+#ifndef HWLOC_OBJ_PACKAGE
+#define HWLOC_OBJ_PACKAGE HWLOC_OBJ_SOCKET
+#endif
 #endif
 
 #if KMP_ARCH_X86 || KMP_ARCH_X86_64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32496.96608.patch
Type: text/x-patch
Size: 2350 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20170425/a0c0abc5/attachment.bin>


More information about the Openmp-commits mailing list