예제 #1
0
파일: fabric.c 프로젝트: biddisco/libfabric
void fi_ini(void)
{
	char *param_val = NULL;

	pthread_mutex_lock(&ofi_ini_lock);

	if (ofi_init)
		goto unlock;

	fi_param_init();
	fi_log_init();
	fi_util_init();
	ofi_osd_init();

	fi_param_define(NULL, "provider", FI_PARAM_STRING,
			"Only use specified provider (default: all available)");
	fi_param_define(NULL, "fork_unsafe", FI_PARAM_BOOL,
			"Whether use of fork() may be unsafe for some providers"
			" (default: no). Setting this to yes could improve"
			" performance at the expense of making fork() potentially"
			" unsafe");
	fi_param_get_str(NULL, "provider", &param_val);
	fi_create_filter(&prov_filter, param_val);

#ifdef HAVE_LIBDL
	int n = 0;
	char **dirs;
	char *provdir = NULL;
	void *dlhandle;

	/* If dlopen fails, assume static linking and just return
	   without error */
	dlhandle = dlopen(NULL, RTLD_NOW);
	if (dlhandle == NULL) {
		goto libdl_done;
	}
	dlclose(dlhandle);

	fi_param_define(NULL, "provider_path", FI_PARAM_STRING,
			"Search for providers in specific path (default: "
			PROVDLDIR ")");
	fi_param_get_str(NULL, "provider_path", &provdir);
	if (!provdir)
		provdir = PROVDLDIR;

	dirs = split_and_alloc(provdir, ":");
	if (dirs) {
		for (n = 0; dirs[n]; ++n) {
			fi_ini_dir(dirs[n]);
		}
		free_string_array(dirs);
	}
libdl_done:
#endif

	fi_register_provider(PSM2_INIT, NULL);
	fi_register_provider(PSM_INIT, NULL);
	fi_register_provider(USNIC_INIT, NULL);
	fi_register_provider(MLX_INIT, NULL);
	fi_register_provider(VERBS_INIT, NULL);
	fi_register_provider(GNI_INIT, NULL);
	fi_register_provider(RXM_INIT, NULL);
	fi_register_provider(BGQ_INIT, NULL);

        /* Initialize the socket(s) provider last.  This will result in
           it being the least preferred provider. */
	fi_register_provider(UDP_INIT, NULL);
	fi_register_provider(SOCKETS_INIT, NULL);
	/* Before you add ANYTHING here, read the comment above!!! */

	/* Seriously, read it! */

	ofi_init = 1;

unlock:
	pthread_mutex_unlock(&ofi_ini_lock);
}
예제 #2
0
void fi_ini(void)
{
	char *param_val = NULL;

	pthread_mutex_lock(&common_locks.ini_lock);

	if (ofi_init)
		goto unlock;

	ofi_ordered_provs_init();
	fi_param_init();
	fi_log_init();
	ofi_osd_init();
	ofi_pmem_init();
	ofi_perf_init();
	ofi_hook_init();

	fi_param_define(NULL, "provider", FI_PARAM_STRING,
			"Only use specified provider (default: all available)");
	fi_param_define(NULL, "fork_unsafe", FI_PARAM_BOOL,
			"Whether use of fork() may be unsafe for some providers"
			" (default: no). Setting this to yes could improve"
			" performance at the expense of making fork() potentially"
			" unsafe");
	fi_param_define(NULL, "universe_size", FI_PARAM_SIZE_T,
			"Defines the maximum number of processes that will be"
			" used by distribute OFI application. The provider uses"
			" this to optimize resource allocations"
			" (default: OFI service specific)");
	fi_param_get_str(NULL, "provider", &param_val);
	ofi_create_filter(&prov_filter, param_val);

#ifdef HAVE_LIBDL
	int n = 0;
	char **dirs;
	char *provdir = NULL;
	void *dlhandle;

	/* If dlopen fails, assume static linking and just return
	   without error */
	dlhandle = dlopen(NULL, RTLD_NOW);
	if (dlhandle == NULL) {
		goto libdl_done;
	}
	dlclose(dlhandle);

	fi_param_define(NULL, "provider_path", FI_PARAM_STRING,
			"Search for providers in specific path (default: "
			PROVDLDIR ")");
	fi_param_get_str(NULL, "provider_path", &provdir);
	if (!provdir)
		provdir = PROVDLDIR;

	dirs = ofi_split_and_alloc(provdir, ":", NULL);
	if (dirs) {
		for (n = 0; dirs[n]; ++n) {
			ofi_ini_dir(dirs[n]);
		}
		ofi_free_string_array(dirs);
	}
libdl_done:
#endif

	ofi_register_provider(PSM2_INIT, NULL);
	ofi_register_provider(PSM_INIT, NULL);
	ofi_register_provider(USNIC_INIT, NULL);
	ofi_register_provider(MLX_INIT, NULL);
	ofi_register_provider(GNI_INIT, NULL);
	ofi_register_provider(BGQ_INIT, NULL);
	ofi_register_provider(NETDIR_INIT, NULL);
	ofi_register_provider(SHM_INIT, NULL);
	ofi_register_provider(RXM_INIT, NULL);
	ofi_register_provider(VERBS_INIT, NULL);
	//ofi_register_provider(MRAIL_INIT, NULL);
	ofi_register_provider(RSTREAM_INIT, NULL);

	{
		/* TODO: RXD is not stable for now. Disable it by default */
		int enable_rxd = 0;
		fi_param_define(NULL, "rxd_enable", FI_PARAM_BOOL,
				"Enable RXD provider (default: no)");
		fi_param_get_bool(NULL, "rxd_enable", &enable_rxd);
		if (enable_rxd)
			ofi_register_provider(RXD_INIT, NULL);
	}

	ofi_register_provider(UDP_INIT, NULL);
	ofi_register_provider(SOCKETS_INIT, NULL);
	ofi_register_provider(TCP_INIT, NULL);

	ofi_init = 1;

unlock:
	pthread_mutex_unlock(&common_locks.ini_lock);
}