@@ -349,6 +349,7 @@ int orte_util_decode_nidmap(opal_buffer_t *buf)
349
349
}
350
350
} else {
351
351
vp8 = (uint8_t * )boptr -> bytes ;
352
+ sz = boptr -> size ;
352
353
boptr -> bytes = NULL ;
353
354
boptr -> size = 0 ;
354
355
}
@@ -444,27 +445,17 @@ int orte_util_decode_nidmap(opal_buffer_t *buf)
444
445
return rc ;
445
446
}
446
447
447
- typedef struct {
448
- opal_list_item_t super ;
449
- orte_topology_t * t ;
450
- } orte_tptr_trk_t ;
451
- static OBJ_CLASS_INSTANCE (orte_tptr_trk_t ,
452
- opal_list_item_t ,
453
- NULL, NULL) ;
454
-
455
448
int orte_util_pass_node_info (opal_buffer_t * buffer )
456
449
{
457
450
uint16_t * slots = NULL , slot = UINT16_MAX ;
458
- uint8_t * flags = NULL , flag = UINT8_MAX , * topologies = NULL ;
451
+ uint8_t * flags = NULL , flag = UINT8_MAX ;
459
452
int8_t i8 , ntopos ;
460
453
int rc , n , nbitmap , nstart ;
461
454
bool compressed , unislots = true, uniflags = true, unitopos = true;
462
455
orte_node_t * nptr ;
463
456
opal_byte_object_t bo , * boptr ;
464
457
size_t sz , nslots ;
465
458
opal_buffer_t bucket ;
466
- orte_tptr_trk_t * trk ;
467
- opal_list_t topos ;
468
459
orte_topology_t * t ;
469
460
470
461
/* make room for the number of slots on each node */
@@ -493,15 +484,18 @@ int orte_util_pass_node_info(opal_buffer_t *buffer)
493
484
} else {
494
485
nstart = 0 ;
495
486
}
496
- OBJ_CONSTRUCT (& topos , opal_list_t );
497
487
OBJ_CONSTRUCT (& bucket , opal_buffer_t );
488
+ ntopos = 0 ;
498
489
for (n = nstart ; n < orte_node_topologies -> size ; n ++ ) {
499
490
if (NULL == (t = (orte_topology_t * )opal_pointer_array_get_item (orte_node_topologies , n ))) {
500
491
continue ;
501
492
}
502
- trk = OBJ_NEW (orte_tptr_trk_t );
503
- trk -> t = t ;
504
- opal_list_append (& topos , & trk -> super );
493
+ /* pack the index */
494
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (& bucket , & t -> index , 1 , OPAL_INT ))) {
495
+ ORTE_ERROR_LOG (rc );
496
+ OBJ_DESTRUCT (& bucket );
497
+ goto cleanup ;
498
+ }
505
499
/* pack this topology string */
506
500
if (ORTE_SUCCESS != (rc = opal_dss .pack (& bucket , & t -> sig , 1 , OPAL_STRING ))) {
507
501
ORTE_ERROR_LOG (rc );
@@ -514,36 +508,65 @@ int orte_util_pass_node_info(opal_buffer_t *buffer)
514
508
OBJ_DESTRUCT (& bucket );
515
509
goto cleanup ;
516
510
}
511
+ ++ ntopos ;
517
512
}
518
513
/* pack the number of topologies in allocation */
519
- ntopos = opal_list_get_size (& topos );
520
514
if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & ntopos , 1 , OPAL_INT8 ))) {
521
515
goto cleanup ;
522
516
}
523
517
if (1 < ntopos ) {
524
518
/* need to send them along */
525
- opal_dss .copy_payload (buffer , & bucket );
526
- /* allocate space to report them */
527
- ntopos = orte_node_pool -> size ;
528
- topologies = (uint8_t * )malloc (ntopos );
519
+ if (opal_compress .compress_block ((uint8_t * )bucket .base_ptr , bucket .bytes_used ,
520
+ & bo .bytes , & sz )) {
521
+ /* the data was compressed - mark that we compressed it */
522
+ compressed = true;
523
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & compressed , 1 , OPAL_BOOL ))) {
524
+ ORTE_ERROR_LOG (rc );
525
+ OBJ_DESTRUCT (& bucket );
526
+ goto cleanup ;
527
+ }
528
+ /* pack the uncompressed length */
529
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & bucket .bytes_used , 1 , OPAL_SIZE ))) {
530
+ ORTE_ERROR_LOG (rc );
531
+ OBJ_DESTRUCT (& bucket );
532
+ goto cleanup ;
533
+ }
534
+ bo .size = sz ;
535
+ } else {
536
+ /* mark that it was not compressed */
537
+ compressed = false;
538
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & compressed , 1 , OPAL_BOOL ))) {
539
+ ORTE_ERROR_LOG (rc );
540
+ OBJ_DESTRUCT (& bucket );
541
+ goto cleanup ;
542
+ }
543
+ opal_dss .unload (& bucket , (void * * )& bo .bytes , & bo .size );
544
+ }
529
545
unitopos = false;
546
+ /* pack the info */
547
+ boptr = & bo ;
548
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & boptr , 1 , OPAL_BYTE_OBJECT ))) {
549
+ ORTE_ERROR_LOG (rc );
550
+ OBJ_DESTRUCT (& bucket );
551
+ goto cleanup ;
552
+ }
553
+ OBJ_DESTRUCT (& bucket );
554
+ free (bo .bytes );
530
555
}
531
- OBJ_DESTRUCT (& bucket );
532
556
557
+ /* construct the per-node info */
558
+ OBJ_CONSTRUCT (& bucket , opal_buffer_t );
533
559
for (n = 0 ; n < orte_node_pool -> size ; n ++ ) {
534
560
if (NULL == (nptr = (orte_node_t * )opal_pointer_array_get_item (orte_node_pool , n ))) {
535
561
continue ;
536
562
}
537
- /* store the topology, if required */
563
+ /* track the topology, if required */
538
564
if (!unitopos ) {
539
- topologies [n ] = 0 ;
540
- if (0 == nstart || 0 < n ) {
541
- OPAL_LIST_FOREACH (trk , & topos , orte_tptr_trk_t ) {
542
- if (trk -> t == nptr -> topology ) {
543
- break ;
544
- }
545
- topologies [n ]++ ;
546
- }
565
+ i8 = nptr -> topology -> index ;
566
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (& bucket , & i8 , 1 , OPAL_INT8 ))) {
567
+ ORTE_ERROR_LOG (rc );
568
+ OBJ_DESTRUCT (& bucket );
569
+ goto cleanup ;
547
570
}
548
571
}
549
572
/* store the number of slots */
@@ -572,21 +595,19 @@ int orte_util_pass_node_info(opal_buffer_t *buffer)
572
595
573
596
/* deal with the topology assignments */
574
597
if (!unitopos ) {
575
- if (opal_compress .compress_block ((uint8_t * )topologies , ntopos ,
598
+ if (opal_compress .compress_block ((uint8_t * )bucket . base_ptr , bucket . bytes_used ,
576
599
(uint8_t * * )& bo .bytes , & sz )) {
577
600
/* mark that this was compressed */
578
- i8 = 1 ;
579
601
compressed = true;
580
602
bo .size = sz ;
581
603
} else {
582
604
/* mark that this was not compressed */
583
- i8 = 0 ;
584
605
compressed = false;
585
- bo .bytes = topologies ;
586
- bo .size = nbitmap ;
606
+ bo .bytes = bucket . base_ptr ;
607
+ bo .size = bucket . bytes_used ;
587
608
}
588
609
/* indicate compression */
589
- if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & i8 , 1 , OPAL_INT8 ))) {
610
+ if (ORTE_SUCCESS != (rc = opal_dss .pack (buffer , & compressed , 1 , OPAL_BOOL ))) {
590
611
if (compressed ) {
591
612
free (bo .bytes );
592
613
}
@@ -607,6 +628,7 @@ int orte_util_pass_node_info(opal_buffer_t *buffer)
607
628
free (bo .bytes );
608
629
}
609
630
}
631
+ OBJ_DESTRUCT (& bucket );
610
632
611
633
/* if we have uniform #slots, then just flag it - no
612
634
* need to pass anything */
@@ -713,16 +735,19 @@ int orte_util_pass_node_info(opal_buffer_t *buffer)
713
735
int orte_util_parse_node_info (opal_buffer_t * buf )
714
736
{
715
737
int8_t i8 ;
716
- int rc = ORTE_SUCCESS , cnt , n , m ;
738
+ bool compressed ;
739
+ int rc = ORTE_SUCCESS , cnt , n , m , index ;
717
740
orte_node_t * nptr ;
718
741
size_t sz ;
719
742
opal_byte_object_t * boptr ;
720
743
uint16_t * slots = NULL ;
721
744
uint8_t * flags = NULL ;
722
745
uint8_t * topologies = NULL ;
723
- orte_topology_t * t2 , * * tps = NULL ;
746
+ uint8_t * bytes = NULL ;
747
+ orte_topology_t * t2 ;
724
748
hwloc_topology_t topo ;
725
749
char * sig ;
750
+ opal_buffer_t bucket ;
726
751
727
752
/* check to see if we have uniform topologies */
728
753
cnt = 1 ;
@@ -733,43 +758,104 @@ int orte_util_parse_node_info(opal_buffer_t *buf)
733
758
/* we already defaulted to uniform topology, so only need to
734
759
* process this if it is non-uniform */
735
760
if (1 < i8 ) {
736
- /* create an array to cache these */
737
- tps = (orte_topology_t * * )malloc (sizeof (orte_topology_t * ));
761
+ /* unpack the compression flag */
762
+ cnt = 1 ;
763
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & compressed , & cnt , OPAL_BOOL ))) {
764
+ ORTE_ERROR_LOG (rc );
765
+ goto cleanup ;
766
+ }
767
+ if (compressed ) {
768
+ /* get the uncompressed size */
769
+ cnt = 1 ;
770
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & sz , & cnt , OPAL_SIZE ))) {
771
+ ORTE_ERROR_LOG (rc );
772
+ goto cleanup ;
773
+ }
774
+ }
775
+ /* unpack the topology object */
776
+ cnt = 1 ;
777
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & boptr , & cnt , OPAL_BYTE_OBJECT ))) {
778
+ ORTE_ERROR_LOG (rc );
779
+ goto cleanup ;
780
+ }
781
+
782
+ /* if compressed, decompress */
783
+ if (compressed ) {
784
+ if (!opal_compress .decompress_block ((uint8_t * * )& bytes , sz ,
785
+ boptr -> bytes , boptr -> size )) {
786
+ ORTE_ERROR_LOG (ORTE_ERROR );
787
+ if (NULL != boptr -> bytes ) {
788
+ free (boptr -> bytes );
789
+ }
790
+ free (boptr );
791
+ rc = ORTE_ERROR ;
792
+ goto cleanup ;
793
+ }
794
+ } else {
795
+ bytes = (uint8_t * )boptr -> bytes ;
796
+ sz = boptr -> size ;
797
+ boptr -> bytes = NULL ;
798
+ boptr -> size = 0 ;
799
+ }
800
+ if (NULL != boptr -> bytes ) {
801
+ free (boptr -> bytes );
802
+ }
803
+ /* setup to unpack */
804
+ OBJ_CONSTRUCT (& bucket , opal_buffer_t );
805
+ opal_dss .load (& bucket , bytes , sz );
806
+
738
807
for (n = 0 ; n < i8 ; n ++ ) {
808
+ /* unpack the index */
739
809
cnt = 1 ;
740
- if (ORTE_SUCCESS != (rc = opal_dss .unpack (buf , & sig , & cnt , OPAL_STRING ))) {
810
+ if (ORTE_SUCCESS != (rc = opal_dss .unpack (& bucket , & index , & cnt , OPAL_INT ))) {
741
811
ORTE_ERROR_LOG (rc );
742
812
goto cleanup ;
743
813
}
814
+ /* unpack the signature */
744
815
cnt = 1 ;
745
- if (ORTE_SUCCESS != (rc = opal_dss .unpack (buf , & topo , & cnt , OPAL_HWLOC_TOPO ))) {
816
+ if (ORTE_SUCCESS != (rc = opal_dss .unpack (& bucket , & sig , & cnt , OPAL_STRING ))) {
746
817
ORTE_ERROR_LOG (rc );
747
818
goto cleanup ;
748
819
}
749
- /* new topology - record it */
820
+ /* unpack the topology */
821
+ cnt = 1 ;
822
+ if (ORTE_SUCCESS != (rc = opal_dss .unpack (& bucket , & topo , & cnt , OPAL_HWLOC_TOPO ))) {
823
+ ORTE_ERROR_LOG (rc );
824
+ goto cleanup ;
825
+ }
826
+ /* record it */
750
827
t2 = OBJ_NEW (orte_topology_t );
828
+ t2 -> index = index ;
751
829
t2 -> sig = sig ;
752
830
t2 -> topo = topo ;
753
- opal_pointer_array_add (orte_node_topologies , t2 );
754
- /* keep a cached copy */
755
- tps [n ] = t2 ;
831
+ opal_pointer_array_set_item (orte_node_topologies , index , t2 );
756
832
}
833
+ OBJ_DESTRUCT (& bucket );
834
+
757
835
/* now get the array of assigned topologies */
758
- /* if compressed, get the uncompressed size */
836
+ /* unpack the compression flag */
759
837
cnt = 1 ;
760
- if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & sz , & cnt , OPAL_SIZE ))) {
838
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & compressed , & cnt , OPAL_BOOL ))) {
761
839
ORTE_ERROR_LOG (rc );
762
840
goto cleanup ;
763
841
}
842
+ if (compressed ) {
843
+ /* get the uncompressed size */
844
+ cnt = 1 ;
845
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & sz , & cnt , OPAL_SIZE ))) {
846
+ ORTE_ERROR_LOG (rc );
847
+ goto cleanup ;
848
+ }
849
+ }
764
850
/* unpack the topologies object */
765
851
cnt = 1 ;
766
852
if (OPAL_SUCCESS != (rc = opal_dss .unpack (buf , & boptr , & cnt , OPAL_BYTE_OBJECT ))) {
767
853
ORTE_ERROR_LOG (rc );
768
854
goto cleanup ;
769
855
}
770
856
/* if compressed, decompress */
771
- if (1 == i8 ) {
772
- if (!opal_compress .decompress_block ((uint8_t * * )& topologies , sz ,
857
+ if (compressed ) {
858
+ if (!opal_compress .decompress_block ((uint8_t * * )& bytes , sz ,
773
859
boptr -> bytes , boptr -> size )) {
774
860
ORTE_ERROR_LOG (ORTE_ERROR );
775
861
if (NULL != boptr -> bytes ) {
@@ -780,19 +866,27 @@ int orte_util_parse_node_info(opal_buffer_t *buf)
780
866
goto cleanup ;
781
867
}
782
868
} else {
783
- topologies = (uint8_t * )boptr -> bytes ;
869
+ bytes = (uint8_t * )boptr -> bytes ;
870
+ sz = boptr -> size ;
784
871
boptr -> bytes = NULL ;
785
872
boptr -> size = 0 ;
786
873
}
787
874
if (NULL != boptr -> bytes ) {
788
875
free (boptr -> bytes );
789
876
}
790
877
free (boptr );
878
+ OBJ_CONSTRUCT (& bucket , opal_buffer_t );
879
+ opal_dss .load (& bucket , bytes , sz );
791
880
/* cycle across the node pool and assign the values */
792
- for (n = 0 , m = 0 ; n < orte_node_pool -> size ; n ++ ) {
881
+ for (n = 0 ; n < orte_node_pool -> size ; n ++ ) {
793
882
if (NULL != (nptr = (orte_node_t * )opal_pointer_array_get_item (orte_node_pool , n ))) {
794
- nptr -> topology = tps [topologies [m ]];
795
- ++ m ;
883
+ /* unpack the next topology index */
884
+ cnt = 1 ;
885
+ if (OPAL_SUCCESS != (rc = opal_dss .unpack (& bucket , & i8 , & cnt , OPAL_INT8 ))) {
886
+ ORTE_ERROR_LOG (rc );
887
+ goto cleanup ;
888
+ }
889
+ nptr -> topology = opal_pointer_array_get_item (orte_node_topologies , index );
796
890
}
797
891
}
798
892
}
@@ -932,9 +1026,6 @@ int orte_util_parse_node_info(opal_buffer_t *buf)
932
1026
if (NULL != flags ) {
933
1027
free (flags );
934
1028
}
935
- if (NULL != tps ) {
936
- free (tps );
937
- }
938
1029
if (NULL != topologies ) {
939
1030
free (topologies );
940
1031
}
0 commit comments