1515 * Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
1616 * Copyright (c) 2010-2011 Oak Ridge National Labs. All rights reserved.
1717 * Copyright (c) 2014-2017 Intel, Inc. All rights reserved.
18- * Copyright (c) 2016 Research Organization for Information Science
18+ * Copyright (c) 2016-2017 Research Organization for Information Science
1919 * and Technology (RIST). All rights reserved.
2020 * $COPYRIGHT$
2121 *
5959#include "orte/util/session_dir.h"
6060#include "orte/util/name_fns.h"
6161#include "orte/util/nidmap.h"
62+ #include "orte/util/compress.h"
6263
6364#include "orte/mca/errmgr/errmgr.h"
6465#include "orte/mca/grpcomm/base/base.h"
@@ -101,7 +102,7 @@ void orte_daemon_recv(int status, orte_process_name_t* sender,
101102 int32_t signal ;
102103 orte_jobid_t job ;
103104 char * contact_info ;
104- opal_buffer_t * answer ;
105+ opal_buffer_t data , * answer ;
105106 orte_job_t * jdata ;
106107 orte_process_name_t proc , proc2 ;
107108 orte_process_name_t * return_addr ;
@@ -124,6 +125,9 @@ void orte_daemon_recv(int status, orte_process_name_t* sender,
124125 char * rtmod ;
125126 char * coprocessors ;
126127 orte_job_map_t * map ;
128+ int8_t flag ;
129+ uint8_t * cmpdata ;
130+ size_t cmplen ;
127131
128132 /* unpack the command */
129133 n = 1 ;
@@ -620,36 +624,78 @@ void orte_daemon_recv(int status, orte_process_name_t* sender,
620624
621625 /**** REPORT TOPOLOGY COMMAND ****/
622626 case ORTE_DAEMON_REPORT_TOPOLOGY_CMD :
623- answer = OBJ_NEW ( opal_buffer_t );
627+ OBJ_CONSTRUCT ( & data , opal_buffer_t );
624628 /* pack the topology signature */
625- if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & orte_topo_signature , 1 , OPAL_STRING ))) {
629+ if (ORTE_SUCCESS != (ret = opal_dss .pack (& data , & orte_topo_signature , 1 , OPAL_STRING ))) {
626630 ORTE_ERROR_LOG (ret );
627- OBJ_RELEASE ( answer );
631+ OBJ_DESTRUCT ( & data );
628632 goto CLEANUP ;
629633 }
630634 /* pack the topology */
631- if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & opal_hwloc_topology , 1 , OPAL_HWLOC_TOPO ))) {
635+ if (ORTE_SUCCESS != (ret = opal_dss .pack (& data , & opal_hwloc_topology , 1 , OPAL_HWLOC_TOPO ))) {
632636 ORTE_ERROR_LOG (ret );
633- OBJ_RELEASE ( answer );
637+ OBJ_DESTRUCT ( & data );
634638 goto CLEANUP ;
635639 }
636640
637641 /* detect and add any coprocessors */
638642 coprocessors = opal_hwloc_base_find_coprocessors (opal_hwloc_topology );
639- if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & coprocessors , 1 , OPAL_STRING ))) {
643+ if (ORTE_SUCCESS != (ret = opal_dss .pack (& data , & coprocessors , 1 , OPAL_STRING ))) {
640644 ORTE_ERROR_LOG (ret );
641645 }
642646 if (NULL != coprocessors ) {
643647 free (coprocessors );
644648 }
645649 /* see if I am on a coprocessor */
646650 coprocessors = opal_hwloc_base_check_on_coprocessor ();
647- if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & coprocessors , 1 , OPAL_STRING ))) {
651+ if (ORTE_SUCCESS != (ret = opal_dss .pack (& data , & coprocessors , 1 , OPAL_STRING ))) {
648652 ORTE_ERROR_LOG (ret );
649653 }
650654 if (NULL != coprocessors ) {
651655 free (coprocessors );
652656 }
657+ answer = OBJ_NEW (opal_buffer_t );
658+ if (orte_util_compress_block ((uint8_t * )data .base_ptr , data .bytes_used ,
659+ & cmpdata , & cmplen )) {
660+ /* the data was compressed - mark that we compressed it */
661+ flag = 1 ;
662+ if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & flag , 1 , OPAL_INT8 ))) {
663+ ORTE_ERROR_LOG (ret );
664+ free (cmpdata );
665+ OBJ_DESTRUCT (& data );
666+ }
667+ /* pack the compressed length */
668+ if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & cmplen , 1 , OPAL_SIZE ))) {
669+ ORTE_ERROR_LOG (ret );
670+ free (cmpdata );
671+ OBJ_DESTRUCT (& data );
672+ }
673+ /* pack the uncompressed length */
674+ if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & data .bytes_used , 1 , OPAL_SIZE ))) {
675+ ORTE_ERROR_LOG (ret );
676+ free (cmpdata );
677+ OBJ_DESTRUCT (& data );
678+ }
679+ /* pack the compressed info */
680+ if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , cmpdata , cmplen , OPAL_UINT8 ))) {
681+ ORTE_ERROR_LOG (ret );
682+ free (cmpdata );
683+ OBJ_DESTRUCT (& data );
684+ }
685+ OBJ_DESTRUCT (& data );
686+ free (cmpdata );
687+ } else {
688+ /* mark that it was not compressed */
689+ flag = 0 ;
690+ if (ORTE_SUCCESS != (ret = opal_dss .pack (answer , & flag , 1 , OPAL_INT8 ))) {
691+ ORTE_ERROR_LOG (ret );
692+ OBJ_DESTRUCT (& data );
693+ free (cmpdata );
694+ }
695+ /* transfer the payload across */
696+ opal_dss .copy_payload (answer , & data );
697+ OBJ_DESTRUCT (& data );
698+ }
653699 /* send the data */
654700 if (0 > (ret = orte_rml .send_buffer_nb (orte_mgmt_conduit ,
655701 sender , answer , ORTE_RML_TAG_TOPOLOGY_REPORT ,
0 commit comments