2007-12-21 09:02:00 +03:00
|
|
|
/* -*- Mode: C; c-basic-offset:4 ; -*- */
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2005-11-05 22:57:48 +03:00
|
|
|
* 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.
|
2009-03-13 04:01:00 +03:00
|
|
|
* Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-06-15 23:07:45 +04:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* @file
|
2004-07-13 00:05:29 +04:00
|
|
|
* Description of the Memory Pool framework
|
2004-06-15 23:07:45 +04:00
|
|
|
*/
|
|
|
|
#ifndef MCA_MPOOL_H
|
|
|
|
#define MCA_MPOOL_H
|
2009-03-04 18:35:54 +03:00
|
|
|
#include "ompi_config.h"
|
2006-02-12 04:33:29 +03:00
|
|
|
#include "opal/mca/mca.h"
|
|
|
|
#include "ompi/info/info.h"
|
2006-06-14 21:43:50 +04:00
|
|
|
#include "ompi/class/ompi_free_list.h"
|
2005-06-23 19:53:51 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
#include "opal/mca/crs/crs.h"
|
|
|
|
#include "opal/mca/crs/base/base.h"
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
#define MCA_MPOOL_FLAGS_CACHE_BYPASS 0x1
|
2005-09-04 08:20:55 +04:00
|
|
|
#define MCA_MPOOL_FLAGS_PERSIST 0x2
|
2005-09-17 02:22:03 +04:00
|
|
|
#define MCA_MPOOL_FLAGS_MPI_ALLOC_MEM 0x4
|
2008-01-08 11:55:42 +03:00
|
|
|
#define MCA_MPOOL_FLAGS_INVALID 0x8
|
2009-03-13 04:01:00 +03:00
|
|
|
#define MCA_MPOOL_FLAGS_SO_MEM 0x10
|
2005-06-26 04:47:51 +04:00
|
|
|
|
2005-06-23 19:53:51 +04:00
|
|
|
struct mca_mpool_base_resources_t;
|
2005-06-25 01:12:38 +04:00
|
|
|
|
2005-06-30 22:19:56 +04:00
|
|
|
struct mca_mpool_base_registration_t {
|
2006-06-14 21:43:50 +04:00
|
|
|
ompi_free_list_item_t super;
|
2005-06-25 01:12:38 +04:00
|
|
|
struct mca_mpool_base_module_t *mpool;
|
2005-06-30 22:19:56 +04:00
|
|
|
unsigned char* base;
|
|
|
|
unsigned char* bound;
|
2005-09-27 06:01:21 +04:00
|
|
|
unsigned char* alloc_base;
|
2006-01-19 21:47:32 +03:00
|
|
|
int32_t ref_count;
|
2005-09-04 08:20:55 +04:00
|
|
|
uint32_t flags;
|
2005-06-25 01:12:38 +04:00
|
|
|
};
|
2005-09-04 08:20:55 +04:00
|
|
|
|
2005-06-25 01:12:38 +04:00
|
|
|
typedef struct mca_mpool_base_registration_t mca_mpool_base_registration_t;
|
2005-06-26 04:47:51 +04:00
|
|
|
|
|
|
|
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_mpool_base_registration_t);
|
2004-06-15 23:07:45 +04:00
|
|
|
|
2004-08-02 04:24:22 +04:00
|
|
|
/**
|
|
|
|
* component initialize
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef struct mca_mpool_base_module_t* (*mca_mpool_base_component_init_fn_t)(
|
2005-06-23 19:53:51 +04:00
|
|
|
struct mca_mpool_base_resources_t*);
|
2004-06-18 00:57:47 +04:00
|
|
|
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
|
|
|
* allocate function typedef
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void* (*mca_mpool_base_module_alloc_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
size_t size,
|
|
|
|
size_t align,
|
2005-09-13 02:28:23 +04:00
|
|
|
uint32_t flags,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
|
|
|
* realloc function typedef
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void* (*mca_mpool_base_module_realloc_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
void* addr,
|
|
|
|
size_t size,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
|
|
|
* free function typedef
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef void (*mca_mpool_base_module_free_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
2005-06-22 20:46:56 +04:00
|
|
|
void *addr,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t* registration);
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
|
|
|
* register memory
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef int (*mca_mpool_base_module_register_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
void * addr,
|
|
|
|
size_t size,
|
2005-09-13 02:28:23 +04:00
|
|
|
uint32_t flags,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t** registration);
|
2005-06-23 00:09:54 +04:00
|
|
|
|
2004-06-15 23:07:45 +04:00
|
|
|
/**
|
|
|
|
* deregister memory
|
|
|
|
*/
|
2005-06-21 21:10:28 +04:00
|
|
|
typedef int (*mca_mpool_base_module_deregister_fn_t)(
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t* registration);
|
2005-06-21 21:10:28 +04:00
|
|
|
|
2005-09-04 08:20:55 +04:00
|
|
|
/**
|
2006-12-17 15:26:41 +03:00
|
|
|
* find registration in this memory pool
|
2005-09-04 08:20:55 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef int (*mca_mpool_base_module_find_fn_t) (
|
2006-12-17 15:26:41 +03:00
|
|
|
struct mca_mpool_base_module_t* mpool, void* addr, size_t size,
|
|
|
|
mca_mpool_base_registration_t **reg);
|
2005-09-13 02:28:23 +04:00
|
|
|
|
2005-09-04 08:20:55 +04:00
|
|
|
/**
|
|
|
|
* release registration
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef int (*mca_mpool_base_module_release_fn_t) (
|
|
|
|
struct mca_mpool_base_module_t* mpool,
|
|
|
|
mca_mpool_base_registration_t* registration);
|
|
|
|
|
|
|
|
|
2006-12-17 15:26:41 +03:00
|
|
|
/**
|
|
|
|
* release memory region
|
|
|
|
*/
|
|
|
|
typedef int (*mca_mpool_base_module_release_memory_fn_t) (
|
|
|
|
struct mca_mpool_base_module_t* mpool, void *base, size_t size);
|
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
/**
|
|
|
|
* if appropriate - returns base address of memory pool
|
|
|
|
*/
|
|
|
|
typedef void* (*mca_mpool_base_module_address_fn_t)(struct mca_mpool_base_module_t* mpool);
|
2004-06-16 19:41:29 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* finalize
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
typedef void (*mca_mpool_base_module_finalize_fn_t)(struct mca_mpool_base_module_t*);
|
2004-06-15 23:07:45 +04:00
|
|
|
|
2004-06-16 19:41:29 +04:00
|
|
|
|
2007-03-17 02:11:45 +03:00
|
|
|
/**
|
|
|
|
* Fault Tolerance Event Notification Function
|
|
|
|
* @param state Checkpoint Stae
|
|
|
|
* @return OMPI_SUCCESS or failure status
|
|
|
|
*/
|
|
|
|
typedef int (*mca_mpool_base_module_ft_event_fn_t)(int state);
|
|
|
|
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* mpool component descriptor. Contains component version information
|
|
|
|
* and open/close/init functions.
|
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
struct mca_mpool_base_component_2_0_0_t {
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_base_component_t mpool_version; /**< version */
|
2008-07-29 02:40:57 +04:00
|
|
|
mca_base_component_data_t mpool_data;/**< metadata */
|
2004-08-02 04:24:22 +04:00
|
|
|
|
|
|
|
mca_mpool_base_component_init_fn_t mpool_init; /**< init function */
|
2004-06-16 19:41:29 +04:00
|
|
|
};
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef.
|
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
typedef struct mca_mpool_base_component_2_0_0_t mca_mpool_base_component_2_0_0_t;
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef
|
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
typedef struct mca_mpool_base_component_2_0_0_t mca_mpool_base_component_t;
|
2004-06-16 19:41:29 +04:00
|
|
|
|
|
|
|
/**
|
2004-08-17 03:06:33 +04:00
|
|
|
* mpool module descriptor. Contains the interface functions exported
|
|
|
|
* by the component. This does not expose memory management
|
|
|
|
* details.
|
2004-06-16 19:41:29 +04:00
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
struct mca_mpool_base_module_t {
|
2004-07-13 00:05:29 +04:00
|
|
|
mca_mpool_base_component_t *mpool_component; /**< component stuct */
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_mpool_base_module_address_fn_t mpool_base; /**< returns the base address */
|
|
|
|
mca_mpool_base_module_alloc_fn_t mpool_alloc; /**< allocate function */
|
|
|
|
mca_mpool_base_module_realloc_fn_t mpool_realloc; /**< reallocate function */
|
|
|
|
mca_mpool_base_module_free_fn_t mpool_free; /**< free function */
|
|
|
|
mca_mpool_base_module_register_fn_t mpool_register; /**< register memory */
|
|
|
|
mca_mpool_base_module_deregister_fn_t mpool_deregister; /**< deregister memory */
|
2005-09-04 08:20:55 +04:00
|
|
|
mca_mpool_base_module_find_fn_t mpool_find; /**< find regisrations in the cache */
|
2006-06-14 21:43:50 +04:00
|
|
|
mca_mpool_base_module_release_fn_t mpool_release; /**< release a registration from the cache */
|
2006-12-17 15:26:41 +03:00
|
|
|
mca_mpool_base_module_release_memory_fn_t mpool_release_memory; /**< release memor region from the cache */
|
2004-08-02 04:24:22 +04:00
|
|
|
mca_mpool_base_module_finalize_fn_t mpool_finalize; /**< finalize */
|
2007-03-17 02:11:45 +03:00
|
|
|
mca_mpool_base_module_ft_event_fn_t mpool_ft_event; /**< ft_event */
|
2005-09-13 02:28:23 +04:00
|
|
|
struct mca_rcache_base_module_t *rcache; /* the rcache associated with this mpool */
|
2005-09-17 02:22:03 +04:00
|
|
|
uint32_t flags; /**< mpool flags */
|
2004-06-15 23:07:45 +04:00
|
|
|
};
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
|
|
|
* Convenience typedef
|
|
|
|
*/
|
2004-08-02 04:24:22 +04:00
|
|
|
typedef struct mca_mpool_base_module_t mca_mpool_base_module_t;
|
2004-06-15 23:07:45 +04:00
|
|
|
|
2005-06-25 01:12:38 +04:00
|
|
|
|
2005-05-31 23:07:27 +04:00
|
|
|
/**
|
|
|
|
* Function to allocate special memory according to what the user requests in
|
|
|
|
* the info object.
|
|
|
|
*
|
|
|
|
* If the user passes in a valid info structure then the function will
|
|
|
|
* try to allocate the memory and register it with every mpool that there is a
|
|
|
|
* key for it in the info struct. If it fails at registering the memory with
|
|
|
|
* one of the requested mpools, an error will be returned. Also, if there is a
|
|
|
|
* key in info that does not match any mpool, an error will be returned.
|
|
|
|
*
|
|
|
|
* If the info parameter is MPI_INFO_NULL, then this function will try to allocate
|
|
|
|
* the memory and register it wih as many mpools as possible. However,
|
|
|
|
* if any of the registratons fail the mpool will simply be ignored.
|
|
|
|
*
|
|
|
|
* @param size the size of the memory area to allocate
|
|
|
|
* @param info an info object which tells us what kind of memory to allocate
|
|
|
|
*
|
|
|
|
* @retval pointer to the allocated memory
|
|
|
|
* @retval NULL on failure
|
|
|
|
*/
|
2005-06-25 01:12:38 +04:00
|
|
|
OMPI_DECLSPEC void * mca_mpool_base_alloc(size_t size, struct ompi_info_t * info);
|
2005-05-31 23:07:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function to free memory previously allocated by mca_mpool_base_alloc
|
|
|
|
*
|
|
|
|
* @param base pointer to the memory to free
|
|
|
|
*
|
|
|
|
* @retval OMPI_SUCCESS
|
|
|
|
* @retval OMPI_ERR_BAD_PARAM if the passed base pointer was invalid
|
|
|
|
*/
|
2005-06-22 01:20:23 +04:00
|
|
|
OMPI_DECLSPEC int mca_mpool_base_free(void * base);
|
2005-05-31 23:07:27 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function for the red black tree to compare 2 keys
|
|
|
|
*
|
|
|
|
* @param key1 a pointer to the 1st key
|
|
|
|
* @param key2 a pointer to the second key
|
|
|
|
*
|
|
|
|
* @retval -1 if key1 is below key2
|
|
|
|
* @retval 1 if key 1 is above key2
|
|
|
|
* @retval 0 if the keys are the same
|
|
|
|
*/
|
|
|
|
OMPI_DECLSPEC int mca_mpool_base_tree_node_compare(void * key1, void * key2);
|
|
|
|
|
2005-06-20 23:47:54 +04:00
|
|
|
|
2005-06-21 21:10:28 +04:00
|
|
|
OMPI_DECLSPEC int mca_mpool_base_insert(
|
|
|
|
void * addr,
|
|
|
|
size_t size,
|
|
|
|
mca_mpool_base_module_t* mpool,
|
2005-06-23 19:53:51 +04:00
|
|
|
void* user_in,
|
2005-06-25 01:12:38 +04:00
|
|
|
mca_mpool_base_registration_t* registration);
|
2005-06-20 23:47:54 +04:00
|
|
|
|
2005-06-21 19:03:59 +04:00
|
|
|
OMPI_DECLSPEC int mca_mpool_base_remove(void * base);
|
|
|
|
|
2004-07-13 00:05:29 +04:00
|
|
|
/**
|
2008-07-29 02:40:57 +04:00
|
|
|
* Macro for use in components that are of type mpool
|
2004-06-16 19:41:29 +04:00
|
|
|
*/
|
2008-07-29 02:40:57 +04:00
|
|
|
#define MCA_MPOOL_BASE_VERSION_2_0_0 \
|
|
|
|
MCA_BASE_VERSION_2_0_0, \
|
|
|
|
"mpool", 2, 0, 0
|
2004-06-15 23:07:45 +04:00
|
|
|
|
|
|
|
#endif /* MCA_MPOOL_H */
|
|
|
|
|