| 292 | } |
| 293 | |
| 294 | int NUMAGetMemAffinity(const void* addr) { |
| 295 | int node = kNUMANoAffinity; |
| 296 | #ifdef TENSORFLOW_USE_NUMA |
| 297 | if (HaveHWLocTopology() && addr) { |
| 298 | hwloc_nodeset_t nodeset = hwloc_bitmap_alloc(); |
| 299 | if (!hwloc_get_area_memlocation(hwloc_topology_handle, addr, 4, nodeset, |
| 300 | HWLOC_MEMBIND_BYNODESET)) { |
| 301 | hwloc_obj_t obj = nullptr; |
| 302 | while ((obj = hwloc_get_next_obj_by_type( |
| 303 | hwloc_topology_handle, HWLOC_OBJ_NUMANODE, obj)) != nullptr) { |
| 304 | if (hwloc_bitmap_isincluded(nodeset, obj->nodeset)) { |
| 305 | node = obj->os_index; |
| 306 | break; |
| 307 | } |
| 308 | } |
| 309 | hwloc_bitmap_free(nodeset); |
| 310 | } else { |
| 311 | LOG(ERROR) << "Failed call to hwloc_get_area_memlocation."; |
| 312 | } |
| 313 | } |
| 314 | #endif // TENSORFLOW_USE_NUMA |
| 315 | return node; |
| 316 | } |
| 317 | |
| 318 | void MallocExtension_ReleaseToSystem(std::size_t num_bytes) { |
| 319 | // No-op. |