2004-01-12 19:08:46 +03:00
|
|
|
/*
|
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-03-17 02:34:41 +03:00
|
|
|
/** @file
|
|
|
|
*
|
|
|
|
* Implementation for taking care of the attribute that can hang off a comm,
|
|
|
|
* win or datatype.
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#ifndef OMPI_ATTRIBUTE_H
|
|
|
|
#define OMPI_ATTRIBUTE_H
|
2004-01-12 19:08:46 +03:00
|
|
|
|
2004-03-17 02:34:41 +03:00
|
|
|
#include <string.h>
|
|
|
|
#include "mpi.h"
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
|
|
|
#include "class/ompi_object.h"
|
|
|
|
#include "class/ompi_bitmap.h"
|
|
|
|
#include "class/ompi_hash_table.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "communicator/communicator.h"
|
|
|
|
#include "datatype/datatype.h"
|
|
|
|
#include "win/win.h"
|
2004-03-17 02:34:41 +03:00
|
|
|
|
2004-05-30 20:21:44 +04:00
|
|
|
#define ATTR_HASH_SIZE 10
|
2004-03-17 02:34:41 +03:00
|
|
|
|
2004-06-16 19:17:43 +04:00
|
|
|
/* Flags for attribute will contain these */
|
2004-03-17 02:34:41 +03:00
|
|
|
|
2004-06-16 19:17:43 +04:00
|
|
|
#define OMPI_KEYVAL_PREDEFINED 1
|
|
|
|
#define OMPI_KEYVAL_F77 2
|
2004-03-17 02:34:41 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
enum ompi_attribute_type_t{
|
2004-03-17 02:34:41 +03:00
|
|
|
COMM_ATTR = 1, /**< The attribute belongs to a comm object. Starts
|
|
|
|
with 1 so that we can have it initialized to 0
|
|
|
|
using memset in the constructor */
|
|
|
|
WIN_ATTR, /**< The attribute belongs to a win object */
|
|
|
|
TYPE_ATTR /**< The attribute belongs to datatype object */
|
|
|
|
};
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef enum ompi_attribute_type_t ompi_attribute_type_t;
|
2004-01-12 19:08:46 +03:00
|
|
|
|
2004-06-16 19:17:43 +04:00
|
|
|
|
|
|
|
/* Fortran function pointer declarations for copy and delete. These
|
|
|
|
will only be used here and not in the front end functions */
|
|
|
|
|
|
|
|
typedef void (MPI_F_copy_function)(int *, int *, int *, int *, int *,
|
|
|
|
int *, int *);
|
|
|
|
typedef void (MPI_F_delete_function)(int *, int *, int *, int *, int *);
|
|
|
|
|
|
|
|
|
2004-05-30 20:21:44 +04:00
|
|
|
/* Union to take care of proper casting of the function pointers
|
|
|
|
passed from the front end functions depending on the type. This
|
|
|
|
will avoid casting function pointers to void* */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
union ompi_attribute_fn_ptr_union_t {
|
2004-05-30 20:21:44 +04:00
|
|
|
MPI_Comm_delete_attr_function *attr_communicator_delete_fn;
|
|
|
|
MPI_Type_delete_attr_function *attr_datatype_delete_fn;
|
|
|
|
MPI_Win_delete_attr_function *attr_win_delete_fn;
|
2004-06-16 19:17:43 +04:00
|
|
|
|
2004-05-30 20:21:44 +04:00
|
|
|
MPI_Comm_copy_attr_function *attr_communicator_copy_fn;
|
|
|
|
MPI_Type_copy_attr_function *attr_datatype_copy_fn;
|
|
|
|
MPI_Win_copy_attr_function *attr_win_copy_fn;
|
2004-06-16 19:17:43 +04:00
|
|
|
|
|
|
|
/* For Fortran functions */
|
|
|
|
|
|
|
|
MPI_F_delete_function *attr_F_delete_fn;
|
|
|
|
MPI_F_copy_function *attr_F_copy_fn;
|
2004-05-30 20:21:44 +04:00
|
|
|
};
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef union ompi_attribute_fn_ptr_union_t ompi_attribute_fn_ptr_union_t;
|
2004-05-30 20:21:44 +04:00
|
|
|
|
2004-01-12 19:08:46 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
struct ompi_attrkey_item_t {
|
|
|
|
ompi_object_t super;
|
|
|
|
ompi_attribute_type_t attr_type; /**< One of COMM/WIN/DTYPE. This
|
2004-03-17 02:34:41 +03:00
|
|
|
will be used to cast the
|
|
|
|
copy/delete attribute functions
|
|
|
|
properly and error checking */
|
2004-06-16 19:17:43 +04:00
|
|
|
int attr_flag; /**< flag field: contains "OMPI_KEYVAL_PREDEFINED",
|
|
|
|
"OMPI_KEYVAL_F77" */
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_attribute_fn_ptr_union_t copy_attr_fn; /**< Copy function for the
|
2004-05-30 20:21:44 +04:00
|
|
|
attribute */
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_attribute_fn_ptr_union_t delete_attr_fn; /**< Delete function for the
|
2004-05-30 20:21:44 +04:00
|
|
|
attribute */
|
2004-03-17 02:34:41 +03:00
|
|
|
void *extra_state; /**< Extra state of the attribute */
|
|
|
|
int key; /**< Keep a track of which key this item belongs to, so that
|
|
|
|
the key can be deleted when this object is destroyed */
|
|
|
|
};
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
typedef struct ompi_attrkey_item_t ompi_attrkey_item_t;
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2004-05-30 20:21:44 +04:00
|
|
|
/**
|
|
|
|
* Convenient way to initialize the attribute hash table per MPI-Object
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_hash_init(ompi_hash_table_t **keyhash)
|
2004-05-30 20:21:44 +04:00
|
|
|
{
|
2004-06-07 19:33:53 +04:00
|
|
|
*keyhash = OBJ_NEW(ompi_hash_table_t);
|
2004-05-30 20:21:44 +04:00
|
|
|
if (NULL == keyhash) {
|
|
|
|
fprintf(stderr, "Error while creating the local attribute list\n");
|
|
|
|
return MPI_ERR_SYSRESOURCE;
|
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
if (ompi_hash_table_init(*keyhash, ATTR_HASH_SIZE) != OMPI_SUCCESS)
|
2004-05-30 20:21:44 +04:00
|
|
|
return MPI_ERR_SYSRESOURCE;
|
|
|
|
|
|
|
|
return MPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-03-17 02:34:41 +03:00
|
|
|
/**
|
|
|
|
* Initialize the main attribute hash that stores the key and meta data
|
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI return code
|
2004-03-17 02:34:41 +03:00
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_init(void);
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Destroy the main attribute hash that stores the key and meta data
|
|
|
|
*/
|
|
|
|
|
2004-08-29 13:05:14 +04:00
|
|
|
int ompi_attr_finalize(void);
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new key for use by attribute of Comm/Win/Datatype
|
|
|
|
*
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param copy_attr_fn Union variable containing the function pointer
|
|
|
|
* to be used in order to copy the attribute (IN)
|
2004-03-17 02:34:41 +03:00
|
|
|
* @param delete_attr_fn Function pointer to be used for deleting the
|
|
|
|
* attribute (IN)
|
|
|
|
* @param key The newly created key is returned here (OUT)
|
|
|
|
* @param extra_state Extra state to hang off/do some special things (IN)
|
2004-06-16 19:17:43 +04:00
|
|
|
* @param flags Flags for the key -- flags contain OMPI_KEYVAL_F77,
|
|
|
|
* OMPI_KEYVAL_PREDEFINED
|
2004-03-24 02:44:53 +03:00
|
|
|
* NOTE: I have taken the assumption that user cannot modify/delete
|
|
|
|
* any predefined keys or the attributes attached. To accomplish this,
|
2004-06-16 19:17:43 +04:00
|
|
|
* all MPI* calls will have OMPI_KEYVAL_PREDEFINED set as 0. MPI
|
2004-03-24 02:44:53 +03:00
|
|
|
* implementors who will need to play with the predefined keys and
|
2004-06-07 19:33:53 +04:00
|
|
|
* attributes would call the ompi* functions here and not the MPI*
|
2004-06-16 19:17:43 +04:00
|
|
|
* functions, with OMPI_KEYVAL_PREDEFINED set to 1.
|
2004-03-24 02:44:53 +03:00
|
|
|
* END OF NOTE
|
|
|
|
*
|
2004-05-30 20:21:44 +04:00
|
|
|
* NOTE: For the function pointers, you need to create a variable of the
|
2004-06-07 19:33:53 +04:00
|
|
|
* union type "ompi_attribute_fn_ptr_union_t" and assign the proper field.
|
2004-05-30 20:21:44 +04:00
|
|
|
* to be passed into this function
|
|
|
|
* END OF NOTE
|
|
|
|
*
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI return code
|
2004-03-24 02:44:53 +03:00
|
|
|
|
2004-03-17 02:34:41 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
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,
|
2004-06-16 19:17:43 +04:00
|
|
|
int *key, void *extra_state, int flags);
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Free an attribute keyval
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
|
|
|
* @param key key, which is set to MPI_KEY_INVALID (IN/OUT)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-17 02:34:41 +03:00
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_free_keyval(ompi_attribute_type_t type, int *key, int predefined);
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set an attribute on the comm/win/datatype
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
|
|
|
* @param object The actual Comm/Win/Datatype object (IN)
|
2004-10-07 05:26:40 +04:00
|
|
|
* @param keyhash The attribute hash table hanging on the object(IN/OUT)
|
2004-03-17 02:34:41 +03:00
|
|
|
* @param key Key val for the attribute (IN)
|
|
|
|
* @param attribute The actual attribute pointer (IN)
|
|
|
|
* @param predefined Whether the key is predefined or not 0/1 (IN)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-17 02:34:41 +03:00
|
|
|
*
|
2004-10-07 05:26:40 +04:00
|
|
|
* If (*keyhash) == NULL, a new keyhash will be created and
|
|
|
|
* initialized.
|
|
|
|
*
|
2004-03-17 02:34:41 +03:00
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_set(ompi_attribute_type_t type, void *object,
|
2004-10-07 05:26:40 +04:00
|
|
|
ompi_hash_table_t **keyhash,
|
|
|
|
int key, void *attribute, int predefined);
|
2004-03-17 02:34:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an attribute on the comm/win/datatype
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param keyhash The attribute hash table hanging on the object(IN)
|
2004-03-17 02:34:41 +03:00
|
|
|
* @param key Key val for the attribute (IN)
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param attribute The actual attribute pointer (OUT)
|
|
|
|
* @param flag Flag whether an attribute is associated
|
|
|
|
* with the key (OUT)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-17 02:34:41 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_get(ompi_hash_table_t *keyhash, int key,
|
2004-03-17 02:34:41 +03:00
|
|
|
void *attribute, int *flag);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete an attribute on the comm/win/datatype
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
|
|
|
* @param object The actual Comm/Win/Datatype object (IN)
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param keyhash The attribute hash table hanging on the object(IN)
|
2004-03-17 02:34:41 +03:00
|
|
|
* @param key Key val for the attribute (IN)
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param predefined Whether the key is predefined or not 0/1 (IN)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-17 02:34:41 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_delete(ompi_attribute_type_t type, void *object,
|
|
|
|
ompi_hash_table_t *keyhash , int key,
|
2004-03-17 02:34:41 +03:00
|
|
|
int predefined);
|
|
|
|
|
2004-03-24 02:44:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
|
|
|
* @param old_object The old COMM/WIN/DTYPE object (IN)
|
|
|
|
* @param new_object The new COMM/WIN/DTYPE object (IN)
|
2004-05-30 20:24:20 +04:00
|
|
|
* @param keyhash The attribute hash table hanging on old object(IN)
|
|
|
|
* @param newkeyhash The attribute hash table hanging on new object(IN)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-24 02:44:53 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,
|
|
|
|
void *new_object, ompi_hash_table_t *oldkeyhash,
|
|
|
|
ompi_hash_table_t *newkeyhash);
|
2004-03-24 02:44:53 +03:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This to be used to delete all the attributes from the Comm/Win/Dtype
|
|
|
|
* object in one shot
|
|
|
|
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
|
|
|
|
* @param object The COMM/WIN/DTYPE object (IN)
|
2004-05-30 20:21:44 +04:00
|
|
|
* @param keyhash The attribute hash table hanging on the object(IN)
|
2004-06-07 19:33:53 +04:00
|
|
|
* @return OMPI error code
|
2004-03-24 02:44:53 +03:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
int ompi_attr_delete_all(ompi_attribute_type_t type, void *object,
|
|
|
|
ompi_hash_table_t *keyhash);
|
2004-03-24 02:44:53 +03:00
|
|
|
|
|
|
|
|
2004-09-16 04:00:09 +04:00
|
|
|
/**
|
|
|
|
* \internal
|
|
|
|
*
|
|
|
|
* Create all the predefined attributes
|
|
|
|
*
|
|
|
|
* @returns OMPI_SUCCESS
|
|
|
|
*/
|
|
|
|
int ompi_attr_create_predefined(void);
|
|
|
|
|
|
|
|
|
2004-03-17 02:34:41 +03:00
|
|
|
#if defined(c_plusplus) || defined(__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2004-01-12 19:08:46 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#endif /* OMPI_ATTRIBUTE_H */
|