|
OpenMPI
0.1.1
|
Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana University Research and Technology Corporation. More...
#include "ompi_config.h"#include <stdlib.h>#include <string.h>#include "opal/threads/mutex.h"#include "ompi/mca/allocator/allocator.h"Go to the source code of this file.
Data Structures | |
| struct | mca_allocator_bucket_chunk_header_t |
| Structure for the header of each memory chunk. More... | |
| union | mca_allocator_bucket_chunk_header_t::u |
| Union which holds either a pointer to the next free chunk or the bucket number. More... | |
| struct | mca_allocator_bucket_segment_head_t |
| Structure that heads each segment. More... | |
| struct | mca_allocator_bucket_bucket_t |
| Structure for each bucket. More... | |
| struct | mca_allocator_bucket_t |
| Structure that holds the necessary information for each area of memory. More... | |
Typedefs | |
|
typedef struct mca_allocator_bucket_chunk_header_t | mca_allocator_bucket_chunk_header_t |
| Typedef so we don't have to use struct. | |
|
typedef struct mca_allocator_bucket_segment_head_t | mca_allocator_bucket_segment_head_t |
| Typedef so we don't have to use struct. | |
|
typedef struct mca_allocator_bucket_bucket_t | mca_allocator_bucket_bucket_t |
| Typedef so we don't have to use struct. | |
|
typedef struct mca_allocator_bucket_t | mca_allocator_bucket_t |
| Typedef so we don't have to use struct. | |
Functions | |
| mca_allocator_bucket_t * | mca_allocator_bucket_init (mca_allocator_base_module_t *mem, int num_buckets, mca_allocator_base_component_segment_alloc_fn_t get_mem_funct, mca_allocator_base_component_segment_free_fn_t free_mem_funct) |
| Initializes the mca_allocator_bucket_options_t data structure for the passed parameters. More... | |
| void * | mca_allocator_bucket_alloc (mca_allocator_base_module_t *mem, size_t size, mca_mpool_base_registration_t **registration) |
| Accepts a request for memory in a specific region defined by the mca_allocator_bucket_options_t struct and returns a pointer to memory in that region or NULL if there was an error. More... | |
| void * | mca_allocator_bucket_alloc_align (mca_allocator_base_module_t *mem, size_t size, size_t alignment, mca_mpool_base_registration_t **registration) |
| Accepts a request for memory in a specific region defined by the mca_allocator_bucket_options_t struct and aligned by the specified amount and returns a pointer to memory in that region or NULL if there was an error. More... | |
| void * | mca_allocator_bucket_realloc (mca_allocator_base_module_t *mem, void *ptr, size_t size, mca_mpool_base_registration_t **registration) |
| Attempts to resize the passed region of memory into a larger or a smaller region. More... | |
| void | mca_allocator_bucket_free (mca_allocator_base_module_t *mem, void *ptr) |
| Frees the passed region of memory. More... | |
| int | mca_allocator_bucket_cleanup (mca_allocator_base_module_t *mem) |
| Frees all the memory from all the buckets back to the system. More... | |
| int | mca_allocator_bucket_finalize (mca_allocator_base_module_t *mem) |
| Cleanup all resources held by this allocator. More... | |
Variables | |
|
OMPI_DECLSPEC mca_allocator_base_component_t | mca_allocator_bucket_component |
Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana University Research and Technology Corporation.
All rights reserved. Copyright (c) 2004-2005 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$
Additional copyrights may follow
$HEADER$ A generic memory bucket allocator.
| void* mca_allocator_bucket_alloc | ( | mca_allocator_base_module_t * | mem, |
| size_t | size, | ||
| mca_mpool_base_registration_t ** | registration | ||
| ) |
Accepts a request for memory in a specific region defined by the mca_allocator_bucket_options_t struct and returns a pointer to memory in that region or NULL if there was an error.
| mem | A pointer to the appropriate struct for the area of memory. |
| size | The size of the requested area of memory |
| Pointer | to the area of memory if the allocation was successful |
| NULL | if the allocation was unsuccessful |
References mca_allocator_bucket_chunk_header_t::u::bucket, mca_allocator_bucket_t::buckets, mca_allocator_bucket_segment_head_t::first_chunk, mca_allocator_bucket_bucket_t::free_chunk, mca_allocator_bucket_t::get_mem_fn, mca_allocator_bucket_bucket_t::lock, mca_allocator_bucket_chunk_header_t::u::next_free, mca_allocator_bucket_chunk_header_t::next_in_segment, mca_allocator_bucket_segment_head_t::next_segment, OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, mca_allocator_bucket_bucket_t::segment_head, mca_allocator_bucket_t::super, and mca_allocator_bucket_chunk_header_t::u.
Referenced by mca_allocator_bucket_realloc().
| void* mca_allocator_bucket_alloc_align | ( | mca_allocator_base_module_t * | mem, |
| size_t | size, | ||
| size_t | alignment, | ||
| mca_mpool_base_registration_t ** | registration | ||
| ) |
Accepts a request for memory in a specific region defined by the mca_allocator_bucket_options_t struct and aligned by the specified amount and returns a pointer to memory in that region or NULL if there was an error.
| mem | A pointer to the appropriate struct for the area of memory. |
| size | The size of the requested area of memory |
| alignment | The requested alignment of the new area of memory. This MUST be a power of 2. |
| Pointer | to the area of memory if the allocation was successful |
| NULL | if the allocation was unsuccessful |
References mca_allocator_bucket_chunk_header_t::u::bucket, mca_allocator_bucket_t::buckets, mca_allocator_bucket_segment_head_t::first_chunk, mca_allocator_bucket_bucket_t::free_chunk, mca_allocator_bucket_t::get_mem_fn, mca_allocator_bucket_bucket_t::lock, mca_allocator_bucket_chunk_header_t::u::next_free, mca_allocator_bucket_chunk_header_t::next_in_segment, mca_allocator_bucket_segment_head_t::next_segment, OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, mca_allocator_bucket_bucket_t::segment_head, mca_allocator_bucket_t::super, and mca_allocator_bucket_chunk_header_t::u.
| int mca_allocator_bucket_cleanup | ( | mca_allocator_base_module_t * | mem | ) |
Frees all the memory from all the buckets back to the system.
Note that this function only frees memory that was previously freed with mca_allocator_bucket_free().
| mem | A pointer to the appropriate struct for the area of memory. |
| None |
References mca_allocator_bucket_chunk_header_t::u::bucket, mca_allocator_bucket_t::buckets, mca_allocator_bucket_segment_head_t::first_chunk, mca_allocator_bucket_bucket_t::free_chunk, mca_allocator_bucket_t::free_mem_fn, mca_allocator_bucket_bucket_t::lock, mca_allocator_bucket_chunk_header_t::u::next_free, mca_allocator_bucket_chunk_header_t::next_in_segment, mca_allocator_bucket_segment_head_t::next_segment, mca_allocator_bucket_t::num_buckets, OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, mca_allocator_bucket_bucket_t::segment_head, and mca_allocator_bucket_chunk_header_t::u.
Referenced by mca_allocator_bucket_finalize().
| int mca_allocator_bucket_finalize | ( | mca_allocator_base_module_t * | mem | ) |
Cleanup all resources held by this allocator.
| mem | A pointer to the appropriate struct for the area of memory. |
| None |
References mca_allocator_bucket_cleanup().
| void mca_allocator_bucket_free | ( | mca_allocator_base_module_t * | mem, |
| void * | ptr | ||
| ) |
Frees the passed region of memory.
| mem | A pointer to the appropriate struct for the area of memory. |
| ptr | A pointer to the region of memory to be freed |
| None |
References mca_allocator_bucket_chunk_header_t::u::bucket, mca_allocator_bucket_t::buckets, mca_allocator_bucket_bucket_t::free_chunk, mca_allocator_bucket_bucket_t::lock, mca_allocator_bucket_chunk_header_t::u::next_free, OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, and mca_allocator_bucket_chunk_header_t::u.
Referenced by mca_allocator_bucket_realloc().
| mca_allocator_bucket_t* mca_allocator_bucket_init | ( | mca_allocator_base_module_t * | mem, |
| int | num_buckets, | ||
| mca_allocator_base_component_segment_alloc_fn_t | get_mem_funct, | ||
| mca_allocator_base_component_segment_free_fn_t | free_mem_funct | ||
| ) |
Initializes the mca_allocator_bucket_options_t data structure for the passed parameters.
| mem | a pointer to the mca_allocator_t struct to be filled in |
| num_buckets | The number of buckets the allocator will use |
| get_mem_funct | A pointer to the function that the allocator will use to get more memory |
| free_mem_funct | A pointer to the function that the allocator will use to free memory |
| Pointer | to the initialized mca_allocator_bucket_options_t structure |
| NULL | if there was an error |
References mca_allocator_bucket_t::buckets, mca_allocator_bucket_bucket_t::free_chunk, mca_allocator_bucket_t::free_mem_fn, mca_allocator_bucket_t::get_mem_fn, mca_allocator_bucket_bucket_t::lock, mca_allocator_bucket_t::num_buckets, OBJ_CONSTRUCT, and mca_allocator_bucket_bucket_t::segment_head.
| void* mca_allocator_bucket_realloc | ( | mca_allocator_base_module_t * | mem, |
| void * | ptr, | ||
| size_t | size, | ||
| mca_mpool_base_registration_t ** | registration | ||
| ) |
Attempts to resize the passed region of memory into a larger or a smaller region.
If it is unsuccessful, it will return NULL and the passed area of memory will be untouched.
| mem | A pointer to the appropriate struct for the area of memory. |
| size | The size of the requested area of memory |
| ptr | A pointer to the region of memory to be resized |
| Pointer | to the area of memory if the reallocation was successful |
| NULL | if the allocation was unsuccessful |
References mca_allocator_bucket_chunk_header_t::u::bucket, mca_allocator_bucket_alloc(), mca_allocator_bucket_free(), and mca_allocator_bucket_chunk_header_t::u.