/* * Get the number of net cards in a NUMA node */ int hw_get_nnetcards(int NUMAnode) { int count, net_NUMAnode, error; hwloc_obj_t obj, obj_anc; count = 0; hwloc_topology_t topo_net; error = hwloc_topology_init(&topo_net); hwloc_topology_set_flags(topo_net, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); if (!error){ hwloc_topology_load(topo_net); for (obj = hwloc_get_obj_by_type(topo_net, HWLOC_OBJ_OS_DEVICE, 0); obj; obj = hwloc_get_next_osdev(topo_net,obj)) if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_NETWORK || obj->attr->osdev.type == HWLOC_OBJ_OSDEV_OPENFABRICS){ obj_anc = hwloc_get_non_io_ancestor_obj(topo_net,obj); net_NUMAnode = hwloc_bitmap_first(obj_anc->nodeset); //only if the MPI NUMA node is equal to the found net card if(NUMAnode == net_NUMAnode) count++; } } hwloc_topology_destroy(topo_net); return count; }
int main(void) { hwloc_topology_t topology; int i; int err; hwloc_topology_init(&topology); hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); hwloc_topology_load(topology); for(i=0; ; i++) { hwloc_bitmap_t set; hwloc_obj_t osdev, ancestor; const char *value; osdev = hwloc_intel_mic_get_device_osdev_by_index(topology, i); if (!osdev) break; assert(osdev); ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); printf("found OSDev %s\n", osdev->name); err = strncmp(osdev->name, "mic", 3); assert(!err); assert(atoi(osdev->name+3) == (int) i); assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC); value = hwloc_obj_get_info_by_name(osdev, "CoProcType"); err = strcmp(value, "MIC"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "MICFamily"); printf("found MICFamily %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICSKU"); printf("found MICSKU %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICActiveCores"); printf("found MICActiveCores %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICMemorySize"); printf("found MICMemorySize %s\n", value); set = hwloc_bitmap_alloc(); err = hwloc_intel_mic_get_device_cpuset(topology, i, set); if (err < 0) { printf("failed to get cpuset for device %d\n", i); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for device %d\n", cpuset_string, i); assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); free(cpuset_string); } hwloc_bitmap_free(set); } hwloc_topology_destroy(topology); return 0; }
/* * Find a NUMA node with network cards * */ int hw_get_node_net() { int net_NUMAnode=0, error; hwloc_obj_t obj, obj_anc; hwloc_topology_t topo_net; error = hwloc_topology_init(&topo_net); hwloc_topology_set_flags(topo_net, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); if (!error){ hwloc_topology_load(topo_net); obj = hwloc_get_obj_by_type(topo_net, HWLOC_OBJ_OS_DEVICE, 0); if (obj != NULL){ obj_anc = hwloc_get_non_io_ancestor_obj(topo_net,obj); net_NUMAnode = hwloc_bitmap_first(obj_anc->nodeset); } } return net_NUMAnode; }
/* * Returns the network card of a MPI process * */ int hw_my_netCard(int core, int myRank) { int card=0, error, nnetcards, *netcards, my_local_cards=0; int NUMAnode = hw_get_myNode(core), net_NUMAnode; hwloc_obj_t obj, obj_anc; nnetcards = hw_get_nnetcards(NUMAnode); netcards = malloc(nnetcards*sizeof(int)); hwloc_topology_t topo_net; error = hwloc_topology_init(&topo_net); hwloc_topology_set_flags(topo_net, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); if (!error){ hwloc_topology_load(topo_net); my_local_cards = 0; for (obj = hwloc_get_obj_by_type(topo_net, HWLOC_OBJ_OS_DEVICE, 0); obj ; obj = hwloc_get_next_osdev(topo_net,obj)) if (obj->attr->osdev.type == HWLOC_OBJ_OSDEV_NETWORK || obj->attr->osdev.type == HWLOC_OBJ_OSDEV_OPENFABRICS) { obj_anc = hwloc_get_non_io_ancestor_obj(topo_net,obj); net_NUMAnode = hwloc_bitmap_first(obj_anc->nodeset); if ( net_NUMAnode == NUMAnode ) { netcards[my_local_cards] = obj->os_index; my_local_cards++;} } } hwloc_topology_destroy(topo_net); if (!my_local_cards) return -1; //no net affinity else return netcards[myRank%nnetcards]; }
int main(void) { hwloc_topology_t topology; cl_int clret; cl_platform_id *platform_ids; unsigned nrp, nrd, count, i, j; int err; hwloc_topology_init(&topology); hwloc_topology_set_type_filter(topology, HWLOC_OBJ_PCI_DEVICE, HWLOC_TYPE_FILTER_KEEP_IMPORTANT); hwloc_topology_set_type_filter(topology, HWLOC_OBJ_OS_DEVICE, HWLOC_TYPE_FILTER_KEEP_IMPORTANT); hwloc_topology_load(topology); clret = clGetPlatformIDs(0, NULL, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; platform_ids = malloc(nrp * sizeof(*platform_ids)); if (!platform_ids) return 0; clret = clGetPlatformIDs(nrp, platform_ids, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; count = 0; for(i=0; i<nrp; i++) { cl_device_id *device_ids; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, 0, NULL, &nrd); if (CL_SUCCESS != clret || !nrd) continue; device_ids = malloc(nrd * sizeof(*device_ids)); if (!device_ids) continue; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, nrd, device_ids, &nrd); if (CL_SUCCESS != clret || !nrd) continue; for(j=0; j<nrd; j++) { hwloc_bitmap_t set; hwloc_obj_t osdev, osdev2, ancestor; const char *value; unsigned p, d; osdev = hwloc_opencl_get_device_osdev_by_index(topology, i, j); /* we currently insert all OpenCL devices, except CPU devices */ if (!osdev) { cl_device_type type; clGetDeviceInfo(device_ids[j], CL_DEVICE_TYPE, sizeof(type), &type, NULL); assert(type == CL_DEVICE_TYPE_CPU); continue; } /* try to get it from PCI locality (only works with AMD extensions) */ osdev2 = hwloc_opencl_get_device_osdev(topology, device_ids[j]); if (osdev2) { assert(osdev == osdev2); } ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); set = hwloc_bitmap_alloc(); err = hwloc_opencl_get_device_cpuset(topology, device_ids[j], set); if (err < 0) { printf("no cpuset for platform %u device %u\n", i, j); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for platform %u device %u\n", cpuset_string, i, j); free(cpuset_string); if (hwloc_bitmap_isequal(hwloc_topology_get_complete_cpuset(topology), hwloc_topology_get_topology_cpuset(topology))) /* only compare if the topology is complete, otherwise things can be significantly different */ assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); } hwloc_bitmap_free(set); printf("found OSDev %s\n", osdev->name); err = sscanf(osdev->name, "opencl%ud%u", &p, &d); assert(err == 2); assert(p == i); assert(d == j); value = hwloc_obj_get_info_by_name(osdev, "Backend"); err = strcmp(value, "OpenCL"); assert(!err); assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC); value = osdev->subtype; assert(value); err = strcmp(value, "OpenCL"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "GPUModel"); printf("found OSDev model %s\n", value); count++; } } hwloc_topology_destroy(topology); return 0; }
int main(void) { hwloc_topology_t topology; hwloc_obj_t obj; hwloc_topology_init(&topology); hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_WHOLE_IO); assert(-1 == hwloc_topology_ignore_type(topology, HWLOC_OBJ_PCI_DEVICE)); assert(-1 == hwloc_topology_ignore_type_keep_structure(topology, HWLOC_OBJ_BRIDGE)); assert(-1 == hwloc_topology_ignore_type(topology, HWLOC_OBJ_OS_DEVICE)); hwloc_topology_load(topology); printf("Found %d bridges\n", hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_BRIDGE)); obj = NULL; while ((obj = hwloc_get_next_bridge(topology, obj)) != NULL) { assert(obj->type == HWLOC_OBJ_BRIDGE); /* only host->pci and pci->pci bridge supported so far */ if (obj->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_HOST) { assert(obj->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI); printf(" Found host->PCI bridge for domain %04x bus %02x-%02x\n", obj->attr->bridge.downstream.pci.domain, obj->attr->bridge.downstream.pci.secondary_bus, obj->attr->bridge.downstream.pci.subordinate_bus); } else { assert(obj->attr->bridge.upstream_type == HWLOC_OBJ_BRIDGE_PCI); assert(obj->attr->bridge.downstream_type == HWLOC_OBJ_BRIDGE_PCI); printf(" Found PCI->PCI bridge [%04x:%04x] for domain %04x bus %02x-%02x\n", obj->attr->bridge.upstream.pci.vendor_id, obj->attr->bridge.upstream.pci.device_id, obj->attr->bridge.downstream.pci.domain, obj->attr->bridge.downstream.pci.secondary_bus, obj->attr->bridge.downstream.pci.subordinate_bus); } } printf("Found %d PCI devices\n", hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_PCI_DEVICE)); obj = NULL; while ((obj = hwloc_get_next_pcidev(topology, obj)) != NULL) { assert(obj->type == HWLOC_OBJ_PCI_DEVICE); printf(" Found PCI device class %04x vendor %04x model %04x\n", obj->attr->pcidev.class_id, obj->attr->pcidev.vendor_id, obj->attr->pcidev.device_id); } printf("Found %d OS devices\n", hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_OS_DEVICE)); obj = NULL; while ((obj = hwloc_get_next_osdev(topology, obj)) != NULL) { assert(obj->type == HWLOC_OBJ_OS_DEVICE); printf(" Found OS device %s subtype %d\n", obj->name, obj->attr->osdev.type); } assert(HWLOC_TYPE_DEPTH_BRIDGE == hwloc_get_type_depth(topology, HWLOC_OBJ_BRIDGE)); assert(HWLOC_TYPE_DEPTH_PCI_DEVICE == hwloc_get_type_depth(topology, HWLOC_OBJ_PCI_DEVICE)); assert(HWLOC_TYPE_DEPTH_OS_DEVICE == hwloc_get_type_depth(topology, HWLOC_OBJ_OS_DEVICE)); assert(hwloc_compare_types(HWLOC_OBJ_BRIDGE, HWLOC_OBJ_PCI_DEVICE) < 0); assert(hwloc_compare_types(HWLOC_OBJ_BRIDGE, HWLOC_OBJ_OS_DEVICE) < 0); assert(hwloc_compare_types(HWLOC_OBJ_PCI_DEVICE, HWLOC_OBJ_OS_DEVICE) < 0); /* check that hwloc_get_hostbridge_by_pcibus() and hwloc_get_non_io_ancestor_obj work fine */ obj = NULL; while ((obj = hwloc_get_next_pcidev(topology, obj)) != NULL) { assert(hwloc_get_hostbridge_by_pcibus(topology, obj->attr->pcidev.domain, obj->attr->pcidev.bus)->parent == hwloc_get_non_io_ancestor_obj(topology, obj)); } hwloc_topology_destroy(topology); return 0; }
int main(void) { hwloc_topology_t topology; int i; int err; hwloc_topology_init(&topology); hwloc_topology_set_type_filter(topology, HWLOC_OBJ_PCI_DEVICE, HWLOC_TYPE_FILTER_KEEP_IMPORTANT); hwloc_topology_set_type_filter(topology, HWLOC_OBJ_OS_DEVICE, HWLOC_TYPE_FILTER_KEEP_IMPORTANT); hwloc_topology_load(topology); for(i=0; ; i++) { hwloc_bitmap_t set; hwloc_obj_t osdev, ancestor; const char *value; osdev = hwloc_intel_mic_get_device_osdev_by_index(topology, i); if (!osdev) break; assert(osdev); ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); printf("found OSDev %s\n", osdev->name); err = strncmp(osdev->name, "mic", 3); assert(!err); assert(atoi(osdev->name+3) == (int) i); assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC); value = hwloc_obj_get_info_by_name(osdev, "CoProcType"); err = strcmp(value, "MIC"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "MICFamily"); printf("found MICFamily %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICSKU"); printf("found MICSKU %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICActiveCores"); printf("found MICActiveCores %s\n", value); value = hwloc_obj_get_info_by_name(osdev, "MICMemorySize"); printf("found MICMemorySize %s\n", value); set = hwloc_bitmap_alloc(); err = hwloc_intel_mic_get_device_cpuset(topology, i, set); if (err < 0) { printf("failed to get cpuset for device %d\n", i); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for device %d\n", cpuset_string, i); if (hwloc_bitmap_isequal(hwloc_topology_get_complete_cpuset(topology), hwloc_topology_get_topology_cpuset(topology))) /* only compare if the topology is complete, otherwise things can be significantly different */ assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); free(cpuset_string); } hwloc_bitmap_free(set); } hwloc_topology_destroy(topology); return 0; }
int main(void) { hwloc_topology_t topology; CUresult cres; CUdevice device; int count, i; int err; cres = cuInit(0); if (cres != CUDA_SUCCESS) { printf("cuInit failed %d\n", cres); return 0; } cres = cuDeviceGetCount(&count); if (cres != CUDA_SUCCESS) { printf("cuDeviceGetCount failed %d\n", cres); return 0; } printf("cuDeviceGetCount found %d devices\n", count); hwloc_topology_init(&topology); hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); hwloc_topology_load(topology); for(i=0; i<count; i++) { hwloc_bitmap_t set; hwloc_obj_t osdev, osdev2, ancestor; const char *value; cres = cuDeviceGet(&device, i); if (cres != CUDA_SUCCESS) { printf("failed to get device %d\n", i); continue; } osdev = hwloc_cuda_get_device_osdev(topology, device); assert(osdev); osdev2 = hwloc_cuda_get_device_osdev_by_index(topology, i); assert(osdev == osdev2); ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); printf("found OSDev %s\n", osdev->name); err = strncmp(osdev->name, "cuda", 4); assert(!err); assert(atoi(osdev->name+4) == (int) i); value = hwloc_obj_get_info_by_name(osdev, "Backend"); err = strcmp(value, "CUDA"); assert(!err); assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC); value = hwloc_obj_get_info_by_name(osdev, "CoProcType"); err = strcmp(value, "CUDA"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "GPUModel"); printf("found OSDev model %s\n", value); set = hwloc_bitmap_alloc(); err = hwloc_cuda_get_device_cpuset(topology, device, set); if (err < 0) { printf("failed to get cpuset for device %d\n", i); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for device %d\n", cpuset_string, i); assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); free(cpuset_string); } hwloc_bitmap_free(set); } hwloc_topology_destroy(topology); return 0; }
int main(void) { hwloc_topology_t topology; cl_int clret; cl_platform_id *platform_ids; unsigned nrp, nrd, count, i, j; int err; hwloc_topology_init(&topology); hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); hwloc_topology_load(topology); clret = clGetPlatformIDs(0, NULL, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; platform_ids = malloc(nrp * sizeof(*platform_ids)); if (!platform_ids) return 0; clret = clGetPlatformIDs(nrp, platform_ids, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; count = 0; for(i=0; i<nrp; i++) { cl_device_id *device_ids; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, 0, NULL, &nrd); if (CL_SUCCESS != clret || !nrd) continue; device_ids = malloc(nrd * sizeof(*device_ids)); if (!device_ids) continue; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, nrd, device_ids, &nrd); if (CL_SUCCESS != clret || !nrd) continue; for(j=0; j<nrd; j++) { hwloc_bitmap_t set; hwloc_obj_t osdev, osdev2, ancestor; const char *value; unsigned p, d; osdev = hwloc_opencl_get_device_osdev(topology, device_ids[j]); osdev2 = hwloc_opencl_get_device_osdev_by_index(topology, i, j); assert(osdev == osdev2); if (!osdev) { printf("no osdev for platform %u device %u\n", i, j); continue; } ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); set = hwloc_bitmap_alloc(); err = hwloc_opencl_get_device_cpuset(topology, device_ids[j], set); if (err < 0) { printf("no cpuset for platform %u device %u\n", i, j); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for platform %u device %u\n", cpuset_string, i, j); free(cpuset_string); if (hwloc_bitmap_isequal(hwloc_topology_get_complete_cpuset(topology), hwloc_topology_get_topology_cpuset(topology))) /* only compare if the topology is complete, otherwise things can be significantly different */ assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); } hwloc_bitmap_free(set); printf("found OSDev %s\n", osdev->name); err = sscanf(osdev->name, "opencl%ud%u", &p, &d); assert(err == 2); assert(p == i); assert(d == j); value = hwloc_obj_get_info_by_name(osdev, "Backend"); err = strcmp(value, "OpenCL"); assert(!err); assert(osdev->attr->osdev.type == HWLOC_OBJ_OSDEV_COPROC); value = hwloc_obj_get_info_by_name(osdev, "CoProcType"); err = strcmp(value, "OpenCL"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "GPUModel"); printf("found OSDev model %s\n", value); count++; } } hwloc_topology_destroy(topology); return 0; }
int32_t Pipe::_getAutoAffinity() const { #ifdef EQ_USE_HWLOC_GL uint32_t port = getPort(); uint32_t device = getDevice(); if( port == LB_UNDEFINED_UINT32 && device == LB_UNDEFINED_UINT32 ) return lunchbox::Thread::NONE; if( port == LB_UNDEFINED_UINT32 ) port = 0; if( device == LB_UNDEFINED_UINT32 ) device = 0; hwloc_topology_t topology; hwloc_topology_init( &topology ); // Flags used for loading the I/O devices, bridges and their relevant info const unsigned long loading_flags = HWLOC_TOPOLOGY_FLAG_IO_BRIDGES | HWLOC_TOPOLOGY_FLAG_IO_DEVICES; // Set discovery flags if( hwloc_topology_set_flags( topology, loading_flags ) < 0 ) { LBINFO << "Automatic pipe thread placement failed: " << "hwloc_topology_set_flags() failed" << std::endl; hwloc_topology_destroy( topology ); return lunchbox::Thread::NONE; } if( hwloc_topology_load( topology ) < 0 ) { LBINFO << "Automatic pipe thread placement failed: " << "hwloc_topology_load() failed" << std::endl; hwloc_topology_destroy( topology ); return lunchbox::Thread::NONE; } const hwloc_obj_t osdev = hwloc_gl_get_display_osdev_by_port_device( topology, int( port ), int( device )); if( !osdev ) { LBINFO << "Automatic pipe thread placement failed: GPU not found" << std::endl; hwloc_topology_destroy( topology ); return lunchbox::Thread::NONE; } const hwloc_obj_t pcidev = osdev->parent; const hwloc_obj_t parent = hwloc_get_non_io_ancestor_obj( topology, pcidev ); const int numCpus = hwloc_get_nbobjs_inside_cpuset_by_type( topology, parent->cpuset, HWLOC_OBJ_SOCKET ); if( numCpus != 1 ) { LBINFO << "Automatic pipe thread placement failed: GPU attached to " << numCpus << " processors?" << std::endl; hwloc_topology_destroy( topology ); return lunchbox::Thread::NONE; } const hwloc_obj_t cpuObj = hwloc_get_obj_inside_cpuset_by_type( topology, parent->cpuset, HWLOC_OBJ_SOCKET, 0 ); if( cpuObj == 0 ) { LBINFO << "Automatic pipe thread placement failed: " << "hwloc_get_obj_inside_cpuset_by_type() failed" << std::endl; hwloc_topology_destroy( topology ); return lunchbox::Thread::NONE; } const int cpuIndex = cpuObj->logical_index; hwloc_topology_destroy( topology ); return cpuIndex + lunchbox::Thread::SOCKET; #else LBINFO << "Automatic thread placement not supported, no hwloc GL support" << std::endl; #endif return lunchbox::Thread::NONE; }
int main(void) { hwloc_topology_t topology; cl_int clret; cl_platform_id *platform_ids; unsigned nrp, nrd, count, i, j; int err; hwloc_topology_init(&topology); hwloc_topology_set_flags(topology, HWLOC_TOPOLOGY_FLAG_IO_DEVICES); hwloc_topology_load(topology); clret = clGetPlatformIDs(0, NULL, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; platform_ids = malloc(nrp * sizeof(*platform_ids)); if (!platform_ids) return 0; clret = clGetPlatformIDs(nrp, platform_ids, &nrp); if (CL_SUCCESS != clret || !nrp) return 0; count = 0; for(i=0; i<nrp; i++) { cl_device_id *device_ids; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, 0, NULL, &nrd); if (CL_SUCCESS != clret || !nrd) continue; device_ids = malloc(nrd * sizeof(*device_ids)); if (!device_ids) continue; clret = clGetDeviceIDs(platform_ids[i], CL_DEVICE_TYPE_ALL, nrd, device_ids, &nrd); if (CL_SUCCESS != clret || !nrd) continue; for(j=0; j<nrd; j++) { hwloc_bitmap_t set; hwloc_obj_t osdev, osdev2, ancestor; const char *value; osdev = hwloc_opencl_get_device_osdev(topology, device_ids[j]); osdev2 = hwloc_opencl_get_device_osdev_by_index(topology, i, j); assert(osdev == osdev2); if (!osdev) { printf("no osdev for platform %d device %d\n", i, j); continue; } ancestor = hwloc_get_non_io_ancestor_obj(topology, osdev); set = hwloc_bitmap_alloc(); err = hwloc_opencl_get_device_cpuset(topology, device_ids[j], set); if (err < 0) { printf("no cpuset for platform %d device %d\n", i, j); } else { char *cpuset_string = NULL; hwloc_bitmap_asprintf(&cpuset_string, set); printf("got cpuset %s for platform %d device %d\n", cpuset_string, i, j); free(cpuset_string); assert(hwloc_bitmap_isequal(set, ancestor->cpuset)); } hwloc_bitmap_free(set); printf("found OSDev %s\n", osdev->name); err = strncmp(osdev->name, "opencl", 6); assert(!err); assert(atoi(osdev->name+6) == (int) count); value = hwloc_obj_get_info_by_name(osdev, "Backend"); err = strcmp(value, "OpenCL"); assert(!err); value = hwloc_obj_get_info_by_name(osdev, "Name"); printf("found OSDev name %s\n", value); count++; } } hwloc_topology_destroy(topology); return 0; }