diff --git a/include/margo.h b/include/margo.h index f23f44c9cc8753dee629956219044176747da342..56aa9dd816a21868b817ba682f6c98c164b367d3 100644 --- a/include/margo.h +++ b/include/margo.h @@ -67,12 +67,43 @@ typedef ABT_eventual margo_request; * call margo_wait_for_finalize() after margo_init() to relinguish control to * Margo. */ -margo_instance_id margo_init( +#define margo_init(_addr_str, _mode, _use_progress_thread, _rpc_thread_count)\ + margo_init_opt(_addr_str, _mode, NULL, _use_progress_thread, _rpc_thread_count) + +/** + * Initializes margo library with custom Mercury options. + * @param [in] addr_str Mercury host address with port number + * @param [in] mode Mode to run Margo in: + * - MARGO_CLIENT_MODE + * - MARGO_SERVER_MODE + * @param [in] hg_init_info (Optional) Hg init info, passed directly + * to Mercury + * @param [in] use_progress_thread Boolean flag to use a dedicated thread for + * running Mercury's progress loop. If false, + * it will run in the caller's thread context. + * @param [in] rpc_thread_count Number of threads to use for running RPC + * calls. A value of 0 directs Margo to execute + * RPCs in the caller's thread context. + * Clients (i.e processes that will *not* + * service incoming RPCs) should use a value + * of 0. A value of -1 directs Margo to use + * the same execution context as that used + * for Mercury progress. + * @returns margo instance id on success, MARGO_INSTANCE_NULL upon error + * + * NOTE: Servers (processes expecting to service incoming RPC requests) must + * specify non-zero values for use_progress_thread and rpc_thread_count *or* + * call margo_wait_for_finalize() after margo_init() to relinguish control to + * Margo. + */ +margo_instance_id margo_init_opt( const char *addr_str, int mode, + const struct hg_init_info *hg_init_info, int use_progress_thread, int rpc_thread_count); + /** * Initializes margo library from given argobots and Mercury instances. * @param [in] progress_pool Argobots pool to drive communication diff --git a/src/margo.c b/src/margo.c index 24fe421b0068577c3ec689265035bbe905b1bae4..df035c1a4675fd0d0a560d9142f0cc0034ef8497 100644 --- a/src/margo.c +++ b/src/margo.c @@ -171,7 +171,7 @@ static hg_return_t margo_handle_cache_put(margo_instance_id mid, static hg_id_t margo_register_internal(margo_instance_id mid, hg_id_t id, hg_proc_cb_t in_proc_cb, hg_proc_cb_t out_proc_cb, hg_rpc_cb_t rpc_cb, ABT_pool pool); -margo_instance_id margo_init(const char *addr_str, int mode, +margo_instance_id margo_init_opt(const char *addr_str, int mode, const struct hg_init_info *hg_init_info, int use_progress_thread, int rpc_thread_count) { ABT_xstream progress_xstream = ABT_XSTREAM_NULL; @@ -268,7 +268,7 @@ margo_instance_id margo_init(const char *addr_str, int mode, rpc_pool = progress_pool; } - hg_class = HG_Init(addr_str, listen_flag); + hg_class = HG_Init_opt(addr_str, listen_flag, hg_init_info); if(!hg_class) goto err; hg_context = HG_Context_create(hg_class);