1
1
openmpi/oshmem/mca/memheap/base/memheap_base_frame.c
2013-09-13 20:37:30 +00:00

216 строки
8.4 KiB
C

/*
* Copyright (c) 2013 Mellanox Technologies, Inc.
* All rights reserved.
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "oshmem_config.h"
#include <stdio.h>
#include "opal/mca/mca.h"
#include "opal/util/output.h"
#include "opal/mca/base/base.h"
#include "oshmem/mca/memheap/memheap.h"
#include "oshmem/mca/memheap/base/base.h"
/*
* The following file was created by configure. It contains extern
* statements and the definition of an array of pointers to each
* component's public mca_base_component_t struct.
*/
#include "oshmem/mca/memheap/base/static-components.h"
#if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0)
int mca_memheap_base_alloc_type = 5;
#else
int mca_memheap_base_alloc_type = 1;
#endif /* MPAGE_ENABLE */
void* mca_memheap_base_start_address = (void*)0xFF000000;
int mca_memheap_base_output = -1;
int mca_memheap_base_key_exchange = 1;
int mca_memheap_base_mr_interleave_factor = 2;
char* mca_memheap_base_include = NULL;
char* mca_memheap_base_exclude = NULL;
char* mca_memheap_base_param_hca_name = NULL;
opal_list_t mca_memheap_base_components_opened;
struct mca_memheap_base_module_t* mca_memheap_base_module_initialized = NULL;
int mca_memheap_base_already_opened = 0;
mca_memheap_map_t mca_memheap_base_map;
static int mca_memheap_base_register(mca_base_register_flag_t flags)
{
#if defined(MPAGE_ENABLE) && (MPAGE_ENABLE > 0)
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"alloc_type",
"0|1|2|5 - disabled huge pages, enabled huge pages with fallback to mmap(), do not fallback to mmap(), enabled mpages(default)",
MCA_BASE_VAR_TYPE_INT,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_alloc_type);
#else
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"alloc_type",
"0|1|2 - disabled huge pages, enabled huge pages(default) with fallback to mmap(), do not fallback to mmap()",
MCA_BASE_VAR_TYPE_INT,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_alloc_type);
#endif /* MPAGE_ENABLE */
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"start_address",
"Specify base address for shared memory region",
MCA_BASE_VAR_TYPE_UNSIGNED_LONG_LONG,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_start_address);
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"key_exchange",
"0|1 - disabled, enabled(default) force memory keys exchange",
MCA_BASE_VAR_TYPE_INT,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_key_exchange);
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"mr_interleave_factor",
"2 - default, try to give at least N Gbytes spaces between mapped memheaps of other pes that are local to me",
MCA_BASE_VAR_TYPE_INT,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_mr_interleave_factor);
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"include",
"Specify a specific MEMHEAP implementation to use",
MCA_BASE_VAR_TYPE_STRING,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_include);
if (NULL == mca_memheap_base_include) {
mca_memheap_base_include = getenv(SHMEM_HEAP_TYPE);
if (NULL == mca_memheap_base_include)
mca_memheap_base_include = strdup("");
else
mca_memheap_base_include = strdup(mca_memheap_base_include);
}
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"exclude",
"Specify excluded MEMHEAP implementations",
MCA_BASE_VAR_TYPE_STRING,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_exclude);
(void) mca_base_var_register("oshmem",
"memheap",
"base",
"hca_name",
"Specify excluded memheap implementations",
MCA_BASE_VAR_TYPE_STRING,
NULL,
0,
MCA_BASE_VAR_FLAG_SETTABLE,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&mca_memheap_base_param_hca_name);
return OSHMEM_SUCCESS;
}
static int mca_memheap_base_close(void)
{
if (mca_memheap_base_already_opened <= 0) {
return OSHMEM_ERROR;
}
mca_memheap_base_already_opened--;
if (mca_memheap_base_already_opened > 0) {
return OSHMEM_SUCCESS;
}
memheap_oob_destruct();
mca_memheap_base_dereg(&mca_memheap_base_map);
mca_memheap_base_alloc_exit(&mca_memheap_base_map);
mca_memheap_base_static_exit(&mca_memheap_base_map);
/* Close all remaining available components */
return mca_base_framework_components_close(&oshmem_memheap_base_framework, NULL);
}
static int mca_memheap_base_open(mca_base_open_flag_t flags)
{
mca_memheap_base_already_opened = mca_memheap_base_already_opened + 1;
if (mca_memheap_base_already_opened > 1) {
return OSHMEM_SUCCESS;
}
memset(&mca_memheap_base_map, 0, sizeof(mca_memheap_base_map));
mca_memheap_base_map.n_segments = 0;
mca_memheap_base_map.num_transports = 0;
/* Open up all available components */
if (OPAL_SUCCESS !=
mca_base_framework_components_open(&oshmem_memheap_base_framework, flags)) {
return OSHMEM_ERROR;
}
return OSHMEM_SUCCESS;
}
MCA_BASE_FRAMEWORK_DECLARE(oshmem, memheap,
"OSHMEM MEMHEAP",
mca_memheap_base_register,
mca_memheap_base_open,
mca_memheap_base_close,
mca_memheap_base_static_components,
MCA_BASE_FRAMEWORK_FLAG_DEFAULT);