OpenMPI
0.1.1
|
Implementation for taking care of the attribute that can hang off a comm, win or datatype. More...
#include <string.h>
#include "mpi.h"
#include "ompi_config.h"
#include "ompi/constants.h"
#include "opal/class/opal_object.h"
#include "opal/class/opal_hash_table.h"
Go to the source code of this file.
Data Structures | |
union | ompi_attribute_fn_ptr_union_t |
union | ompi_attribute_fortran_ptr_t |
Union to help convert between Fortran attributes (which must be stored by value) and C pointers (which is the back-end storage of all attributes). More... | |
struct | ompi_attribute_keyval_t |
Macros | |
#define | ATTR_HASH_SIZE 10 |
#define | OMPI_KEYVAL_PREDEFINED 0x0001 |
#define | OMPI_KEYVAL_F77 0x0002 |
#define | OMPI_KEYVAL_F77_MPI1 0x0004 |
Typedefs | |
typedef enum ompi_attribute_type_t | ompi_attribute_type_t |
typedef void( | ompi_mpi1_fortran_copy_attr_function )(MPI_Fint *oldobj, MPI_Fint *keyval, MPI_Fint *extra_state, MPI_Fint *attr_in, MPI_Fint *attr_out, ompi_fortran_logical_t *flag, MPI_Fint *ierr) |
typedef void( | ompi_mpi1_fortran_delete_attr_function )(MPI_Fint *obj, MPI_Fint *keyval, MPI_Fint *attr_in, MPI_Fint *extra_state, MPI_Fint *ierr) |
typedef void( | ompi_mpi2_fortran_copy_attr_function )(MPI_Fint *oldobj, MPI_Fint *keyval, void *extra_state, void *attr_in, void *attr_out, ompi_fortran_logical_t *flag, MPI_Fint *ierr) |
typedef void( | ompi_mpi2_fortran_delete_attr_function )(MPI_Fint *obj, MPI_Fint *keyval, void *attr_in, void *extra_state, MPI_Fint *ierr) |
typedef int( | MPI_Comm_internal_copy_attr_function )(MPI_Comm, int, void *, void *, void *, int *, MPI_Comm) |
typedef int( | MPI_Type_internal_copy_attr_function )(MPI_Datatype, int, void *, void *, void *, int *, MPI_Datatype) |
typedef int( | MPI_Win_internal_copy_attr_function )(MPI_Win, int, void *, void *, void *, int *, MPI_Win) |
typedef void( | ompi_attribute_keyval_destructor_fn_t )(int) |
typedef union ompi_attribute_fn_ptr_union_t | ompi_attribute_fn_ptr_union_t |
typedef union ompi_attribute_fortran_ptr_t | ompi_attribute_fortran_ptr_t |
Convenience typedef. | |
typedef struct ompi_attribute_keyval_t | ompi_attribute_keyval_t |
Enumerations | |
enum | ompi_attribute_type_t { UNUSED_ATTR = 0, COMM_ATTR, TYPE_ATTR, WIN_ATTR } |
Functions | |
static int | ompi_attr_hash_init (opal_hash_table_t **hash) |
Convenient way to initialize the attribute hash table per MPI-Object. | |
int | ompi_attr_init (void) |
Initialize the main attribute hash that stores the keyvals and meta data. More... | |
int | ompi_attr_finalize (void) |
Destroy the main attribute hash that stores the keyvals and meta data. | |
OMPI_DECLSPEC int | ompi_attr_create_keyval (ompi_attribute_type_t type, ompi_attribute_fn_ptr_union_t copy_attr_fn, ompi_attribute_fn_ptr_union_t delete_attr_fn, int *key, void *extra_state, int flags, void *bindings_extra_state) |
Create a new key for use by attribute of Comm/Win/Datatype. More... | |
OMPI_DECLSPEC int | ompi_attr_create_keyval_fint (ompi_attribute_type_t type, ompi_attribute_fn_ptr_union_t copy_attr_fn, ompi_attribute_fn_ptr_union_t delete_attr_fn, int *key, MPI_Fint extra_state, int flags, void *bindings_extra_state) |
Same as ompi_attr_create_keyval, but extra_state is a Fortran default integer. | |
OMPI_DECLSPEC int | ompi_attr_create_keyval_aint (ompi_attribute_type_t type, ompi_attribute_fn_ptr_union_t copy_attr_fn, ompi_attribute_fn_ptr_union_t delete_attr_fn, int *key, MPI_Aint extra_state, int flags, void *bindings_extra_state) |
Same as ompi_attr_create_keyval, but extra_state is a Fortran address integer. | |
int | ompi_attr_free_keyval (ompi_attribute_type_t type, int *key, bool predefined) |
Free an attribute keyval. More... | |
int | ompi_attr_set_c (ompi_attribute_type_t type, void *object, opal_hash_table_t **attr_hash, int key, void *attribute, bool predefined) |
Set an attribute on the comm/win/datatype in a form valid for C. More... | |
OMPI_DECLSPEC int | ompi_attr_set_fortran_mpi1 (ompi_attribute_type_t type, void *object, opal_hash_table_t **attr_hash, int key, MPI_Fint attribute, bool predefined) |
Set an attribute on the comm/win/datatype in a form valid for Fortran MPI-1. More... | |
OMPI_DECLSPEC int | ompi_attr_set_fortran_mpi2 (ompi_attribute_type_t type, void *object, opal_hash_table_t **attr_hash, int key, MPI_Aint attribute, bool predefined) |
Set an attribute on the comm/win/datatype in a form valid for Fortran MPI-2. More... | |
int | ompi_attr_get_c (opal_hash_table_t *attr_hash, int key, void **attribute, int *flag) |
Get an attribute on the comm/win/datatype in a form valid for C. More... | |
OMPI_DECLSPEC int | ompi_attr_get_fortran_mpi1 (opal_hash_table_t *attr_hash, int key, MPI_Fint *attribute, int *flag) |
Get an attribute on the comm/win/datatype in a form valid for Fortran MPI-1. More... | |
OMPI_DECLSPEC int | ompi_attr_get_fortran_mpi2 (opal_hash_table_t *attr_hash, int key, MPI_Aint *attribute, int *flag) |
Get an attribute on the comm/win/datatype in a form valid for Fortran MPI-2. More... | |
int | ompi_attr_delete (ompi_attribute_type_t type, void *object, opal_hash_table_t *attr_hash, int key, bool predefined) |
Delete an attribute on the comm/win/datatype. More... | |
int | ompi_attr_copy_all (ompi_attribute_type_t type, void *old_object, void *new_object, opal_hash_table_t *oldattr_hash, opal_hash_table_t *newkeyhash) |
This to be used from functions like MPI_*_DUP inorder to copy all the attributes from the old Comm/Win/Dtype object to a new object. More... | |
int | ompi_attr_delete_all (ompi_attribute_type_t type, void *object, opal_hash_table_t *attr_hash) |
This to be used to delete all the attributes from the Comm/Win/Dtype object in one shot. More... | |
int | ompi_attr_create_predefined (void) |
int | ompi_attr_free_predefined (void) |
Implementation for taking care of the attribute that can hang off a comm, win or datatype.
int ompi_attr_copy_all | ( | ompi_attribute_type_t | type, |
void * | old_object, | ||
void * | new_object, | ||
opal_hash_table_t * | oldattr_hash, | ||
opal_hash_table_t * | newkeyhash | ||
) |
This to be used from functions like MPI_*_DUP inorder to copy all the attributes from the old Comm/Win/Dtype object to a new object.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
old_object | The old COMM/WIN/DTYPE object (IN) |
new_object | The new COMM/WIN/DTYPE object (IN) |
attr_hash | The attribute hash table hanging on old object(IN) |
newattr_hash | The attribute hash table hanging on new object(IN) |
References ompi_attribute_keyval_t::attr_flag, COMM_ATTR, OBJ_RELEASE, opal_hash_table_get_first_key_uint32(), opal_hash_table_get_next_key_uint32(), opal_hash_table_get_value_uint32(), OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, TYPE_ATTR, UNUSED_ATTR, and WIN_ATTR.
OMPI_DECLSPEC int ompi_attr_create_keyval | ( | ompi_attribute_type_t | type, |
ompi_attribute_fn_ptr_union_t | copy_attr_fn, | ||
ompi_attribute_fn_ptr_union_t | delete_attr_fn, | ||
int * | key, | ||
void * | extra_state, | ||
int | flags, | ||
void * | bindings_extra_state | ||
) |
Create a new key for use by attribute of Comm/Win/Datatype.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
copy_attr_fn | Union variable containing the function pointer to be used in order to copy the attribute (IN) |
delete_attr_fn | Function pointer to be used for deleting the attribute (IN) |
key | The newly created key is returned here (OUT) |
extra_state | Extra state to hang off/do some special things (IN) |
flags | Flags for the key – flags contain OMPI_KEYVAL_F77, OMPI_KEYVAL_PREDEFINED |
bindings_extra_state | Extra state that, if non-NULL, will automatically be free()'ed by the C base when the keyval is destroyed. |
NOTE: I have taken the assumption that user cannot modify/delete any predefined keys or the attributes attached. To accomplish this, all MPI* calls will have OMPI_KEYVAL_PREDEFINED set as 0. MPI implementors who will need to play with the predefined keys and attributes would call the ompi* functions here and not the MPI* functions, with OMPI_KEYVAL_PREDEFINED set to 1. END OF NOTE
NOTE: For the function pointers, you need to create a variable of the union type "ompi_attribute_fn_ptr_union_t" and assign the proper field. to be passed into this function END OF NOTE
int ompi_attr_delete | ( | ompi_attribute_type_t | type, |
void * | object, | ||
opal_hash_table_t * | attr_hash, | ||
int | key, | ||
bool | predefined | ||
) |
Delete an attribute on the comm/win/datatype.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
object | The actual Comm/Win/Datatype object (IN) |
attr_hash | The attribute hash table hanging on the object(IN) |
key | Key val for the attribute (IN) |
predefined | Whether the key is predefined or not 0/1 (IN) |
References ompi_attribute_keyval_t::attr_flag, ompi_attribute_keyval_t::attr_type, COMM_ATTR, OBJ_RELEASE, opal_hash_table_get_value_uint32(), opal_hash_table_remove_value_uint32(), OPAL_THREAD_LOCK, OPAL_THREAD_UNLOCK, TYPE_ATTR, and WIN_ATTR.
Referenced by ompi_attr_delete_all().
int ompi_attr_delete_all | ( | ompi_attribute_type_t | type, |
void * | object, | ||
opal_hash_table_t * | attr_hash | ||
) |
This to be used to delete all the attributes from the Comm/Win/Dtype object in one shot.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
object | The COMM/WIN/DTYPE object (IN) |
attr_hash | The attribute hash table hanging on the object(IN) |
References ompi_attr_delete(), opal_hash_table_get_first_key_uint32(), opal_hash_table_get_next_key_uint32(), OPAL_THREAD_LOCK, and OPAL_THREAD_UNLOCK.
Referenced by ompi_mpi_finalize().
int ompi_attr_free_keyval | ( | ompi_attribute_type_t | type, |
int * | key, | ||
bool | predefined | ||
) |
Free an attribute keyval.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
key | key, which is set to MPI_KEY_INVALID (IN/OUT) |
References ompi_attribute_keyval_t::attr_flag, ompi_attribute_keyval_t::attr_type, OBJ_RELEASE, opal_hash_table_get_value_uint32(), OPAL_THREAD_LOCK, and OPAL_THREAD_UNLOCK.
int ompi_attr_get_c | ( | opal_hash_table_t * | attr_hash, |
int | key, | ||
void ** | attribute, | ||
int * | flag | ||
) |
Get an attribute on the comm/win/datatype in a form valid for C.
attr_hash | The attribute hash table hanging on the object(IN) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (OUT) |
flag | Flag whether an attribute is associated with the key (OUT) |
All three of these functions (ompi_attr_get_c(), ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.
OMPI_DECLSPEC int ompi_attr_get_fortran_mpi1 | ( | opal_hash_table_t * | attr_hash, |
int | key, | ||
MPI_Fint * | attribute, | ||
int * | flag | ||
) |
Get an attribute on the comm/win/datatype in a form valid for Fortran MPI-1.
attr_hash | The attribute hash table hanging on the object(IN) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (OUT) |
flag | Flag whether an attribute is associated with the key (OUT) |
All three of these functions (ompi_attr_get_c(), ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.
OMPI_DECLSPEC int ompi_attr_get_fortran_mpi2 | ( | opal_hash_table_t * | attr_hash, |
int | key, | ||
MPI_Aint * | attribute, | ||
int * | flag | ||
) |
Get an attribute on the comm/win/datatype in a form valid for Fortran MPI-2.
attrhash | The attribute hash table hanging on the object(IN) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (OUT) |
flag | Flag whether an attribute is associated with the key (OUT) |
All three of these functions (ompi_attr_get_c(), ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.
int ompi_attr_init | ( | void | ) |
Initialize the main attribute hash that stores the keyvals and meta data.
References OBJ_CONSTRUCT, opal_bitmap_init(), opal_bitmap_set_max_size(), and opal_hash_table_init().
Referenced by ompi_mpi_init().
int ompi_attr_set_c | ( | ompi_attribute_type_t | type, |
void * | object, | ||
opal_hash_table_t ** | attr_hash, | ||
int | key, | ||
void * | attribute, | ||
bool | predefined | ||
) |
Set an attribute on the comm/win/datatype in a form valid for C.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
object | The actual Comm/Win/Datatype object (IN) |
attr_hash | The attribute hash table hanging on the object(IN/OUT) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (IN) |
predefined | Whether the key is predefined or not 0/1 (IN) |
If (*attr_hash) == NULL, a new hash will be created and initialized.
All three of these functions (ompi_attr_set_c(), ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.
OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1 | ( | ompi_attribute_type_t | type, |
void * | object, | ||
opal_hash_table_t ** | attr_hash, | ||
int | key, | ||
MPI_Fint | attribute, | ||
bool | predefined | ||
) |
Set an attribute on the comm/win/datatype in a form valid for Fortran MPI-1.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
object | The actual Comm/Win/Datatype object (IN) |
attr_hash | The attribute hash table hanging on the object(IN/OUT) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (IN) |
predefined | Whether the key is predefined or not 0/1 (IN) |
If (*attr_hash) == NULL, a new hash will be created and initialized.
All three of these functions (ompi_attr_set_c(), ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.
OMPI_DECLSPEC int ompi_attr_set_fortran_mpi2 | ( | ompi_attribute_type_t | type, |
void * | object, | ||
opal_hash_table_t ** | attr_hash, | ||
int | key, | ||
MPI_Aint | attribute, | ||
bool | predefined | ||
) |
Set an attribute on the comm/win/datatype in a form valid for Fortran MPI-2.
type | Type of attribute (COMM/WIN/DTYPE) (IN) |
object | The actual Comm/Win/Datatype object (IN) |
attr_hash | The attribute hash table hanging on the object(IN/OUT) |
key | Key val for the attribute (IN) |
attribute | The actual attribute pointer (IN) |
predefined | Whether the key is predefined or not 0/1 (IN) |
If (*attr_hash) == NULL, a new hash will be created and initialized.
All three of these functions (ompi_attr_set_c(), ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2()) could have been combined into one function that took some kind of (void*) and an enum to indicate which way to translate the final representation, but that just seemed to make an already complicated situation more complicated through yet another layer of indirection.
So yes, this is more code, but it's clearer and less error-prone (read: better) this way.