Ejemplo n.º 1
0
static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
  const struct mg_request_info *ri = mg_get_request_info(conn);
  extern void luaL_openlibs(lua_State *);
  int i;

  luaL_openlibs(L);

  // Register "print" function which calls mg_write()
  lua_pushlightuserdata(L, conn);
  lua_pushcclosure(L, lsp_mg_print, 1);
  lua_setglobal(L, "print");

  // Register mg_read()
  lua_pushlightuserdata(L, conn);
  lua_pushcclosure(L, lsp_mg_read, 1);
  lua_setglobal(L, "read");

  // Export request_info
  lua_newtable(L);
  reg_string(L, "request_method", ri->request_method);
  reg_string(L, "uri", ri->uri);
  reg_string(L, "http_version", ri->http_version);
  reg_string(L, "query_string", ri->query_string);
  reg_int(L, "remote_ip", ri->remote_ip);
  reg_int(L, "remote_port", ri->remote_port);
  reg_int(L, "num_headers", ri->num_headers);
  lua_pushstring(L, "http_headers");
  lua_newtable(L);
  for (i = 0; i < ri->num_headers; i++) {
    reg_string(L, ri->http_headers[i].name, ri->http_headers[i].value);
  }
  lua_rawset(L, -3);
  lua_setglobal(L, "request_info");
}
Ejemplo n.º 2
0
static void prepare_lua_environment(struct mg_connection *conn, lua_State *L) {
  const struct mg_request_info *ri = &conn->request_info;
  extern void luaL_openlibs(lua_State *);
  int i;

  luaL_openlibs(L);
#ifdef USE_LUA_SQLITE3
  { extern int luaopen_lsqlite3(lua_State *); luaopen_lsqlite3(L); }
#endif

  luaL_newmetatable(L, LUASOCKET);
  lua_pushliteral(L, "__index");
  luaL_newlib(L, luasocket_methods);
  lua_rawset(L, -3);
  lua_pop(L, 1);
  lua_register(L, "connect", lsp_connect);

  if (conn == NULL) return;

  // Register mg module
  lua_newtable(L);

  reg_function(L, "read", lsp_read, conn);
  reg_function(L, "write", lsp_write, conn);
  reg_function(L, "cry", lsp_cry, conn);
  reg_function(L, "include", lsp_include, conn);
  reg_function(L, "redirect", lsp_redirect, conn);
  reg_string(L, "version", MONGOOSE_VERSION);

  // Export request_info
  lua_pushstring(L, "request_info");
  lua_newtable(L);
  reg_string(L, "request_method", ri->request_method);
  reg_string(L, "uri", ri->uri);
  reg_string(L, "http_version", ri->http_version);
  reg_string(L, "query_string", ri->query_string);
  reg_int(L, "remote_ip", ri->remote_ip);
  reg_int(L, "remote_port", ri->remote_port);
  reg_int(L, "num_headers", ri->num_headers);
  lua_pushstring(L, "http_headers");
  lua_newtable(L);
  for (i = 0; i < ri->num_headers; i++) {
    reg_string(L, ri->http_headers[i].name, ri->http_headers[i].value);
  }
  lua_rawset(L, -3);
  lua_rawset(L, -3);

  lua_setglobal(L, "mg");

  // Register default mg.onerror function
  luaL_dostring(L, "mg.onerror = function(e) mg.write('\\nLua error:\\n', "
                "debug.traceback(e, 1)) end");
}
Ejemplo n.º 3
0
static int hcoll_register(void)
{

    int ret, tmp;

    ret = OMPI_SUCCESS;

#define CHECK(expr) do {                    \
            tmp = (expr);                       \
            if (OMPI_SUCCESS != tmp) ret = tmp; \
         } while (0)



    CHECK(reg_int("priority",NULL,
                "Priority of the hcol coll component",
                           90,
                           &mca_coll_hcoll_component.hcoll_priority,
                           0));

    CHECK(reg_int("verbose", NULL,
                "Verbose level of the hcol coll component",
                           0,
                           &mca_coll_hcoll_component.hcoll_verbose,
                           0));

    CHECK(reg_int("enable",NULL,
                           "[1|0|] Enable/Disable HCOL",
                           1 /*enable by default*/,
                           &mca_coll_hcoll_component.hcoll_enable,
                           0));

    CHECK(reg_int("datatype_fallback",NULL,
                           "[1|0|] Enable/Disable user defined dattypes fallback",
                           1 /*enable by default*/,
                           &mca_coll_hcoll_component.hcoll_datatype_fallback,
                           0));

    CHECK(reg_string("library_path", NULL,
                           "HCOL /path/to/libhcol.so",
                           ""COLL_HCOLL_HOME"/libhcol.so",
                           &mca_coll_hcoll_component.hcoll_lib_path,
                           0));

    return ret;
}
Ejemplo n.º 4
0
static void prepare_lua_environment(struct mg_connection *ri, lua_State *L) {
	extern void luaL_openlibs(lua_State *);
	int i;

	luaL_openlibs(L);

	if (ri == NULL) return;

	// Register mg module
	lua_newtable(L);
	reg_function(L, "write", lua_write, ri);
	reg_function(L, "header", lua_header, ri);

	// Export request_info
	lua_pushstring(L, "request_info");
	lua_newtable(L);
	reg_string(L, "request_method", ri->request_method);
	reg_string(L, "uri", ri->uri);
	reg_string(L, "http_version", ri->http_version);
	reg_string(L, "query_string", ri->query_string);
	reg_string(L, "remote_ip", ri->remote_ip);
	reg_int(L, "remote_port", ri->remote_port);
	reg_string(L, "local_ip", ri->local_ip);
	reg_int(L, "local_port", ri->local_port);
	lua_pushstring(L, "content");
	lua_pushlstring(L, ri->content == NULL ? "" : ri->content, ri->content_len);
	lua_rawset(L, -3);
	reg_int(L, "num_headers", ri->num_headers);
	lua_pushstring(L, "http_headers");
	lua_newtable(L);
	for (i = 0; i < ri->num_headers; i++) {
	reg_string(L, ri->http_headers[i].name, ri->http_headers[i].value);
	}
	lua_rawset(L, -3);
	lua_rawset(L, -3);

	lua_setglobal(L, "mg");

}
Ejemplo n.º 5
0
static int lsp_connect(lua_State *L) {
  char ebuf[100];
  SOCKET sock;

  if (lua_isstring(L, -3) && lua_isnumber(L, -2) && lua_isnumber(L, -1)) {
    sock = conn2(lua_tostring(L, -3), (int) lua_tonumber(L, -2),
                 (int) lua_tonumber(L, -1), ebuf, sizeof(ebuf));
    if (sock == INVALID_SOCKET) {
      return luaL_error(L, ebuf);
    } else {
      lua_newtable(L);
      reg_int(L, "sock", sock);
      reg_string(L, "host", lua_tostring(L, -4));
      luaL_getmetatable(L, LUASOCKET);
      lua_setmetatable(L, -2);
    }
  } else {
    return luaL_error(L, "connect(host,port,is_ssl): invalid parameter given.");
  }
  return 1;
}
Ejemplo n.º 6
0
int opal_btl_usnic_component_register(void)
{
    int tmp, ret = 0;
    static int max_modules;
    static int stats_relative;
    static int want_numa_device_assignment;
    static int sd_num;
    static int rd_num;
    static int prio_sd_num;
    static int prio_rd_num;
    static int cq_num;
    static int av_eq_num;
    static int udp_port_base;
    static int max_tiny_msg_size;
    static int eager_limit;
    static int rndv_eager_limit;
    static int pack_lazy_threshold;
    static int max_short_packets;

#define CHECK(expr) do {\
        tmp = (expr); \
        if (OPAL_SUCCESS != tmp) ret = tmp; \
     } while (0)

    CHECK(reg_int("max_btls",
                  "Maximum number of usNICs to use (default: 0 = as many as are available)",
                  0, &max_modules,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_2));
    mca_btl_usnic_component.max_modules = (size_t) max_modules;

    CHECK(reg_string("if_include",
                     "Comma-delimited list of usNIC devices/networks to be used (e.g. \"eth3,usnic_0,10.10.0.0/16\"; empty value means to use all available usNICs).  Mutually exclusive with btl_usnic_if_exclude.",
                     NULL, &mca_btl_usnic_component.if_include,
                     REGSTR_EMPTY_OK, OPAL_INFO_LVL_1));

    CHECK(reg_string("if_exclude",
                     "Comma-delimited list of usNIC devices/networks to be excluded (empty value means to not exclude any usNICs).  Mutually exclusive with btl_usnic_if_include.",
                     NULL, &mca_btl_usnic_component.if_exclude,
                     REGSTR_EMPTY_OK, OPAL_INFO_LVL_1));

    CHECK(reg_int("stats",
                  "A non-negative integer specifying the frequency at which each usnic BTL will output statistics (default: 0 seconds, meaning that statistics are disabled)",
                  0, &mca_btl_usnic_component.stats_frequency, 0,
                  OPAL_INFO_LVL_4));
    mca_btl_usnic_component.stats_enabled =
        (bool) (mca_btl_usnic_component.stats_frequency > 0);

    CHECK(reg_int("stats_relative",
                  "If stats are enabled, output relative stats between the timestamps (vs. cumulative stats since the beginning of the job) (default: 0 -- i.e., absolute)",
                  0, &stats_relative, 0, OPAL_INFO_LVL_4));
    mca_btl_usnic_component.stats_relative = (bool) stats_relative;

#if RCACHE_VERSION == 30
    CHECK(reg_string("mpool_hints", "Hints to use when selecting mpool",
                     NULL, &mca_btl_usnic_component.usnic_mpool_hints,
                     REGSTR_EMPTY_OK,
                     OPAL_INFO_LVL_5));

    CHECK(reg_string("rcache", "Name of the registration cache to be used",
                     "grdma", &mca_btl_usnic_component.usnic_rcache_name, 0,
                     OPAL_INFO_LVL_5));
#else
    CHECK(reg_string("mpool", "Name of the memory pool to be used",
                     "grdma", &mca_btl_usnic_component.usnic_mpool_name, 0,
                     OPAL_INFO_LVL_5));
#endif

    want_numa_device_assignment = OPAL_HAVE_HWLOC ? 1 : -1;
    CHECK(reg_int("want_numa_device_assignment",
                  "If 1, use only Cisco VIC ports thare are a minimum NUMA distance from the MPI process for short messages.  If 0, use all available Cisco VIC ports for short messages.  This parameter is meaningless (and ignored) unless MPI proceses are bound to processor cores.  Defaults to 1 if NUMA support is included in Open MPI; -1 otherwise.",
                  want_numa_device_assignment,
                  &want_numa_device_assignment,
                  0, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.want_numa_device_assignment =
        (1 == want_numa_device_assignment) ? true : false;

    CHECK(reg_int("sd_num", "Maximum send descriptors to post (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &sd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.sd_num = (int32_t) sd_num;

    CHECK(reg_int("rd_num", "Number of pre-posted receive buffers (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &rd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.rd_num = (int32_t) rd_num;

    CHECK(reg_int("prio_sd_num", "Maximum priority send descriptors to post (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &prio_sd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.prio_sd_num = (int32_t) prio_sd_num;

    CHECK(reg_int("prio_rd_num", "Number of pre-posted priority receive buffers (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &prio_rd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.prio_rd_num = (int32_t) prio_rd_num;

    CHECK(reg_int("cq_num", "Number of completion queue entries (-1 = pre-set defaults; depends on number and type of devices available; will error if (sd_num+rd_num)>cq_num)",
                  -1, &cq_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.cq_num = (int32_t) cq_num;

    CHECK(reg_int("av_eq_num", "Number of event queue entries for peer address resolution",
                  1024, &av_eq_num, REGINT_GE_ONE, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.av_eq_num = (int32_t) av_eq_num;

    CHECK(reg_int("base_udp_port", "Base UDP port to use for usNIC communications.  If 0, system will pick the port number.  If non-zero, it will be added to each process' local rank to obtain the final port number (default: 0)",
                  0, &udp_port_base, REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.udp_port_base = (int) udp_port_base;

    CHECK(reg_int("retrans_timeout", "Number of microseconds before retransmitting a frame",
                  5000, &mca_btl_usnic_component.retrans_timeout,
                  REGINT_GE_ONE, OPAL_INFO_LVL_5));

    CHECK(reg_int("priority_limit", "Max size of \"priority\" messages (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &max_tiny_msg_size,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    opal_btl_usnic_module_template.max_tiny_msg_size =
        (size_t) max_tiny_msg_size;

    CHECK(reg_int("eager_limit", "Eager send limit (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &eager_limit, REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    opal_btl_usnic_module_template.super.btl_eager_limit = eager_limit;

    CHECK(reg_int("rndv_eager_limit", "Eager rendezvous limit (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &rndv_eager_limit, REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    opal_btl_usnic_module_template.super.btl_rndv_eager_limit =
        rndv_eager_limit;

    CHECK(reg_int("pack_lazy_threshold", "Convertor packing on-the-fly threshold (-1 = always pack eagerly, 0 = always pack lazily, otherwise will pack on the fly if fragment size is > limit)",
                  USNIC_DFLT_PACK_LAZY_THRESHOLD, &pack_lazy_threshold, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.pack_lazy_threshold = pack_lazy_threshold;

    CHECK(reg_int("max_short_packets", "Number of abnormally-short packets received before outputting a warning (0 = never show the warning)",
                  25, &max_short_packets,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.max_short_packets = max_short_packets;

    /* Default to bandwidth auto-detection */
    opal_btl_usnic_module_template.super.btl_bandwidth = 0;
    opal_btl_usnic_module_template.super.btl_latency = 2;

    /* Show "cannot find route" warnings? */
    mca_btl_usnic_component.show_route_failures = true;
    CHECK(reg_bool("show_route_failures",
                   "Whether to show a warning when route failures between MPI process peers are detected (default = 1, enabled; 0 = disabled)",
                   mca_btl_usnic_component.show_route_failures,
                   &mca_btl_usnic_component.show_route_failures,
                   OPAL_INFO_LVL_3));

    /* Connectivity verification */
    mca_btl_usnic_component.connectivity_enabled = true;
    CHECK(reg_bool("connectivity_check",
                   "Whether to enable the usNIC connectivity check upon first send (default = 1, enabled; 0 = disabled)",
                   mca_btl_usnic_component.connectivity_enabled,
                   &mca_btl_usnic_component.connectivity_enabled,
                   OPAL_INFO_LVL_3));

    mca_btl_usnic_component.connectivity_ack_timeout = 250;
    CHECK(reg_int("connectivity_ack_timeout",
                  "Timeout, in milliseconds, while waiting for an ACK while verification connectivity between usNIC interfaces.  If 0, the connectivity check is disabled (must be >=0).",
                  mca_btl_usnic_component.connectivity_ack_timeout,
                  &mca_btl_usnic_component.connectivity_ack_timeout,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_3));

    mca_btl_usnic_component.connectivity_num_retries = 40;
    CHECK(reg_int("connectivity_error_num_retries",
                  "Number of times to retry usNIC connectivity verification before aborting the MPI job (must be >0).",
                  mca_btl_usnic_component.connectivity_num_retries,
                  &mca_btl_usnic_component.connectivity_num_retries,
                  REGINT_GE_ONE, OPAL_INFO_LVL_3));

    mca_btl_usnic_component.connectivity_map_prefix = NULL;
    CHECK(reg_string("connectivity_map",
                     "Write a per-process file containing the usNIC connectivity map.  If this parameter is specified, it is the filename prefix emitted by each MPI process.  The full filename emitted by each process is of the form: <prefix>-<hostname>.<pid>.<jobid>.<MCW rank>.txt.",
                     mca_btl_usnic_component.connectivity_map_prefix,
                     &mca_btl_usnic_component.connectivity_map_prefix,
                     REGSTR_EMPTY_OK, OPAL_INFO_LVL_3));

    return ret;
}
Ejemplo n.º 7
0
int ompi_btl_usnic_component_register(void)
{
    int i, tmp, ret = 0;
    char *str, **parts;
    static int max_modules;
    static int stats_relative;
    static int want_numa_device_assignment;
    static int sd_num;
    static int rd_num;
    static int prio_sd_num;
    static int prio_rd_num;
    static int cq_num;
    static int max_tiny_payload;
    static int eager_limit;
    static int rndv_eager_limit;
    static int pack_lazy_threshold;
    static char *vendor_part_ids;

#define CHECK(expr) do {\
        tmp = (expr); \
        if (OMPI_SUCCESS != tmp) ret = tmp; \
     } while (0)

    CHECK(reg_int("max_btls",
                  "Maximum number of usNICs to use (default: 0 = as many as are available)",
                  0, &max_modules,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_2));
    mca_btl_usnic_component.max_modules = (size_t) max_modules;

    CHECK(reg_string("if_include",
                     "Comma-delimited list of devices/networks to be used (e.g. \"usnic_0,10.10.0.0/16\"; empty value means to use all available usNICs).  Mutually exclusive with btl_usnic_if_exclude.",
                     NULL, &mca_btl_usnic_component.if_include, 
                     REGSTR_EMPTY_OK, OPAL_INFO_LVL_1));
    
    CHECK(reg_string("if_exclude",
                     "Comma-delimited list of devices/networks to be excluded (empty value means to not exclude any usNICs).  Mutually exclusive with btl_usnic_if_include.",
                     NULL, &mca_btl_usnic_component.if_exclude,
                     REGSTR_EMPTY_OK, OPAL_INFO_LVL_1));

    /* Cisco Sereno-based VICs are part ID 207 */
    vendor_part_ids = NULL;
    CHECK(reg_string("vendor_part_ids",
                     "Comma-delimited list verbs vendor part IDs to search for/use",
                     "207", &vendor_part_ids, 0, OPAL_INFO_LVL_5));
    parts = opal_argv_split(vendor_part_ids, ',');
    mca_btl_usnic_component.vendor_part_ids = 
        calloc(sizeof(uint32_t), opal_argv_count(parts) + 1);
    if (NULL == mca_btl_usnic_component.vendor_part_ids) {
        return OPAL_ERR_OUT_OF_RESOURCE;
    }
    for (i = 0, str = parts[0]; NULL != str; str = parts[++i]) {
        mca_btl_usnic_component.vendor_part_ids[i] = (uint32_t) atoi(str);
    }
    opal_argv_free(parts);

    CHECK(reg_int("stats",
                  "A non-negative integer specifying the frequency at which each USNIC BTL will output statistics (default: 0 seconds, meaning that statistics are disabled)",
                  0, &mca_btl_usnic_component.stats_frequency, 0,
                  OPAL_INFO_LVL_4));
    mca_btl_usnic_component.stats_enabled = 
        (bool) (mca_btl_usnic_component.stats_frequency > 0);

    CHECK(reg_int("stats_relative",
                  "If stats are enabled, output relative stats between the timestemps (vs. cumulative stats since the beginning of the job) (default: 0 -- i.e., absolute)",
                  0, &stats_relative, 0, OPAL_INFO_LVL_4));
    mca_btl_usnic_component.stats_relative = (bool) stats_relative;

    CHECK(reg_string("mpool", "Name of the memory pool to be used",
                     "grdma", &mca_btl_usnic_component.usnic_mpool_name, 0,
                     OPAL_INFO_LVL_5));

    want_numa_device_assignment = OPAL_HAVE_HWLOC ? 1 : -1;
    CHECK(reg_int("want_numa_device_assignment",
                  "If 1, use only Cisco VIC ports thare are a minimum NUMA distance from the MPI process for short messages.  If 0, use all available Cisco VIC ports for short messages.  This parameter is meaningless (and ignored) unless MPI proceses are bound to processor cores.  Defaults to 1 if NUMA support is included in Open MPI; -1 otherwise.",
                  want_numa_device_assignment,
                  &want_numa_device_assignment,
                  0, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.want_numa_device_assignment =
        (1 == want_numa_device_assignment) ? true : false;

    CHECK(reg_int("sd_num", "Maximum send descriptors to post (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &sd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.sd_num = (int32_t) sd_num;

    CHECK(reg_int("rd_num", "Number of pre-posted receive buffers (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &rd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.rd_num = (int32_t) rd_num;

    CHECK(reg_int("prio_sd_num", "Maximum priority send descriptors to post (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &prio_sd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.prio_sd_num = (int32_t) prio_sd_num;

    CHECK(reg_int("prio_rd_num", "Number of pre-posted priority receive buffers (-1 = pre-set defaults; depends on number and type of devices available)",
                  -1, &prio_rd_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.prio_rd_num = (int32_t) prio_rd_num;

    CHECK(reg_int("cq_num", "Number of completion queue entries (-1 = pre-set defaults; depends on number and type of devices available; will error if (sd_num+rd_num)>cq_num)",
                  -1, &cq_num, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.cq_num = (int32_t) cq_num;

    CHECK(reg_int("retrans_timeout", "Number of microseconds before retransmitting a frame",
                  1000, &mca_btl_usnic_component.retrans_timeout,
                  REGINT_GE_ONE, OPAL_INFO_LVL_5));

    CHECK(reg_int("priority_limit", "Max size of \"priority\" messages (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &max_tiny_payload,
                  REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    ompi_btl_usnic_module_template.max_tiny_payload = 
        (size_t) max_tiny_payload;

    CHECK(reg_int("eager_limit", "Eager send limit (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &eager_limit, REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    ompi_btl_usnic_module_template.super.btl_eager_limit = eager_limit;

    CHECK(reg_int("rndv_eager_limit", "Eager rendezvous limit (0 = use pre-set defaults; depends on number and type of devices available)",
                  0, &rndv_eager_limit, REGINT_GE_ZERO, OPAL_INFO_LVL_5));
    ompi_btl_usnic_module_template.super.btl_rndv_eager_limit = 
        rndv_eager_limit;

    CHECK(reg_int("pack_lazy_threshold", "Convertor packing on-the-fly threshold (-1 = always pack eagerly, 0 = always pack lazily, otherwise will pack on the fly if fragment size is > limit)",
                  USNIC_DFLT_PACK_LAZY_THRESHOLD, &pack_lazy_threshold, REGINT_NEG_ONE_OK, OPAL_INFO_LVL_5));
    mca_btl_usnic_component.pack_lazy_threshold = pack_lazy_threshold;

    /* Default to bandwidth auto-detection */
    ompi_btl_usnic_module_template.super.btl_bandwidth = 0;
    ompi_btl_usnic_module_template.super.btl_latency = 4;

    /* Register some synonyms to the ompi common verbs component */
    ompi_common_verbs_mca_register(&mca_btl_usnic_component.super.btl_version);

    return ret;
}
Ejemplo n.º 8
0
/*
 * Register and check all MCA parameters
 */
int btl_openib_register_mca_params(void)
{
    char default_qps[100];
    uint32_t mid_qp_size;
    int i;
    char *msg, *str, *pkey;
    int ival, ival2, ret, tmp;

    ret = OMPI_SUCCESS;
#define CHECK(expr) do {\
        tmp = (expr); \
        if (OMPI_SUCCESS != tmp) ret = tmp; \
     } while (0)

    /* register openib component parameters */
    CHECK(reg_int("verbose", NULL,
                  "Output some verbose OpenIB BTL information "
                  "(0 = no output, nonzero = output)", 0, &ival, 0));
    mca_btl_openib_component.verbose = (0 != ival);

    CHECK(reg_int("warn_no_device_params_found",
                  "warn_no_hca_params_found",
                  "Warn when no device-specific parameters are found in the INI file specified by the btl_openib_device_param_files MCA parameter (0 = do not warn; any other value = warn)",
                  1, &ival, 0));
    mca_btl_openib_component.warn_no_device_params_found = (0 != ival);
    CHECK(reg_int("warn_default_gid_prefix", NULL,
                  "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)",
                  1, &ival, 0));
    mca_btl_openib_component.warn_default_gid_prefix = (0 != ival);
    CHECK(reg_int("warn_nonexistent_if", NULL,
                  "Warn if non-existent devices and/or ports are specified in the btl_openib_if_[in|ex]clude MCA parameters (0 = do not warn; any other value = warn)",
                  1, &ival, 0));
    mca_btl_openib_component.warn_nonexistent_if = (0 != ival);

    if (OMPI_HAVE_IBV_FORK_INIT) {
        ival2 = -1;
    } else {
        ival2 = 0;
    }
    CHECK(reg_int("want_fork_support", NULL,
                  "Whether fork support is desired or not "
                  "(negative = try to enable fork support, but continue even if it is not available, 0 = do not enable fork support, positive = try to enable fork support and fail if it is not available)",
                  ival2, &ival, 0));
#ifdef HAVE_IBV_FORK_INIT
    mca_btl_openib_component.want_fork_support = ival;
#else
    if (0 != ival) {
        orte_show_help("help-mpi-btl-openib.txt",
                       "ibv_fork requested but not supported", true,
                       orte_process_info.nodename);
        return OMPI_ERROR;
    }
#endif

    asprintf(&str, "%s/mca-btl-openib-device-params.ini",
             opal_install_dirs.pkgdatadir);
    if (NULL == str) {
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    CHECK(reg_string("device_param_files", "hca_param_files",
                     "Colon-delimited list of INI-style files that contain device vendor/part-specific parameters",
                     str, &mca_btl_openib_component.device_params_file_names, 
                     0));
    free(str);

    CHECK(reg_string("device_type", NULL,
                     "Specify to only use IB or iWARP network adapters (infiniband = only use InfiniBand HCAs; iwarp = only use iWARP NICs; all = use any available adapters)",
                     "all", &str, 0));
    if (0 == strcasecmp(str, "ib") ||
        0 == strcasecmp(str, "infiniband")) {
        mca_btl_openib_component.device_type = BTL_OPENIB_DT_IB;
    } else if (0 == strcasecmp(str, "iw") ||
               0 == strcasecmp(str, "iwarp")) {
        mca_btl_openib_component.device_type = BTL_OPENIB_DT_IWARP;
    } else if (0 == strcasecmp(str, "all")) {
        mca_btl_openib_component.device_type = BTL_OPENIB_DT_ALL;
    } else {
        orte_show_help("help-mpi-btl-openib.txt",
                       "ibv_fork requested but not supported", true,
                       orte_process_info.nodename);
        return OMPI_ERROR;
    }
    free(str);

    CHECK(reg_int("max_btls", NULL,
                  "Maximum number of device ports to use "
                  "(-1 = use all available, otherwise must be >= 1)",
                  -1, &mca_btl_openib_component.ib_max_btls,
                  REGINT_NEG_ONE_OK | REGINT_GE_ONE));
    CHECK(reg_int("free_list_num", NULL,
                  "Intial size of free lists (must be >= 1)",
                  8, &mca_btl_openib_component.ib_free_list_num,
                  REGINT_GE_ONE));
    CHECK(reg_int("free_list_max", NULL,
                  "Maximum size of free lists "
                  "(-1 = infinite, otherwise must be >= 0)",
                  -1, &mca_btl_openib_component.ib_free_list_max,
                  REGINT_NEG_ONE_OK | REGINT_GE_ONE));
    CHECK(reg_int("free_list_inc", NULL,
                  "Increment size of free lists (must be >= 1)",
                  32, &mca_btl_openib_component.ib_free_list_inc,
                  REGINT_GE_ONE));
    CHECK(reg_string("mpool", NULL,
                     "Name of the memory pool to be used (it is unlikely that you will ever want to change this",
                     "rdma", &mca_btl_openib_component.ib_mpool_name,
                     0));
    CHECK(reg_int("reg_mru_len", NULL,
                  "Length of the registration cache most recently used list "
                  "(must be >= 1)",
                  16, (int*) &mca_btl_openib_component.reg_mru_len,
                  REGINT_GE_ONE));

    CHECK(reg_int("cq_size", "ib_cq_size",
                  "Size of the OpenFabrics completion "
                  "queue (will automatically be set to a minimum of "
                  "(2 * number_of_peers * btl_openib_rd_num))",
                  1000, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.ib_cq_size[BTL_OPENIB_LP_CQ] =
        mca_btl_openib_component.ib_cq_size[BTL_OPENIB_HP_CQ] = (uint32_t) ival;

    CHECK(reg_int("max_inline_data", "ib_max_inline_data",
                  "Maximum size of inline data segment "
                  "(-1 = run-time probe to discover max value, "
                  "otherwise must be >= 0). "
                  "If not explicitly set, use max_inline_data from "
                  "the INI file containing device-specific parameters",
                  -1, &ival, REGINT_NEG_ONE_OK | REGINT_GE_ZERO));
    mca_btl_openib_component.ib_max_inline_data = (int32_t) ival;

    CHECK(reg_string("pkey", "ib_pkey_val", 
                     "OpenFabrics partition key (pkey) value. "
                     "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB paritition key value (0x7fff)",
                     "0", &pkey, 0));
    mca_btl_openib_component.ib_pkey_val = 
        ompi_btl_openib_ini_intify(pkey) & MCA_BTL_IB_PKEY_MASK;
    free(pkey);

    CHECK(reg_int("psn", "ib_psn",
                  "OpenFabrics packet sequence starting number "
                  "(must be >= 0)",
                  0, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.ib_psn = (uint32_t) ival;

    CHECK(reg_int("ib_qp_ous_rd_atom", NULL, 
                  "InfiniBand outstanding atomic reads "
                  "(must be >= 0)",
                  4, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.ib_qp_ous_rd_atom = (uint32_t) ival;

    asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files).  Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes",
             IBV_MTU_256,
             IBV_MTU_512,
             IBV_MTU_1024,
             IBV_MTU_2048,
             IBV_MTU_4096);
    if (NULL == msg) {
        /* Don't try to recover from this */
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    CHECK(reg_int("mtu", "ib_mtu", msg, IBV_MTU_1024, &ival, 0));
    free(msg);
    if (ival < IBV_MTU_1024 || ival > IBV_MTU_4096) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "invalid value for btl_openib_ib_mtu",
                       "btl_openib_ib_mtu reset to 1024");
        mca_btl_openib_component.ib_mtu = IBV_MTU_1024;
    } else {
        mca_btl_openib_component.ib_mtu = (uint32_t) ival;
    }

    CHECK(reg_int("ib_min_rnr_timer", NULL, "InfiniBand minimum "
                  "\"receiver not ready\" timer, in seconds "
                  "(must be >= 0 and <= 31)",
                  25, &ival, 0));
    if (ival > 31) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "btl_openib_ib_min_rnr_timer > 31",
                       "btl_openib_ib_min_rnr_timer reset to 31");
        ival = 31;
    } else if (ival < 0){
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                   true, "btl_openib_ib_min_rnr_timer < 0",
                   "btl_openib_ib_min_rnr_timer reset to 0");
        ival = 0;
    }
    mca_btl_openib_component.ib_min_rnr_timer = (uint32_t) ival;

    CHECK(reg_int("ib_timeout", NULL, "InfiniBand transmit timeout, plugged into formula: 4.096 microseconds * (2^btl_openib_ib_timeout)"
                  "(must be >= 0 and <= 31)",
                  20, &ival, 0));
    if (ival > 31) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "btl_openib_ib_timeout > 31",
                       "btl_openib_ib_timeout reset to 31");
        ival = 31;
    } else if (ival < 0) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                   true, "btl_openib_ib_timeout < 0",
                   "btl_openib_ib_timeout reset to 0");
        ival = 0;
    }
    mca_btl_openib_component.ib_timeout = (uint32_t) ival;

    CHECK(reg_int("ib_retry_count", NULL, "InfiniBand transmit retry count "
                  "(must be >= 0 and <= 7)",
                  7, &ival, 0));
    if (ival > 7) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "btl_openib_ib_retry_count > 7",
                       "btl_openib_ib_retry_count reset to 7");
        ival = 7;
    } else if (ival < 0) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                   true, "btl_openib_ib_retry_count < 0",
                   "btl_openib_ib_retry_count reset to 0");
        ival = 0;
    }
    mca_btl_openib_component.ib_retry_count = (uint32_t) ival;

    CHECK(reg_int("ib_rnr_retry", NULL, "InfiniBand \"receiver not ready\" "
                  "retry count; applies *only* to SRQ/XRC queues.  PP queues "
                  "use RNR retry values of 0 because Open MPI performs "
                  "software flow control to guarantee that RNRs never occur "
                  "(must be >= 0 and <= 7; 7 = \"infinite\")",
                  7, &ival, 0));
    if (ival > 7) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "btl_openib_ib_rnr_retry > 7",
                       "btl_openib_ib_rnr_retry reset to 7");
        ival = 7;
    } else if (ival < 0) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                   true, "btl_openib_ib_rnr_retry < 0",
                   "btl_openib_ib_rnr_retry reset to 0");
        ival = 0;
    }
    mca_btl_openib_component.ib_rnr_retry = (uint32_t) ival;

    CHECK(reg_int("ib_max_rdma_dst_ops", NULL, "InfiniBand maximum pending RDMA "
                  "destination operations "
                  "(must be >= 0)",
                  4, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.ib_max_rdma_dst_ops = (uint32_t) ival;

    CHECK(reg_int("ib_service_level", NULL, "InfiniBand service level "
                  "(must be >= 0 and <= 15)",
                  0, &ival, 0));
    if (ival > 15) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                       true, "btl_openib_ib_service_level > 15",
                       "btl_openib_ib_service_level reset to 15");
        ival = 15;
    } else if (ival < 0) {
        orte_show_help("help-mpi-btl-openib.txt", "invalid mca param value",
                   true, "btl_openib_ib_service_level < 0",
                   "btl_openib_ib_service_level reset to 0");
        ival = 0;
    }
    mca_btl_openib_component.ib_service_level = (uint32_t) ival;

    CHECK(reg_int("use_eager_rdma", NULL, "Use RDMA for eager messages "
                  "(-1 = use device default, 0 = do not use eager RDMA, "
                  "1 = use eager RDMA)",
                  -1, &ival, 0));
    mca_btl_openib_component.use_eager_rdma = (int32_t) ival;

    CHECK(reg_int("eager_rdma_threshold", NULL,
                  "Use RDMA for short messages after this number of "
                  "messages are received from a given peer "
                  "(must be >= 1)",
                  16, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.eager_rdma_threshold = (int32_t) ival;

    CHECK(reg_int("max_eager_rdma", NULL, "Maximum number of peers allowed to use "
                  "RDMA for short messages (RDMA is used for all long "
                  "messages, except if explicitly disabled, such as "
                  "with the \"dr\" pml) "
                  "(must be >= 0)",
                  16, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.max_eager_rdma = (int32_t) ival;

    CHECK(reg_int("eager_rdma_num", NULL, "Number of RDMA buffers to allocate "
                  "for small messages"
                  "(must be >= 1)",
                  16, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.eager_rdma_num = (int32_t) (ival + 1);

    CHECK(reg_int("btls_per_lid", NULL, "Number of BTLs to create for each "
                  "InfiniBand LID "
                  "(must be >= 1)",
                  1, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.btls_per_lid = (uint32_t) ival;

    CHECK(reg_int("max_lmc", NULL, "Maximum number of LIDs to use for each device port "
                  "(must be >= 0, where 0 = use all available)",
                  0, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.max_lmc = (uint32_t) ival;

#if OMPI_HAVE_THREADS
    CHECK(reg_int("enable_apm_over_lmc", NULL, "Maximum number of alterative paths for each device port "
                  "(must be >= -1, where 0 = disable apm, -1 = all availible alternative paths )",
                  0, &ival, REGINT_NEG_ONE_OK|REGINT_GE_ZERO));
    mca_btl_openib_component.apm_lmc = (uint32_t) ival;
    CHECK(reg_int("enable_apm_over_ports", NULL, "Enable alterative path migration (APM) over different ports of the same device "
                  "(must be >= 0, where 0 = disable APM over ports , 1 = enable APM over ports of the same device)",
                  0, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.apm_ports = (uint32_t) ival;

    CHECK(reg_int("enable_apm_over_lmc", NULL, "Maximum number of alterative paths for each device port "
                  "(must be >= -1, where 0 = disable APM, -1 = all availible alternative paths)",
                  0, &ival, REGINT_NEG_ONE_OK|REGINT_GE_ZERO));
    mca_btl_openib_component.apm_lmc = (uint32_t) ival;
    CHECK(reg_int("enable_apm_over_ports", NULL, "Enable alterative path migration (APM) over different ports of the same device "
                  "(must be >= 0, where 0 = disable APM over ports, 1 = enable APM over ports of the same device)",
                  0, &ival, REGINT_GE_ZERO));
    mca_btl_openib_component.apm_ports = (uint32_t) ival;

    CHECK(reg_int("use_async_event_thread", NULL,
                "If nonzero, use the thread that will handle InfiniBand asyncihronous events ",
                1, &ival, 0));
    mca_btl_openib_component.use_async_event_thread = (0 != ival);
#endif

    CHECK(reg_int("buffer_alignment", NULL,
                  "Prefered communication buffer alignment, in bytes "
                  "(must be > 0 and power of two)",
                  64, &ival, REGINT_GE_ZERO));
    if(ival <= 1 || (ival & (ival - 1))) {
        orte_show_help("help-mpi-btl-openib.txt", "wrong buffer alignment",
                true, ival, orte_process_info.nodename, 64);
        mca_btl_openib_component.buffer_alignment = 64;
    } else {
        mca_btl_openib_component.buffer_alignment = (uint32_t) ival;
    }

    CHECK(reg_int("use_message_coalescing", NULL,
                  "Use message coalescing", 1, &ival, 0));
    mca_btl_openib_component.use_message_coalescing = (0 != ival);

    CHECK(reg_int("cq_poll_ratio", NULL,
                  "how often poll high priority CQ versus low priority CQ",
                  100, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.cq_poll_ratio = (uint32_t)ival;
    CHECK(reg_int("eager_rdma_poll_ratio", NULL,
                  "how often poll eager RDMA channel versus CQ",
                  100, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.eager_rdma_poll_ratio = (uint32_t)ival;
    CHECK(reg_int("hp_cq_poll_per_progress", NULL,
                  "max number of completion events to process for each call "
                  "of BTL progress engine",
                  10, &ival, REGINT_GE_ONE));
    mca_btl_openib_component.cq_poll_progress = (uint32_t)ival;

    /* Info only */
    mca_base_param_reg_int(&mca_btl_openib_component.super.btl_version,
                           "have_fork_support",
                           "Whether the OpenFabrics stack supports applications that invoke the \"fork()\" system call or not (0 = no, 1 = yes).  Note that this value does NOT indicate whether the system being run on supports \"fork()\" with OpenFabrics applications or not.",
                           false, true,
                           OMPI_HAVE_IBV_FORK_INIT ? 1 : 0,
                           NULL);

    mca_btl_openib_module.super.btl_exclusivity = MCA_BTL_EXCLUSIVITY_DEFAULT;

    mca_btl_openib_module.super.btl_eager_limit = 12 * 1024;
    mca_btl_openib_module.super.btl_rndv_eager_limit = 12 * 1024;
    mca_btl_openib_module.super.btl_max_send_size = 64 * 1024;
    mca_btl_openib_module.super.btl_rdma_pipeline_send_length = 1024 * 1024;
    mca_btl_openib_module.super.btl_rdma_pipeline_frag_size = 1024 * 1024;
    mca_btl_openib_module.super.btl_min_rdma_pipeline_size = 256 * 1024;
    mca_btl_openib_module.super.btl_flags = MCA_BTL_FLAGS_RDMA |
        MCA_BTL_FLAGS_NEED_ACK | MCA_BTL_FLAGS_NEED_CSUM | MCA_BTL_FLAGS_HETEROGENEOUS_RDMA;
    mca_btl_openib_module.super.btl_bandwidth = 800;
    mca_btl_openib_module.super.btl_latency = 10;
    CHECK(mca_btl_base_param_register(
            &mca_btl_openib_component.super.btl_version,
            &mca_btl_openib_module.super));

    /* setup all the qp stuff */
    mid_qp_size = mca_btl_openib_module.super.btl_eager_limit / 4;
    /* round mid_qp_size to smallest power of two */
    for(i = 31; i > 0; i--) {
        if(!(mid_qp_size & (1<<i))) {
            continue;
        }
        mid_qp_size = (1<<i);
        break;
    }

    if(mid_qp_size <= 128) {
        mid_qp_size = 1024;
    }

    snprintf(default_qps, 100,
            "P,128,256,192,128:S,%u,256,128,32:S,%u,256,128,32:S,%u,256,128,32",
            mid_qp_size,
            (uint32_t)mca_btl_openib_module.super.btl_eager_limit,
            (uint32_t)mca_btl_openib_module.super.btl_max_send_size);

    mca_btl_openib_component.default_recv_qps = strdup(default_qps);
    if(NULL == mca_btl_openib_component.default_recv_qps) {
        BTL_ERROR(("Unable to allocate memory for default receive queues string.\n"));
        return OMPI_ERROR;
    }

    CHECK(reg_string("receive_queues", NULL,
                     "Colon-delimited, comma delimited list of receive queues: P,4096,8,6,4:P,32768,8,6,4",
                     default_qps, &mca_btl_openib_component.receive_queues, 
                     0));
    mca_btl_openib_component.receive_queues_source = 
        (0 == strcmp(default_qps, 
                     mca_btl_openib_component.receive_queues)) ? 
        BTL_OPENIB_RQ_SOURCE_DEFAULT : BTL_OPENIB_RQ_SOURCE_MCA;

    CHECK(reg_string("if_include", NULL,
                     "Comma-delimited list of devices/ports to be used (e.g. \"mthca0,mthca1:2\"; empty value means to use all ports found).  Mutually exclusive with btl_openib_if_exclude.",
                     NULL, &mca_btl_openib_component.if_include,
                     0));

    CHECK(reg_string("if_exclude", NULL,
                     "Comma-delimited list of device/ports to be excluded (empty value means to not exclude any ports).  Mutually exclusive with btl_openib_if_include.",
                     NULL, &mca_btl_openib_component.if_exclude,
                     0));

    CHECK(reg_string("ipaddr_include", NULL,
                     "Comma-delimited list of IP Addresses to be used (e.g. \"192.168.1.0/24\").  Mutually exclusive with btl_openib_ipaddr_exclude.",
                     NULL, &mca_btl_openib_component.ipaddr_include,
                     0));

    CHECK(reg_string("ipaddr_exclude", NULL,
                     "Comma-delimited list of IP Addresses to be excluded (e.g. \"192.168.1.0/24\").  Mutually exclusive with btl_openib_ipaddr_include.",
                     NULL, &mca_btl_openib_component.ipaddr_exclude,
                     0));

    /* Register any MCA params for the connect pseudo-components */
    if (OMPI_SUCCESS == ret) {
        ret = ompi_btl_openib_connect_base_register();
    }

    return ret;
}
Ejemplo n.º 9
0
static int hcoll_register(void)
{

    int ret, tmp;

    ret = OMPI_SUCCESS;

#define CHECK(expr) do {                        \
        tmp = (expr);                           \
        if (OMPI_SUCCESS != tmp) ret = tmp;     \
    } while (0)


    CHECK(reg_int("priority",NULL,
                  "Priority of the hcol coll component",
                  90,
                  &mca_coll_hcoll_component.hcoll_priority,
                  0));

    CHECK(reg_int("verbose", NULL,
                  "Verbose level of the hcol coll component",
                  0,
                  &mca_coll_hcoll_component.hcoll_verbose,
                  0));

    CHECK(reg_int("enable",NULL,
                  "[1|0|] Enable/Disable HCOL",
                  1,
                  &mca_coll_hcoll_component.hcoll_enable,
                  0));

    CHECK(reg_int("np",NULL,
                  "Minimal number of processes in the communicator"
                  " for the corresponding hcoll context to be created (default: 32)",
                  2,
                  &mca_coll_hcoll_component.hcoll_np,
                  0));

    CHECK(reg_int("datatype_fallback",NULL,
                  "[1|0|] Enable/Disable user defined dattypes fallback",
                  1,
                  &mca_coll_hcoll_component.hcoll_datatype_fallback,
                  0));

    mca_coll_hcoll_component.compiletime_version = HCOLL_VERNO_STRING;
    mca_base_component_var_register(&mca_coll_hcoll_component.super.collm_version,
            MCA_COMPILETIME_VER,
            "Version of the libhcoll library with which Open MPI was compiled",
            MCA_BASE_VAR_TYPE_VERSION_STRING,
            NULL, 0, 0,
            OPAL_INFO_LVL_3,
            MCA_BASE_VAR_SCOPE_READONLY,
            &mca_coll_hcoll_component.compiletime_version);
    mca_coll_hcoll_component.runtime_version = hcoll_get_version();
    mca_base_component_var_register(&mca_coll_hcoll_component.super.collm_version,
            MCA_RUNTIME_VER,
            "Version of the libhcoll library with which Open MPI is running",
            MCA_BASE_VAR_TYPE_VERSION_STRING,
            NULL, 0, 0,
            OPAL_INFO_LVL_3,
            MCA_BASE_VAR_SCOPE_READONLY,
            &mca_coll_hcoll_component.runtime_version);

    return ret;
}
int mca_bcol_iboffload_register_params(void)
{
    mca_base_var_enum_t *new_enum;
    char *msg;
    int ret = OMPI_SUCCESS, tmp;

#define CHECK(expr) do {                    \
        tmp = (expr);                       \
        if (OMPI_SUCCESS != tmp) ret = tmp; \
     } while (0)

    /* register openib component parameters */
    CHECK(reg_int("k_nomial_radix", NULL,
                  "The radix of the K-nomial tree for scatther-gather type algorithms"
                  "(starts from 2)", 2, &mca_bcol_iboffload_component.k_nomial_radix,
                  REGINT_GE_ONE));

    CHECK(reg_int("priority", NULL,
                  "IB offload component priority"
                  "(from 0(low) to 90 (high))", 90,
                  &mca_bcol_iboffload_component.super.priority, 0));

    CHECK(reg_int("verbose", NULL,
                  "Output some verbose IB offload BTL information "
                  "(0 = no output, nonzero = output)", 0,
                  &mca_bcol_iboffload_component.verbose, 0));

    CHECK(reg_bool("warn_default_gid_prefix", NULL,
                   "Warn when there is more than one active ports and at least one of them connected to the network with only default GID prefix configured (0 = do not warn; any other value = warn)",
                   true, &mca_bcol_iboffload_component.warn_default_gid_prefix));

    CHECK(reg_bool("warn_nonexistent_if", NULL,
                   "Warn if non-existent devices and/or ports are specified in the bcol_iboffla_if_[in|ex]clude MCA parameters (0 = do not warn; any other value = warn)",
                   true, &mca_bcol_iboffload_component.warn_nonexistent_if));

    CHECK(reg_int("max_pipeline_depth", NULL,
                  "The maximal number of fragments of the same collective request that can be transferred in parallel", 3,
                  (int *) &mca_bcol_iboffload_component.max_pipeline_depth, 0));

    CHECK(reg_int("max_mqe_tasks", NULL,
                  "Maximum number of MQEs for each iboffload module",
                  1024, &mca_bcol_iboffload_component.max_mqe_tasks, 0));
    CHECK(reg_int("max_mq_size", NULL,
                  "Maximum size of each MQ for each iboffload module",
                  1024, &mca_bcol_iboffload_component.max_mq_size, 0));
    CHECK(reg_int("free_list_num", NULL,
                  "Intial size of free lists (must be >= 1)",
                  256, &mca_bcol_iboffload_component.free_list_num,
                  REGINT_GE_ONE));
    CHECK(reg_int("free_list_max", NULL,
                  "Maximum size of free lists "
                  "(-1 = infinite, otherwise must be >= 0)",
                  -1, &mca_bcol_iboffload_component.free_list_max,
                  REGINT_NEG_ONE_OK | REGINT_GE_ONE));
    CHECK(reg_int("free_list_inc", NULL,
                  "Increment size of free lists (must be >= 1)",
                  32, &mca_bcol_iboffload_component.free_list_inc,
                  REGINT_GE_ONE));
    CHECK(reg_string("mpool", NULL,
                     "Name of the memory pool to be used (it is unlikely that you will ever want to change this",
                     "rdma", &mca_bcol_iboffload_component.mpool_name,
                     0));
    CHECK(reg_int("cq_size", "cq_size",
                  "Size of the OpenFabrics completion "
                  "queue (will automatically be set to a minimum of "
                  "(2 * number_of_peers * bcol_iboffload_rd_num))",
                  1024, &mca_bcol_iboffload_component.cq_size, REGINT_GE_ONE));

    CHECK(reg_int("exchange_tree_order", NULL,
                  "The order of the exchange tree. "
                  "Must be power of two.",
                   2, &mca_bcol_iboffload_component.exchange_tree_order, REGINT_GE_ONE));

    CHECK(reg_int("knomial_tree_order", NULL,
                  "The order of the knomial exchange tree. ",
                   3, &mca_bcol_iboffload_component.knomial_tree_order, REGINT_GE_ONE));


    CHECK(reg_int("max_inline_data", "max_inline_data",
                  "Maximum size of inline data segment "
                  "(-1 = run-time probe to discover max value, "
                  "otherwise must be >= 0). "
                  "If not explicitly set, use max_inline_data from "
                  "the INI file containing device-specific parameters",
                  128, (int *) &mca_bcol_iboffload_component.max_inline_data,
                  REGINT_NEG_ONE_OK | REGINT_GE_ZERO));

#if 0
    CHECK(reg_string("pkey", "ib_pkey_val",
                     "OpenFabrics partition key (pkey) value. "
                     "Unsigned integer decimal or hex values are allowed (e.g., \"3\" or \"0x3f\") and will be masked against the maximum allowable IB paritition key value (0x7fff)",
                     "0", &pkey, 0));
    /* Pasha
    mca_bcol_iboffload_component.pkey_val =
        ompi_btl_openib_ini_intify(pkey) & MCA_BTL_IB_PKEY_MASK;
    free(pkey);
    */
#endif

    CHECK(reg_string("receive_queues", NULL,
                     "Colon-delimited, comma delimited list of receive queues: P,4096,8,6,4:P,32768,8,6,4",
                     "P,512,256,192,128", &mca_bcol_iboffload_component.receive_queues,
                     0));

    CHECK(reg_int("qp_ous_rd_atom", NULL,
                  "InfiniBand outstanding atomic reads (must be >= 0)", 4,
                  (int *) &mca_bcol_iboffload_component.qp_ous_rd_atom, REGINT_GE_ZERO));

    asprintf(&msg, "OpenFabrics MTU, in bytes (if not specified in INI files).  Valid values are: %d=256 bytes, %d=512 bytes, %d=1024 bytes, %d=2048 bytes, %d=4096 bytes",
             IBV_MTU_256,
             IBV_MTU_512,
             IBV_MTU_1024,
             IBV_MTU_2048,
             IBV_MTU_4096);
    if (NULL == msg) {
        /* Don't try to recover from this */
        return OMPI_ERR_OUT_OF_RESOURCE;
    }
    CHECK(mca_base_var_enum_create("infiniband mtu", mtu_values, &new_enum));
    mca_bcol_iboffload_component.mtu = IBV_MTU_1024;
    tmp = mca_base_component_var_register(&mca_bcol_iboffload_component.super.bcol_version,
                                          "mtu", msg, MCA_BASE_VAR_TYPE_INT, new_enum, 0, 0,
                                          OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
                                          &mca_bcol_iboffload_component.mtu);
    OBJ_RELEASE(new_enum);
    free(msg);

    if (0 > tmp) ret = tmp;

    tmp = mca_base_var_register_synonym(tmp, "ompi", "bcol", "iboffload", "ib_mtu",
                                        MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
    if (0 > tmp) ret = tmp;

    CHECK(reg_int("ib_min_rnr_timer", NULL, "InfiniBand minimum "
                  "\"receiver not ready\" timer, in seconds "
                  "(must be >= 0 and <= 31)",
                  1 , &mca_bcol_iboffload_component.min_rnr_timer, 0));

    CHECK(reg_int("ib_timeout", NULL, "InfiniBand transmit timeout, plugged into formula: 4.096 microseconds * "
                  "(2^bcol_iboffload_ib_timeout) (must be >= 0 and <= 31)",
                  20, &mca_bcol_iboffload_component.timeout, 0));

    CHECK(reg_int("ib_retry_count", NULL, "InfiniBand transmit retry count "
                  "(must be >= 0 and <= 7)",
                  7, &mca_bcol_iboffload_component.retry_count, 0));

    CHECK(reg_int("ib_rnr_retry", NULL, "InfiniBand \"receiver not ready\" "
                  "retry count; applies *only* to SRQ/XRC queues.  PP queues "
                  "use RNR retry values of 0 because Open MPI performs "
                  "software flow control to guarantee that RNRs never occur "
                  "(must be >= 0 and <= 7; 7 = \"infinite\")",
                  7, &mca_bcol_iboffload_component.rnr_retry, 0));

    CHECK(reg_int("ib_max_rdma_dst_ops", NULL, "InfiniBand maximum pending RDMA "
                  "destination operations "
                  "(must be >= 0)",
                  4, &mca_bcol_iboffload_component.max_rdma_dst_ops, REGINT_GE_ZERO));

    CHECK(reg_int("ib_service_level", NULL, "InfiniBand service level "
                  "(must be >= 0 and <= 15)",
                  0, &mca_bcol_iboffload_component.service_level, 0));

    CHECK(reg_int("buffer_alignment", NULL,
                  "Prefered communication buffer alignment, in bytes "
                  "(must be > 0 and power of two)",
                  64, &mca_bcol_iboffload_component.buffer_alignment, REGINT_GE_ZERO));

    /* register parmeters controlling message fragementation */
    CHECK(reg_int("min_frag_size", NULL,
                  "Minimum fragment size",
                  getpagesize(), &mca_bcol_iboffload_component.super.min_frag_size,
                  REGINT_GE_ONE));

    CHECK(reg_int("max_frag_size", NULL,
                  "Maximum fragment size",
                  FRAG_SIZE_NO_LIMIT, &mca_bcol_iboffload_component.super.max_frag_size,
                  REGINT_NONZERO));

    CHECK(reg_bool("can_use_user_buffers", NULL,
                   "User memory can be used by the collective algorithms",
                   true, &mca_bcol_iboffload_component.super.can_use_user_buffers));

    CHECK(reg_int("barrier_mode", NULL,
                "Barrier mode: 0 - Recursive doubling; 1 - Recursive K-ing",
                0, &mca_bcol_iboffload_component.barrier_mode, REGINT_GE_ZERO));

    CHECK(reg_int("max_progress_pull", NULL,
                "Max number of progress pull checks",
                8, &mca_bcol_iboffload_component.max_progress_pull, REGINT_GE_ZERO));

    CHECK(reg_int("use_brucks_smsg_alltoall_rdma", NULL,
                "Use brucks algorithm for smsg alltoall and RDMA semantics 1 = No Temp buffer recycling"
                "1 = Alg with no Temp Buffer Recycling (faster), 2 = Alg with temp Buffer Recycling (slower)",
                0, &mca_bcol_iboffload_component.use_brucks_smsg_alltoall_rdma, 0));

    CHECK(reg_int("use_brucks_smsg_alltoall_sr", NULL,
                "Use brucks algorithm for smsg alltoall and Send/Recv semantics "
                "1 = Alg with RTR (faster), 2 = Alg with RNR (slower)",
                0, &mca_bcol_iboffload_component.use_brucks_smsg_alltoall_sr, 0));

    CHECK(reg_int("alltoall_bruck_radix", NULL,
                "Radix for Bruck algorithm for smsg alltoall",
                3, &mca_bcol_iboffload_component.k_alltoall_bruck_radix, 0));

    CHECK(reg_int("k_alltoall_bruck_radix", NULL,
                "Temp Buffer alignment for Bruck algorithm for smsg alltoall",
                64, &mca_bcol_iboffload_component.tmp_buf_alignment, 0));

    /*
    CHECK(reg_string("if_include", NULL,
                     "Comma-delimited list of devices/ports to be used (e.g. \"mthca0,mthca1:2\"; empty value means to use all ports found).  Mutually exclusive with bcol_iboffload_if_exclude.",
                     NULL, &mca_bcol_iboffload_component.if_include,
                     0));

    CHECK(reg_string("if_exclude", NULL,
                     "Comma-delimited list of device/ports to be excluded (empty value means to not exclude any ports).  Mutually exclusive with bcol_iboffload_if_include.",
                     NULL, &mca_bcol_iboffload_component.if_exclude,
                     0));
    */

    CHECK(mca_bcol_iboffload_verify_params());

    /* Register any MCA params for the connect pseudo-components */
    if (OMPI_SUCCESS == ret) {
        ret = ompi_common_ofacm_base_register(&mca_bcol_iboffload_component.super.bcol_version);
    }

    return ret;
}