@@ -180,15 +180,16 @@ qvi_hwloc_obj_type_is_host_resource(
180
180
181
181
int
182
182
qvi_hwloc_bitmap_string (
183
+ hwloc_topology_t topo,
183
184
hwloc_const_bitmap_t bitmap,
184
185
qv_bind_string_format_t format,
185
186
char **result
186
187
) {
187
188
switch (format) {
188
189
case QV_BIND_STRING_AS_BITMAP:
189
- return qvi_hwloc_bitmap_asprintf (bitmap, result);
190
+ return qvi_hwloc_bitmap_asprintf (topo, bitmap, result);
190
191
case QV_BIND_STRING_AS_LIST:
191
- return qvi_hwloc_bitmap_list_asprintf (bitmap, result);
192
+ return qvi_hwloc_bitmap_list_asprintf (topo, bitmap, result);
192
193
default :
193
194
*result = nullptr ;
194
195
return QV_ERR_INVLD_ARG;
@@ -816,11 +817,11 @@ qvi_hwloc_emit_cpubind(
816
817
if (rc != QV_SUCCESS) return rc;
817
818
818
819
char *cpusets = nullptr ;
819
- rc = qvi_hwloc_bitmap_asprintf (cpuset, &cpusets);
820
+ rc = qvi_hwloc_bitmap_asprintf (hwl-> topo , cpuset, &cpusets);
820
821
if (rc != QV_SUCCESS) goto out;
821
822
822
823
qvi_log_info (
823
- " [pid={} tid={}] cpubind= {}" ,
824
+ " [pid={} tid={}] cpubind (physical)=[ {}" ,
824
825
getpid (), task_id, cpusets
825
826
);
826
827
out:
@@ -831,6 +832,7 @@ qvi_hwloc_emit_cpubind(
831
832
832
833
int
833
834
qvi_hwloc_bitmap_asprintf (
835
+ hwloc_topology_t topo,
834
836
hwloc_const_cpuset_t cpuset,
835
837
char **result
836
838
) {
@@ -840,12 +842,48 @@ qvi_hwloc_bitmap_asprintf(
840
842
qvi_log_error (" hwloc_bitmap_asprintf() failed" );
841
843
return QV_ERR_OOR;
842
844
}
845
+
846
+ if (topo) {
847
+ hwloc_obj_t obj_pu = nullptr ;
848
+
849
+ int num_pus = hwloc_get_nbobjs_inside_cpuset_by_type (topo, cpuset, HWLOC_OBJ_PU);
850
+ int num_pus_cp = num_pus;
851
+
852
+ int num_digits = 1 ;
853
+ while (num_pus_cp /= 10 ) num_digits++;
854
+
855
+ char head[] = " ] | (logical)=[" ;
856
+ int str_size = strlen (head)+num_pus*(num_digits+1 )+1 ;
857
+ char *str = (char *)calloc (str_size,sizeof (char ));
858
+
859
+ strcpy (str,head);
860
+
861
+ char *core_str = (char *)calloc (num_digits+2 ,sizeof (char ));
862
+ for (int idx = 0 ; idx < num_pus ; idx++){
863
+ obj_pu = hwloc_get_next_obj_inside_cpuset_by_type (topo, cpuset, HWLOC_OBJ_PU, obj_pu);
864
+ sprintf (core_str," %i%s" ,obj_pu->logical_index , idx == (num_pus-1 ) ? " ]" :" ," );
865
+ strncat (str,core_str,strlen (core_str));
866
+ memset (core_str,0 ,strlen (core_str));
867
+ }
868
+
869
+ char *newstr = (char *)calloc (strlen (str)+strlen (iresult)+1 ,sizeof (char ));
870
+ strcpy (newstr,iresult);
871
+ strcat (newstr,str);
872
+
873
+ free (core_str);
874
+ free (str);
875
+ free (iresult);
876
+
877
+ iresult = newstr;
878
+ }
879
+
843
880
*result = iresult;
844
881
return QV_SUCCESS;
845
882
}
846
883
847
884
int
848
885
qvi_hwloc_bitmap_list_asprintf (
886
+ hwloc_topology_t topo,
849
887
hwloc_const_cpuset_t cpuset,
850
888
char **result
851
889
) {
@@ -855,6 +893,41 @@ qvi_hwloc_bitmap_list_asprintf(
855
893
qvi_log_error (" hwloc_bitmap_list_asprintf() failed" );
856
894
return QV_ERR_OOR;
857
895
}
896
+
897
+ if (topo) {
898
+ hwloc_obj_t obj_pu = nullptr ;
899
+
900
+ int num_pus = hwloc_get_nbobjs_inside_cpuset_by_type (topo, cpuset, HWLOC_OBJ_PU);
901
+ int num_pus_cp = num_pus;
902
+
903
+ int num_digits = 1 ;
904
+ while (num_pus_cp /= 10 ) num_digits++;
905
+
906
+ char head[] = " ] | (logical)=[" ;
907
+ int str_size = strlen (head)+num_pus*(num_digits+1 )+1 ;
908
+ char *str = (char *)calloc (str_size,sizeof (char ));
909
+
910
+ strcpy (str,head);
911
+
912
+ char *core_str = (char *)calloc (num_digits+2 ,sizeof (char ));
913
+ for (int idx = 0 ; idx < num_pus ; idx++){
914
+ obj_pu = hwloc_get_next_obj_inside_cpuset_by_type (topo, cpuset, HWLOC_OBJ_PU, obj_pu);
915
+ sprintf (core_str," %i%s" ,obj_pu->logical_index , idx == (num_pus-1 ) ? " ]" :" ," );
916
+ strncat (str,core_str,strlen (core_str));
917
+ memset (core_str,0 ,strlen (core_str));
918
+ }
919
+
920
+ char *newstr = (char *)calloc (strlen (str)+strlen (iresult)+1 ,sizeof (char ));
921
+ strcpy (newstr,iresult);
922
+ strcat (newstr,str);
923
+
924
+ free (core_str);
925
+ free (str);
926
+ free (iresult);
927
+
928
+ iresult = newstr;
929
+ }
930
+
858
931
*result = iresult;
859
932
return QV_SUCCESS;
860
933
}
@@ -869,7 +942,7 @@ qvi_hwloc_cpuset_debug(
869
942
#endif
870
943
assert (cpuset);
871
944
char *cpusets = nullptr ;
872
- int rc = qvi_hwloc_bitmap_asprintf (cpuset, &cpusets);
945
+ int rc = qvi_hwloc_bitmap_asprintf (nullptr , cpuset, &cpusets);
873
946
if (rc != QV_SUCCESS) {
874
947
qvi_abort ();
875
948
}
@@ -957,7 +1030,7 @@ qvi_hwloc_task_get_cpubind_as_string(
957
1030
int rc = qvi_hwloc_task_get_cpubind (hwl, task_id, &cpuset);
958
1031
if (rc != QV_SUCCESS) return rc;
959
1032
960
- rc = qvi_hwloc_bitmap_asprintf (cpuset, cpusets);
1033
+ rc = qvi_hwloc_bitmap_asprintf (hwl-> topo , cpuset, cpusets);
961
1034
qvi_hwloc_bitmap_delete (&cpuset);
962
1035
return rc;
963
1036
}
@@ -1185,7 +1258,7 @@ qvi_hwloc_devices_emit(
1185
1258
}
1186
1259
for (auto &dev : *devlist) {
1187
1260
char *cpusets = nullptr ;
1188
- int rc = qvi_hwloc_bitmap_asprintf (dev->affinity .cdata (), &cpusets);
1261
+ int rc = qvi_hwloc_bitmap_asprintf (hwl-> topo , dev->affinity .cdata (), &cpusets);
1189
1262
if (rc != QV_SUCCESS) return rc;
1190
1263
1191
1264
qvi_log_info (" Device Name: {}" , dev->name );
0 commit comments