Commit ab8f75d1 authored by Marc Vef's avatar Marc Vef
Browse files

Adding margo patch to use multiple clients and using it in preload.

parent 8a787409
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
diff --git a/src/margo.c b/src/margo.c
index e5e2e2c..cef5357 100644
--- a/src/margo.c
+++ b/src/margo.c
@@ -144,15 +144,16 @@ margo_instance_id margo_init(const char *addr_str, int mode,
     struct margo_instance *mid = MARGO_INSTANCE_NULL;
 
     if(mode != MARGO_CLIENT_MODE && mode != MARGO_SERVER_MODE) goto err;
+    if (ABT_initialized() == ABT_ERR_UNINITIALIZED) {
+        ret = ABT_init(0, NULL); /* XXX: argc/argv not currently used by ABT ... */
+        if(ret != 0) goto err;
 
-    ret = ABT_init(0, NULL); /* XXX: argc/argv not currently used by ABT ... */
-    if(ret != 0) goto err;
-
-    /* set caller (self) ES to idle without polling */
+        /* set caller (self) ES to idle without polling */
 #ifdef HAVE_ABT_SNOOZER
-    ret = ABT_snoozer_xstream_self_set();
-    if(ret != 0) goto err;
+        ret = ABT_snoozer_xstream_self_set();
+        if(ret != 0) goto err;
 #endif
+    }
 
     if (use_progress_thread)
     {
+4 −4
Original line number Diff line number Diff line
@@ -530,7 +530,7 @@ bool init_ipc_client() {
    LD_LOG_DEBUG0(debug_fd, "Initializing Margo IPC client ...\n");

    // Start Margo (this will also initialize Argobots and Mercury internally)
    auto mid = margo_init(protocol_port.c_str(), MARGO_CLIENT_MODE, 1, -1);
    auto mid = margo_init(protocol_port.c_str(), MARGO_CLIENT_MODE, 0, 0);

    if (mid == MARGO_INSTANCE_NULL) {
        LD_LOG_DEBUG0(debug_fd, "[ERR]: margo_init failed to initialize the Margo IPC client\n");
@@ -568,7 +568,7 @@ bool init_rpc_client() {
    LD_LOG_DEBUG0(debug_fd, "Initializing Margo RPC client ...\n");

    // Start Margo (this will also initialize Argobots and Mercury internally)
    auto mid = margo_init(protocol_port.c_str(), MARGO_CLIENT_MODE, 1, -1);
    auto mid = margo_init(protocol_port.c_str(), MARGO_CLIENT_MODE, 0, 0);

    if (mid == MARGO_INSTANCE_NULL) {
        LD_LOG_DEBUG0(debug_fd, "[ERR]: margo_init failed to initialize the Margo RPC client\n");
@@ -680,7 +680,7 @@ void destroy_preload() {
    LD_LOG_DEBUG0(debug_fd, "Freeing Mercury daemon addr ...\n");
    HG_Addr_free(margo_get_class(margo_ipc_id_), daemon_svr_addr_);
    LD_LOG_DEBUG0(debug_fd, "Finalizing Margo IPC client ...\n");
    margo_finalize(margo_ipc_id_);
//    margo_finalize(margo_ipc_id_);

    LD_LOG_DEBUG0(debug_fd, "Freeing Mercury RPC addresses ...\n");
    // free all rpc addresses in LRU map and finalize margo rpc
@@ -689,7 +689,7 @@ void destroy_preload() {
    };
    rpc_address_cache_.cwalk(free_all_addr);
    LD_LOG_DEBUG0(debug_fd, "Finalizing Margo RPC client ...\n");
    margo_finalize(margo_rpc_id_);
//    margo_finalize(margo_rpc_id_);
    LD_LOG_DEBUG0(debug_fd, "Preload library shut down.\n");

    fclose(debug_fd);