Commit 16d0ce73 authored by Philip Carns's avatar Philip Carns
Browse files

Merge branch 'carns/dev-json-config' into 'master'

convert margo to json configuration

See merge request !32
parents 0e8ceee9 ecd93a5a
......@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([margo], [0.7], [],[],[])
AC_INIT([margo], [0.8], [],[],[])
AC_CONFIG_MACRO_DIR([m4])
LT_INIT
......@@ -76,7 +76,13 @@ LIBS="$ARGOBOTS_LIBS $LIBS"
CPPFLAGS="$ARGOBOTS_CFLAGS $CPPFLAGS"
CFLAGS="$ARGOBOTS_CFLAGS $CFLAGS"
PC_REQUIRES="mercury argobots"
PKG_CHECK_MODULES([MOCHICFG],[mochi-cfg],[],
[AC_MSG_ERROR([Could not find working mochi-cfg installation!])])
LIBS="$MOCHICFG_LIBS $LIBS"
CPPFLAGS="$MOCHICFG_CFLAGS $CPPFLAGS"
CFLAGS="$MOCHICFG_CFLAGS $CFLAGS"
PC_REQUIRES="mercury argobots jansson"
AC_SUBST([PC_REQUIRES], ["$PC_REQUIRES"])
# turn off a warning that is tripping up our use of utlist at the moment
......
......@@ -24,6 +24,7 @@ int main(int argc, char **argv)
hg_addr_t addr_self;
char addr_self_string[128];
hg_size_t addr_self_string_sz = 128;
char *cfg_str;
if(argc != 2)
{
......@@ -68,6 +69,10 @@ int main(int argc, char **argv)
MARGO_REGISTER(mid, "my_rpc", my_rpc_in_t, my_rpc_out_t, my_rpc_ult);
MARGO_REGISTER(mid, "my_shutdown_rpc", void, void, my_rpc_shutdown_ult);
cfg_str = margo_get_config(mid);
printf("%s\n", cfg_str);
free(cfg_str);
/* NOTE: there isn't anything else for the server to do at this point
* except wait for itself to be shut down. The
* margo_wait_for_finalize() call here yields to let Margo drive
......
......@@ -43,10 +43,6 @@ typedef void(*margo_finalize_callback_t)(void*);
#define MARGO_DEFAULT_PROVIDER_ID 0
#define MARGO_MAX_PROVIDER_ID ((1 << (8*__MARGO_PROVIDER_ID_SIZE))-1)
#define MARGO_PARAM_PROGRESS_TIMEOUT_UB 1
#define MARGO_PARAM_ENABLE_PROFILING 2
#define MARGO_PARAM_ENABLE_DIAGNOSTICS 3
/**
* Initializes margo library.
* @param [in] addr_str Mercury host address with port number
......@@ -74,6 +70,9 @@ typedef void(*margo_finalize_callback_t)(void*);
#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)
#define margo_init_json(_json_cfg_string)\
margo_init_opt_json(NULL, _json_cfg_string)
/**
* Initializes margo library with custom Mercury options.
* @param [in] addr_str Mercury host address with port number
......@@ -107,6 +106,10 @@ margo_instance_id margo_init_opt(
int use_progress_thread,
int rpc_thread_count);
/* same as above, but with configuration expressed via json */
margo_instance_id margo_init_opt_json(
const struct hg_init_info *hg_init_info,
const char* json_cfg_string);
/**
* Initializes margo library from given argobots and Mercury instances.
......@@ -130,6 +133,16 @@ margo_instance_id margo_init_pool(
ABT_pool handler_pool,
hg_context_t *hg_context);
/**
* same as margo_init_pool() except that it has an additional argument to
* accept a json configuration string
*/
margo_instance_id margo_init_pool_json(
ABT_pool progress_pool,
ABT_pool handler_pool,
hg_context_t *hg_context,
const char* json_cfg_string);
/**
* Shuts down margo library and its underlying abt and mercury resources
* @param [in] mid Margo instance
......@@ -1058,7 +1071,8 @@ margo_instance_id margo_hg_info_get_instance(const struct hg_info *info);
* @param [in] mid Margo instance
* @returns void
*/
void margo_diag_start(margo_instance_id mid);
#define margo_diag_start(__mid) \
margo_set_param(__mid, "enable_diagnostics", "1")
/**
* Enables profile data collection on specified Margo instance
......@@ -1066,7 +1080,8 @@ void margo_diag_start(margo_instance_id mid);
* @param [in] mid Margo instance
* @returns void
*/
void margo_profile_start(margo_instance_id mid);
#define margo_profile_start(__mid) \
margo_set_param(__mid, "enable_profiling", "1")
/**
* Disables diagnostic collection on specified Margo instance
......@@ -1074,7 +1089,8 @@ void margo_profile_start(margo_instance_id mid);
* @param [in] mid Margo instance
* @returns void
*/
void margo_diag_stop(margo_instance_id mid);
#define margo_diag_stop(__mid) \
margo_set_param(__mid, "enable_diagnostics", "0")
/**
* Disables profile data collection on specified Margo instance
......@@ -1082,7 +1098,8 @@ void margo_diag_stop(margo_instance_id mid);
* @param [in] mid Margo instance
* @returns void
*/
void margo_profile_stop(margo_instance_id mid);
#define margo_profile_stop(__mid) \
margo_set_param(__mid, "enable_profiling", "0")
/**
* Appends diagnostic statistics (enabled via margo_diag_start()) to specified
......@@ -1121,22 +1138,19 @@ void margo_breadcrumb_snapshot(margo_instance_id mid, struct margo_breadcrumb_sn
* Sets configurable parameters/hints
*
* @param [in] mid Margo instance
* @param [in] option numerical option number
* @param [out] inout_param used to pass in values
* @returns void
* @param [in] key parameter name
* @param [in] value parameter value
* @returns 0 on success, -1 on failure
*/
void margo_set_param(margo_instance_id mid, int option, const void *param);
int margo_set_param(margo_instance_id mid, const char *key, const char *value);
/**
* Retrieves configurable parameters/hints
* Retrieves complete configuration of margo instance, incoded as json
*
* @param [in] mid Margo instance
* @param [in] option numerical option number
* @param [out] param used to pass out values
* @returns void
* @returns null terminated string that must be free'd by caller
*/
void margo_get_param(margo_instance_id mid, int option, void *param);
char* margo_get_config(margo_instance_id mid);
/**
* @private
......
......@@ -88,7 +88,7 @@ struct margo_instance
int owns_progress_pool;
ABT_xstream *rpc_xstreams;
int num_handler_pool_threads;
unsigned int hg_progress_timeout_ub;
int hg_progress_timeout_ub;
uint16_t num_registered_rpcs; /* number of registered rpc's by all providers on this instance */
/* list of rpcs registered on this instance for debugging and profiling purposes */
......@@ -126,7 +126,7 @@ struct margo_instance
* which will serialize access.
*/
int diag_enabled;
unsigned int profile_enabled;
int profile_enabled;
uint64_t self_addr_hash;
double previous_sparkline_data_collection_time;
uint16_t sparkline_index;
......@@ -137,6 +137,8 @@ struct margo_instance
struct diag_data diag_bulk_create_elapsed;
struct diag_data *diag_rpc;
ABT_mutex diag_rpc_mutex;
json_t *component_cfg;
};
struct margo_request_struct {
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment