b8cb6e1c64
be used in MPI_Alloc_mem operations. Note that we found an interesting bug in which if memory was allocated by the sm mpool (via mmap) and then registered via the mvapi mpool, the registration would fail on certain systems. Added mca param mpool_base_use_mem_hooks, set to 1 to enable the memory hooks so that memory is deregistered if the user frees it behind our back. This is only useful if the mca param mpi_leave_pinned is also set to 1. Otherwise all registrations are deregistered within the MPI library or via MPI_Free_buf. After testing we should probably set both mpi_leave_pinned and mpool_base_use_mem_hooks to default to 1. This commit was SVN r7415.
131 строка
4.1 KiB
C
131 строка
4.1 KiB
C
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
* All rights reserved.
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
* All rights reserved.
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
* University of Stuttgart. All rights reserved.
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
* All rights reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
|
|
#include "ompi_config.h"
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
#include "mca/mca.h"
|
|
#include "mca/base/base.h"
|
|
#include "mca/mpool/mpool.h"
|
|
#include "mca/mpool/base/base.h"
|
|
#include "mpool_base_mem_cb.h"
|
|
|
|
extern int mca_mpool_base_use_mem_hooks;
|
|
|
|
mca_mpool_base_component_t* mca_mpool_base_component_lookup(const char* name)
|
|
{
|
|
/* Traverse the list of available modules; call their init functions. */
|
|
opal_list_item_t* item;
|
|
for (item = opal_list_get_first(&mca_mpool_base_components);
|
|
item != opal_list_get_end(&mca_mpool_base_components);
|
|
item = opal_list_get_next(item)) {
|
|
mca_base_component_list_item_t *cli =
|
|
(mca_base_component_list_item_t *) item;
|
|
mca_mpool_base_component_t* component =
|
|
(mca_mpool_base_component_t *) cli->cli_component;
|
|
if(strcmp(component->mpool_version.mca_component_name, name) == 0) {
|
|
return component;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
|
|
mca_mpool_base_module_t* mca_mpool_base_module_create(
|
|
const char* name,
|
|
void* user_data,
|
|
struct mca_mpool_base_resources_t* resources)
|
|
{
|
|
|
|
mca_mpool_base_component_t* component = NULL;
|
|
mca_mpool_base_module_t* module = NULL;
|
|
opal_list_item_t* item;
|
|
mca_mpool_base_selected_module_t *sm;
|
|
|
|
for (item = opal_list_get_first(&mca_mpool_base_components);
|
|
item != opal_list_get_end(&mca_mpool_base_components);
|
|
item = opal_list_get_next(item)) {
|
|
mca_base_component_list_item_t *cli =
|
|
(mca_base_component_list_item_t *) item;
|
|
component =
|
|
(mca_mpool_base_component_t *) cli->cli_component;
|
|
if(0 == strcmp(component->mpool_version.mca_component_name, name)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (NULL == component) {
|
|
return NULL;
|
|
}
|
|
module = component->mpool_init(resources);
|
|
sm = OBJ_NEW(mca_mpool_base_selected_module_t);
|
|
sm->mpool_component = component;
|
|
sm->mpool_module = module;
|
|
sm->user_data = user_data;
|
|
sm->mpool_resources = resources;
|
|
opal_list_append(&mca_mpool_base_modules, (opal_list_item_t*) sm);
|
|
/* on the very first creation of a module we init the memory callback*/
|
|
if(mca_mpool_base_use_mem_hooks &&
|
|
opal_list_get_size(&mca_mpool_base_modules) == 1 &&
|
|
opal_mem_free_is_supported()) {
|
|
opal_mem_free_register_handler(mca_mpool_base_mem_cb, NULL);
|
|
}
|
|
return module;
|
|
}
|
|
|
|
|
|
mca_mpool_base_module_t* mca_mpool_base_module_lookup(const char* name)
|
|
{
|
|
opal_list_item_t* item;
|
|
|
|
for (item = opal_list_get_first(&mca_mpool_base_modules);
|
|
item != opal_list_get_end(&mca_mpool_base_modules);
|
|
item = opal_list_get_next(item)) {
|
|
mca_mpool_base_selected_module_t *mli =
|
|
(mca_mpool_base_selected_module_t *) item;
|
|
if(0 == strcmp(mli->mpool_component->mpool_version.mca_component_name,
|
|
name)) {
|
|
return mli->mpool_module;
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
|
|
int mca_mpool_base_module_destroy(mca_mpool_base_module_t *module)
|
|
{
|
|
opal_list_item_t* item;
|
|
mca_mpool_base_selected_module_t *sm;
|
|
|
|
for (item = opal_list_remove_first(&mca_mpool_base_modules);
|
|
NULL != item;
|
|
item = opal_list_remove_first(&mca_mpool_base_modules)) {
|
|
sm = (mca_mpool_base_selected_module_t *) item;
|
|
if (module == sm->mpool_module) {
|
|
if (NULL != sm->mpool_module->mpool_finalize) {
|
|
sm->mpool_module->mpool_finalize(sm->mpool_module);
|
|
}
|
|
OBJ_RELEASE(sm);
|
|
return OMPI_SUCCESS;
|
|
}
|
|
}
|
|
|
|
return OMPI_ERR_NOT_FOUND;
|
|
}
|