d4afb16f5a
This commit rewrites both the mpool and rcache frameworks. Summary of changes: - Before this change a significant portion of the rcache functionality lived in mpool components. This meant that it was impossible to add a new memory pool to use with rdma networks (ugni, openib, etc) without duplicating the functionality of an existing mpool component. All the registration functionality has been removed from the mpool and placed in the rcache framework. - All registration cache mpools components (udreg, grdma, gpusm, rgpusm) have been changed to rcache components. rcaches are allocated and released in the same way mpool components were. - It is now valid to pass NULL as the resources argument when creating an rcache. At this time the gpusm and rgpusm components support this. All other rcache components require non-NULL resources. - A new mpool component has been added: hugepage. This component supports huge page allocations on linux. - Memory pools are now allocated using "hints". Each mpool component is queried with the hints and returns a priority. The current hints supported are NULL (uses posix_memalign/malloc), page_size=x (huge page mpool), and mpool=x. - The sm mpool has been moved to common/sm. This reflects that the sm mpool is specialized and not meant for any general allocations. This mpool may be moved back into the mpool framework if there is any objection. - The opal_free_list_init arguments have been updated. The unused0 argument is not used to pass in the registration cache module. The mpool registration flags are now rcache registration flags. - All components have been updated to make use of the new framework interfaces. As this commit makes significant changes to both the mpool and rcache frameworks both versions have been bumped to 3.0.0. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
154 строки
4.4 KiB
C
154 строки
4.4 KiB
C
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
|
|
/*
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
* University Research and Technology
|
|
* Corporation. All rights reserved.
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
* of Tennessee Research Foundation. 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 (c) 2015 Los Alamos National Security, LLC. All rights
|
|
* reserved.
|
|
* $COPYRIGHT$
|
|
*
|
|
* Additional copyrights may follow
|
|
*
|
|
* $HEADER$
|
|
*/
|
|
/**
|
|
* @file
|
|
* The public definition of the MCA Allocator framework.
|
|
*/
|
|
#ifndef MCA_ALLOCATOR_H
|
|
#define MCA_ALLOCATOR_H
|
|
|
|
#include "opal_config.h"
|
|
#include "opal/mca/mca.h"
|
|
|
|
BEGIN_C_DECLS
|
|
|
|
/* Here so that we can use mca_allocator_base_module_t in the function typedefs */
|
|
struct mca_allocator_base_module_t;
|
|
|
|
/**
|
|
* The allocate function typedef for the function to be provided by the component.
|
|
*/
|
|
typedef void* (*mca_allocator_base_module_alloc_fn_t)(
|
|
struct mca_allocator_base_module_t*,
|
|
size_t size,
|
|
size_t align);
|
|
|
|
/**
|
|
* The realloc function typedef
|
|
*/
|
|
typedef void* (*mca_allocator_base_module_realloc_fn_t)(
|
|
struct mca_allocator_base_module_t*,
|
|
void*, size_t);
|
|
|
|
/**
|
|
* Free function typedef
|
|
*/
|
|
typedef void(*mca_allocator_base_module_free_fn_t)(
|
|
struct mca_allocator_base_module_t*, void *);
|
|
|
|
|
|
/**
|
|
* compact/return memory to higher level allocator
|
|
*/
|
|
|
|
typedef int (*mca_allocator_base_module_compact_fn_t)(
|
|
struct mca_allocator_base_module_t* allocator
|
|
);
|
|
|
|
|
|
/**
|
|
* cleanup (free) any resources held by allocator
|
|
*/
|
|
|
|
typedef int (*mca_allocator_base_module_finalize_fn_t)(
|
|
struct mca_allocator_base_module_t* allocator
|
|
);
|
|
|
|
/**
|
|
* The data structure for each component.
|
|
*/
|
|
struct mca_allocator_base_module_t {
|
|
mca_allocator_base_module_alloc_fn_t alc_alloc;
|
|
/**< Allocate memory */
|
|
mca_allocator_base_module_realloc_fn_t alc_realloc;
|
|
/**< Reallocate memory */
|
|
mca_allocator_base_module_free_fn_t alc_free;
|
|
/**< Free memory */
|
|
mca_allocator_base_module_compact_fn_t alc_compact;
|
|
/**< Return memory */
|
|
mca_allocator_base_module_finalize_fn_t alc_finalize;
|
|
/**< Finalize and free everything */
|
|
/* memory pool and resources */
|
|
void *alc_context;
|
|
};
|
|
/**
|
|
* Convenience typedef.
|
|
*/
|
|
typedef struct mca_allocator_base_module_t mca_allocator_base_module_t;
|
|
|
|
|
|
/**
|
|
* A function to get more memory from the system. This function is to be
|
|
* provided by the module to the allocator framework.
|
|
*/
|
|
|
|
typedef void* (*mca_allocator_base_component_segment_alloc_fn_t)(void *ctx,
|
|
size_t *size);
|
|
|
|
/**
|
|
* A function to free memory from the control of the allocator framework
|
|
* back to the system. This function is to be provided by the module to the
|
|
* allocator framework.
|
|
*/
|
|
typedef void (*mca_allocator_base_component_segment_free_fn_t)(void *ctx,
|
|
void *segment);
|
|
|
|
|
|
/**
|
|
* The function used to initialize the component.
|
|
*/
|
|
typedef struct mca_allocator_base_module_t*
|
|
(*mca_allocator_base_component_init_fn_t)(
|
|
bool enable_mpi_threads,
|
|
mca_allocator_base_component_segment_alloc_fn_t segment_alloc,
|
|
mca_allocator_base_component_segment_free_fn_t segment_free,
|
|
void *context
|
|
);
|
|
|
|
/**
|
|
* The data structure provided by each component to the framework which
|
|
* describes the component.
|
|
*/
|
|
struct mca_allocator_base_component_2_0_0_t {
|
|
mca_base_component_t allocator_version;
|
|
/**< The version of the component */
|
|
mca_base_component_data_t allocator_data;
|
|
/**< The component metadata */
|
|
mca_allocator_base_component_init_fn_t allocator_init;
|
|
/**< The component initialization function. */
|
|
};
|
|
|
|
/**
|
|
* Convenience typedef.
|
|
*/
|
|
typedef struct mca_allocator_base_component_2_0_0_t mca_allocator_base_component_t;
|
|
|
|
/**
|
|
* Macro for use in components that are of type allocator
|
|
*/
|
|
#define MCA_ALLOCATOR_BASE_VERSION_2_0_0 \
|
|
OPAL_MCA_BASE_VERSION_2_1_0("allocator", 2, 0, 0)
|
|
|
|
END_C_DECLS
|
|
|
|
#endif /* MCA_ALLOCATOR_H */
|
|
|