| 41 | | |
| 42 | | /* Setup the machine level */ |
| 43 | | /* get the System object */ |
| 44 | | obj_sys = hwloc_get_system_obj(topology); |
| 45 | | /* init Hydra structure */ |
| 46 | | HYDT_bind_info.machine.type = HYDT_TOPO_MACHINE; |
| 47 | | HYDT_bind_info.machine.os_index = -1; /* This is a set, not a single unit */ |
| 48 | | HYDT_bind_info.machine.parent = NULL; |
| 49 | | HYDT_bind_info.machine.num_children = hwloc_get_nbobjs_by_type(topology,HWLOC_OBJ_NODE); |
| 50 | | /* There is no real node, consider there is one */ |
| 51 | | if (!HYDT_bind_info.machine.num_children) |
| 52 | | HYDT_bind_info.machine.num_children = 1; |
| 53 | | HYDU_MALLOC(HYDT_bind_info.machine.children, struct HYDT_topo_obj *, |
| 54 | | sizeof(struct HYDT_topo_obj), status); |
| 55 | | HYDT_bind_info.machine.shared_memory_depth = NULL; |
| 56 | | |
| 57 | | /* Setup the nodes levels */ |
| 58 | | for(node = 0 ; node < HYDT_bind_info.machine.num_children ; node++) |
| 59 | | { |
| 60 | | node_ptr = &HYDT_bind_info.machine.children[node]; |
| 61 | | node_ptr->type = HYDT_TOPO_NODE; |
| 62 | | node_ptr->parent = &HYDT_bind_info.machine; |
| 63 | | obj_node = hwloc_get_obj_inside_cpuset_by_type(topology,obj_sys->cpuset,HWLOC_OBJ_NODE,node); |
| 65 | | if(!obj_node) |
| 66 | | obj_node = obj_sys; |
| 67 | | node_ptr->os_index = obj_node->os_index;; |
| 68 | | node_ptr->num_children = hwloc_get_nbobjs_inside_cpuset_by_type(topology,obj_node->cpuset,HWLOC_OBJ_SOCKET); |
| | 42 | /* Setup the machine level */ |
| | 43 | /* get the System object */ |
| | 44 | obj_sys = hwloc_get_system_obj(topology); |
| | 45 | /* init Hydra structure */ |
| | 46 | HYDT_bind_info.machine.type = HYDT_TOPO_MACHINE; |
| | 47 | HYDT_bind_info.machine.os_index = -1; /* This is a set, not a single unit */ |
| | 48 | HYDT_bind_info.machine.parent = NULL; |
| | 49 | HYDT_bind_info.machine.num_children = hwloc_get_nbobjs_by_type(topology, HWLOC_OBJ_NODE); |
| | 50 | /* There is no real node, consider there is one */ |
| | 51 | if (!HYDT_bind_info.machine.num_children) |
| | 52 | HYDT_bind_info.machine.num_children = 1; |
| | 53 | HYDU_MALLOC(HYDT_bind_info.machine.children, struct HYDT_topo_obj *, |
| | 54 | sizeof(struct HYDT_topo_obj), status); |
| | 55 | HYDT_bind_info.machine.shared_memory_depth = NULL; |
| 70 | | /* In case there is no socket! */ |
| 71 | | if(!node_ptr->num_children) |
| 72 | | node_ptr->num_children = 1; |
| 73 | | |
| 74 | | HYDU_MALLOC(node_ptr->children, struct HYDT_topo_obj *, |
| 75 | | sizeof(struct HYDT_topo_obj) * node_ptr->num_children, status); |
| 76 | | node_ptr->shared_memory_depth = NULL; |
| 77 | | |
| 78 | | /* Setup the socket level */ |
| 79 | | for (sock = 0; sock < node_ptr->num_children ; sock++) |
| 80 | | { |
| 81 | | sock_ptr = &node_ptr->children[sock]; |
| 82 | | sock_ptr->type = HYDT_TOPO_SOCKET; |
| 83 | | sock_ptr->parent = node_ptr; |
| 84 | | |
| 85 | | obj_sock = hwloc_get_obj_inside_cpuset_by_type(topology,obj_node->cpuset,HWLOC_OBJ_SOCKET,sock); |
| 86 | | if(!obj_sock) |
| 87 | | obj_sock = obj_node; |
| 88 | | |
| 89 | | sock_ptr->os_index = obj_sock->os_index; |
| 90 | | sock_ptr->num_children = hwloc_get_nbobjs_inside_cpuset_by_type(topology,obj_sock->cpuset,HWLOC_OBJ_CORE); |
| 91 | | |
| 92 | | /* In case there is no core! */ |
| 93 | | if(!sock_ptr->num_children) |
| 94 | | sock_ptr->num_children = 1; |
| | 57 | /* Setup the nodes levels */ |
| | 58 | for (node = 0; node < HYDT_bind_info.machine.num_children; node++) { |
| | 59 | node_ptr = &HYDT_bind_info.machine.children[node]; |
| | 60 | node_ptr->type = HYDT_TOPO_NODE; |
| | 61 | node_ptr->parent = &HYDT_bind_info.machine; |
| | 62 | obj_node = |
| | 63 | hwloc_get_obj_inside_cpuset_by_type(topology, obj_sys->cpuset, HWLOC_OBJ_NODE, |
| | 64 | node); |
| 96 | | HYDU_MALLOC(sock_ptr->children, struct HYDT_topo_obj *, |
| 97 | | sizeof(struct HYDT_topo_obj) * sock_ptr->num_children, status); |
| 98 | | sock_ptr->shared_memory_depth = NULL; |
| 99 | | |
| 100 | | /* setup the core level */ |
| 101 | | for (core = 0; core < sock_ptr->num_children; core++) |
| 102 | | { |
| 103 | | core_ptr = &sock_ptr->children[core]; |
| 104 | | core_ptr->type = HYDT_TOPO_CORE; |
| 105 | | core_ptr->parent = sock_ptr; |
| 106 | | |
| 107 | | obj_core = hwloc_get_obj_inside_cpuset_by_type(topology,obj_sock->cpuset,HWLOC_OBJ_CORE,core); |
| 108 | | if(!obj_core) |
| 109 | | obj_core = obj_sock; |
| 110 | | |
| 111 | | core_ptr->os_index = obj_core->os_index; |
| 112 | | core_ptr->num_children = hwloc_get_nbobjs_inside_cpuset_by_type(topology,obj_core->cpuset,HWLOC_OBJ_PROC); |
| 113 | | |
| 114 | | HYDU_MALLOC(core_ptr->children, struct HYDT_topo_obj *, |
| 115 | | sizeof(struct HYDT_topo_obj) * core_ptr->num_children, status); |
| 116 | | core_ptr->shared_memory_depth = NULL; |
| 117 | | |
| 118 | | /* setup the thread level */ |
| 119 | | for (thread = 0; thread < core_ptr->num_children; thread++) |
| 120 | | { |
| 121 | | obj_proc = hwloc_get_obj_inside_cpuset_by_type(topology,obj_core->cpuset,HWLOC_OBJ_PROC,thread); |
| 122 | | thread_ptr = &core_ptr->children[thread]; |
| 123 | | thread_ptr->type = HYDT_TOPO_THREAD; |
| 124 | | thread_ptr->os_index = obj_proc->os_index; |
| 125 | | thread_ptr->parent = core_ptr; |
| 126 | | thread_ptr->num_children = 0; |
| 127 | | thread_ptr->children = NULL; |
| 128 | | thread_ptr->shared_memory_depth = NULL; |
| 129 | | |
| 130 | | /* |
| 131 | | fprintf(stdout," thread id %i | Core id %i | Socket id %i | Node id %i \n", |
| 132 | | obj_proc->os_index,obj_core->os_index,obj_sock->os_index,obj_node->os_index); |
| 133 | | */ |
| 134 | | } |
| 135 | | |
| 136 | | } |
| 137 | | } |
| 138 | | } |
| 139 | | |
| 140 | | /* We have qualified for topology-aware binding support level */ |
| 141 | | *support_level = HYDT_BIND_TOPO; |
| | 66 | if (!obj_node) |
| | 67 | obj_node = obj_sys; |
| | 68 | node_ptr->os_index = obj_node->os_index;; |
| | 69 | node_ptr->num_children = |
| | 70 | hwloc_get_nbobjs_inside_cpuset_by_type(topology, obj_node->cpuset, |
| | 71 | HWLOC_OBJ_SOCKET); |
| 143 | | fn_exit: |
| 144 | | HYDU_FUNC_EXIT(); |
| 145 | | return status; |
| 146 | | |
| 147 | | fn_fail: |
| 148 | | goto fn_exit; |
| | 73 | /* In case there is no socket! */ |
| | 74 | if (!node_ptr->num_children) |
| | 75 | node_ptr->num_children = 1; |
| | 76 | |
| | 77 | HYDU_MALLOC(node_ptr->children, struct HYDT_topo_obj *, |
| | 78 | sizeof(struct HYDT_topo_obj) * node_ptr->num_children, status); |
| | 79 | node_ptr->shared_memory_depth = NULL; |
| | 80 | |
| | 81 | /* Setup the socket level */ |
| | 82 | for (sock = 0; sock < node_ptr->num_children; sock++) { |
| | 83 | sock_ptr = &node_ptr->children[sock]; |
| | 84 | sock_ptr->type = HYDT_TOPO_SOCKET; |
| | 85 | sock_ptr->parent = node_ptr; |
| | 86 | |
| | 87 | obj_sock = |
| | 88 | hwloc_get_obj_inside_cpuset_by_type(topology, obj_node->cpuset, |
| | 89 | HWLOC_OBJ_SOCKET, sock); |
| | 90 | if (!obj_sock) |
| | 91 | obj_sock = obj_node; |
| | 92 | |
| | 93 | sock_ptr->os_index = obj_sock->os_index; |
| | 94 | sock_ptr->num_children = |
| | 95 | hwloc_get_nbobjs_inside_cpuset_by_type(topology, obj_sock->cpuset, |
| | 96 | HWLOC_OBJ_CORE); |
| | 97 | |
| | 98 | /* In case there is no core! */ |
| | 99 | if (!sock_ptr->num_children) |
| | 100 | sock_ptr->num_children = 1; |
| | 101 | |
| | 102 | HYDU_MALLOC(sock_ptr->children, struct HYDT_topo_obj *, |
| | 103 | sizeof(struct HYDT_topo_obj) * sock_ptr->num_children, status); |
| | 104 | sock_ptr->shared_memory_depth = NULL; |
| | 105 | |
| | 106 | /* setup the core level */ |
| | 107 | for (core = 0; core < sock_ptr->num_children; core++) { |
| | 108 | core_ptr = &sock_ptr->children[core]; |
| | 109 | core_ptr->type = HYDT_TOPO_CORE; |
| | 110 | core_ptr->parent = sock_ptr; |
| | 111 | |
| | 112 | obj_core = |
| | 113 | hwloc_get_obj_inside_cpuset_by_type(topology, obj_sock->cpuset, |
| | 114 | HWLOC_OBJ_CORE, core); |
| | 115 | if (!obj_core) |
| | 116 | obj_core = obj_sock; |
| | 117 | |
| | 118 | core_ptr->os_index = obj_core->os_index; |
| | 119 | core_ptr->num_children = |
| | 120 | hwloc_get_nbobjs_inside_cpuset_by_type(topology, obj_core->cpuset, |
| | 121 | HWLOC_OBJ_PROC); |
| | 122 | |
| | 123 | HYDU_MALLOC(core_ptr->children, struct HYDT_topo_obj *, |
| | 124 | sizeof(struct HYDT_topo_obj) * core_ptr->num_children, status); |
| | 125 | core_ptr->shared_memory_depth = NULL; |
| | 126 | |
| | 127 | /* setup the thread level */ |
| | 128 | for (thread = 0; thread < core_ptr->num_children; thread++) { |
| | 129 | obj_proc = |
| | 130 | hwloc_get_obj_inside_cpuset_by_type(topology, obj_core->cpuset, |
| | 131 | HWLOC_OBJ_PROC, thread); |
| | 132 | thread_ptr = &core_ptr->children[thread]; |
| | 133 | thread_ptr->type = HYDT_TOPO_THREAD; |
| | 134 | thread_ptr->os_index = obj_proc->os_index; |
| | 135 | thread_ptr->parent = core_ptr; |
| | 136 | thread_ptr->num_children = 0; |
| | 137 | thread_ptr->children = NULL; |
| | 138 | thread_ptr->shared_memory_depth = NULL; |
| | 139 | |
| | 140 | /* |
| | 141 | * fprintf(stdout," thread id %i | Core id %i | Socket id %i | Node id %i \n", |
| | 142 | * obj_proc->os_index,obj_core->os_index,obj_sock->os_index,obj_node->os_index); |
| | 143 | */ |
| | 144 | } |
| | 145 | |
| | 146 | } |
| | 147 | } |
| | 148 | } |
| | 149 | |
| | 150 | /* We have qualified for topology-aware binding support level */ |
| | 151 | *support_level = HYDT_BIND_TOPO; |
| | 152 | |
| | 153 | fn_exit: |
| | 154 | HYDU_FUNC_EXIT(); |
| | 155 | return status; |
| | 156 | |
| | 157 | fn_fail: |
| | 158 | goto fn_exit; |