2007-12-21 09:02:00 +03:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
2004-06-17 20:13:20 +04:00
|
|
|
/*
|
2005-11-05 22:57:48 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
2007-12-21 09:02:00 +03:00
|
|
|
* Copyright (c) 2004-2007 The University of Tennessee and The University
|
2005-11-05 22:57:48 +03:00
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2004-11-28 23:09:25 +03:00
|
|
|
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
|
|
|
* University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
2007-02-26 19:25:20 +03:00
|
|
|
* Copyright (c) 2006-2007 Mellanox Technologies. All rights reserved.
|
2009-04-01 21:52:16 +04:00
|
|
|
* Copyright (c) 2008-2009 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-17 20:13:20 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2009-05-07 00:11:28 +04:00
|
|
|
#define OPAL_DISABLE_ENABLE_MEM_DEBUG 1
|
2004-06-17 20:13:20 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2004-11-05 10:52:30 +03:00
|
|
|
#include <string.h>
|
2007-05-27 07:55:21 +04:00
|
|
|
#ifdef HAVE_MALLOC_H
|
|
|
|
#include <malloc.h>
|
|
|
|
#endif
|
2004-06-17 20:13:20 +04:00
|
|
|
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "opal/mca/base/base.h"
|
2012-06-27 05:28:28 +04:00
|
|
|
#include "orte/util/show_help.h"
|
|
|
|
#include "orte/util/name_fns.h"
|
|
|
|
#include "orte/util/proc_info.h"
|
|
|
|
#include "orte/runtime/orte_globals.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/mpool/mpool.h"
|
2008-07-25 02:51:26 +04:00
|
|
|
#include "ompi/runtime/params.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "ompi/mca/mpool/base/base.h"
|
2005-09-14 06:17:04 +04:00
|
|
|
#include "mpool_base_mem_cb.h"
|
2004-06-17 20:13:20 +04:00
|
|
|
|
2006-01-24 01:51:50 +03:00
|
|
|
|
2005-01-15 16:20:26 +03:00
|
|
|
mca_mpool_base_component_t* mca_mpool_base_component_lookup(const char* name)
|
2004-06-17 20:13:20 +04:00
|
|
|
{
|
|
|
|
/* Traverse the list of available modules; call their init functions. */
|
2005-07-03 20:22:16 +04:00
|
|
|
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)) {
|
2004-08-02 04:24:22 +04:00
|
|
|
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) {
|
2004-06-17 20:13:20 +04:00
|
|
|
return component;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-09-13 02:28:23 +04:00
|
|
|
|
2004-06-17 20:13:20 +04:00
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
mca_mpool_base_module_t* mca_mpool_base_module_create(
|
|
|
|
const char* name,
|
2005-06-23 19:53:51 +04:00
|
|
|
void* user_data,
|
|
|
|
struct mca_mpool_base_resources_t* resources)
|
2005-06-07 00:18:56 +04:00
|
|
|
{
|
|
|
|
mca_mpool_base_component_t* component = NULL;
|
|
|
|
mca_mpool_base_module_t* module = NULL;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_item_t* item;
|
2005-06-07 01:46:43 +04:00
|
|
|
mca_mpool_base_selected_module_t *sm;
|
|
|
|
|
2005-07-03 20:22:16 +04:00
|
|
|
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)) {
|
2005-06-07 00:18:56 +04:00
|
|
|
mca_base_component_list_item_t *cli =
|
|
|
|
(mca_base_component_list_item_t *) item;
|
|
|
|
component =
|
|
|
|
(mca_mpool_base_component_t *) cli->cli_component;
|
2005-07-16 00:01:35 +04:00
|
|
|
if(0 == strcmp(component->mpool_version.mca_component_name, name)) {
|
2005-06-07 00:18:56 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2005-05-31 21:06:55 +04:00
|
|
|
|
2009-04-21 16:40:50 +04:00
|
|
|
if (opal_list_get_end(&mca_mpool_base_components) == item) {
|
2005-06-07 00:18:56 +04:00
|
|
|
return NULL;
|
2005-07-16 00:01:35 +04:00
|
|
|
}
|
2005-06-23 19:53:51 +04:00
|
|
|
module = component->mpool_init(resources);
|
2006-05-17 02:04:31 +04:00
|
|
|
if ( NULL == module ) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-06-07 00:18:56 +04:00
|
|
|
sm = OBJ_NEW(mca_mpool_base_selected_module_t);
|
|
|
|
sm->mpool_component = component;
|
|
|
|
sm->mpool_module = module;
|
2005-06-23 19:53:51 +04:00
|
|
|
sm->user_data = user_data;
|
2005-06-22 01:41:02 +04:00
|
|
|
sm->mpool_resources = resources;
|
2005-07-03 20:22:16 +04:00
|
|
|
opal_list_append(&mca_mpool_base_modules, (opal_list_item_t*) sm);
|
2008-06-14 02:32:49 +04:00
|
|
|
/* on the very first creation of a module we init the memory
|
2009-04-01 21:52:16 +04:00
|
|
|
callback */
|
2008-06-14 02:32:49 +04:00
|
|
|
if (opal_list_get_size(&mca_mpool_base_modules) == 1) {
|
2009-04-01 21:52:16 +04:00
|
|
|
/* Default to not using memory hooks */
|
|
|
|
int use_mem_hooks = 0;
|
2008-07-25 02:51:26 +04:00
|
|
|
|
2009-04-01 21:52:16 +04:00
|
|
|
/* Use the memory hooks if leave_pinned or
|
|
|
|
leave_pinned_pipeline is enabled (note that either of these
|
|
|
|
leave_pinned variables may have been set by a user MCA
|
|
|
|
param or elsewhere in the code base). Yes, we could have
|
|
|
|
coded this more succinctly, but this is more clear. */
|
|
|
|
if (ompi_mpi_leave_pinned || ompi_mpi_leave_pinned_pipeline) {
|
2008-07-25 02:51:26 +04:00
|
|
|
use_mem_hooks = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (use_mem_hooks) {
|
2009-04-01 21:52:16 +04:00
|
|
|
if ((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) ==
|
|
|
|
((OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_MUNMAP_SUPPORT) &
|
|
|
|
opal_mem_hooks_support_level())) {
|
2008-06-14 02:32:49 +04:00
|
|
|
opal_mem_hooks_register_release(mca_mpool_base_mem_cb, NULL);
|
|
|
|
} else {
|
2012-06-27 05:28:28 +04:00
|
|
|
orte_show_help("help-mpool-base.txt", "leave pinned failed",
|
|
|
|
true, name, ORTE_NAME_PRINT(ORTE_PROC_MY_NAME),
|
|
|
|
orte_process_info.nodename);
|
2008-06-14 02:32:49 +04:00
|
|
|
return NULL;
|
|
|
|
}
|
2008-07-25 02:51:26 +04:00
|
|
|
|
|
|
|
/* Set this to true so that mpool_base_close knows to
|
|
|
|
cleanup */
|
|
|
|
mca_mpool_base_used_mem_hooks = 1;
|
2006-03-09 01:29:01 +03:00
|
|
|
}
|
2005-09-17 02:22:03 +04:00
|
|
|
}
|
2005-06-07 00:18:56 +04:00
|
|
|
return module;
|
|
|
|
}
|
2005-07-16 00:01:35 +04:00
|
|
|
|
|
|
|
|
|
|
|
mca_mpool_base_module_t* mca_mpool_base_module_lookup(const char* name)
|
|
|
|
{
|
|
|
|
opal_list_item_t* item;
|
2006-01-24 01:51:50 +03:00
|
|
|
|
2005-07-16 00:01:35 +04:00
|
|
|
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;
|
|
|
|
}
|
2005-09-03 04:07:34 +04:00
|
|
|
|
|
|
|
|
|
|
|
int mca_mpool_base_module_destroy(mca_mpool_base_module_t *module)
|
|
|
|
{
|
|
|
|
opal_list_item_t* item;
|
|
|
|
mca_mpool_base_selected_module_t *sm;
|
|
|
|
|
2007-02-26 19:25:20 +03:00
|
|
|
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)) {
|
2005-09-03 04:07:34 +04:00
|
|
|
sm = (mca_mpool_base_selected_module_t *) item;
|
|
|
|
if (module == sm->mpool_module) {
|
2007-02-26 19:25:20 +03:00
|
|
|
opal_list_remove_item(&mca_mpool_base_modules,item);
|
2005-09-03 04:07:34 +04:00
|
|
|
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;
|
|
|
|
}
|