1
1

Add one more argument to the copy functions for the MPI objects. As this argument

is the last one on the list and as on C the caller "make it right" this addition
will not affect the way we handle the user defined copy functions. Only the C
version of the function has this additional parameter. As it represent the pointer
to the newly created MPI object It hold the key to allow us to modify the new
object (communicator, window or type) depending on some key stored on the initial
communicator.

This commit was SVN r9371.
Этот коммит содержится в:
George Bosilca 2006-03-23 04:47:14 +00:00
родитель 70cf1ce562
Коммит 85bb1a9c90
7 изменённых файлов: 52 добавлений и 41 удалений

Просмотреть файл

@ -241,7 +241,7 @@
Ick.
*/
#define DELETE_ATTR_CALLBACKS(type, attribute, keyval_obj) \
#define DELETE_ATTR_CALLBACKS(type, attribute, keyval_obj, object) \
if (0 != (keyval_obj->attr_flag & OMPI_KEYVAL_F77)) { \
MPI_Fint f_key = OMPI_INT_2_FINT(key); \
MPI_Fint f_err; \
@ -289,7 +289,7 @@
/* See the big, long comment above from DELETE_ATTR_CALLBACKS -- most of
that text applies here, too. */
#define COPY_ATTR_CALLBACKS(type, old_object, keyval_obj, in_attr, out_attr) \
#define COPY_ATTR_CALLBACKS(type, old_object, keyval_obj, in_attr, new_object, out_attr) \
if (0 != (keyval_obj->attr_flag & OMPI_KEYVAL_F77)) { \
MPI_Fint f_key = OMPI_INT_2_FINT(key); \
MPI_Fint f_err; \
@ -332,7 +332,7 @@
in = translate_to_c(in_attr); \
if ((err = (*((keyval_obj->copy_attr_fn).attr_##type##_copy_fn)) \
((ompi_##type##_t *)old_object, key, keyval_obj->extra_state, \
in, &out, &flag)) != MPI_SUCCESS) { \
in, &out, &flag, (ompi_##type##_t *)(new_object))) != MPI_SUCCESS) { \
OPAL_THREAD_UNLOCK(&alock); \
return err; \
} \
@ -645,15 +645,15 @@ int ompi_attr_delete(ompi_attribute_type_t type, void *object,
if (OMPI_SUCCESS == ret) {
switch (type) {
case COMM_ATTR:
DELETE_ATTR_CALLBACKS(communicator, attr, key_item);
DELETE_ATTR_CALLBACKS(communicator, attr, key_item, object);
break;
case WIN_ATTR:
DELETE_ATTR_CALLBACKS(win, attr, key_item);
DELETE_ATTR_CALLBACKS(win, attr, key_item, object);
break;
case TYPE_ATTR:
DELETE_ATTR_CALLBACKS(datatype, attr, key_item);
DELETE_ATTR_CALLBACKS(datatype, attr, key_item, object);
break;
default:
@ -857,19 +857,19 @@ int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,
case COMM_ATTR:
/* Now call the copy_attr_fn */
COPY_ATTR_CALLBACKS(communicator, old_object, hash_value,
old_attr, new_attr);
old_attr, new_object, new_attr);
break;
case TYPE_ATTR:
/* Now call the copy_attr_fn */
COPY_ATTR_CALLBACKS(datatype, old_object, hash_value,
old_attr, new_attr);
old_attr, new_object, new_attr);
break;
case WIN_ATTR:
/* Now call the copy_attr_fn */
COPY_ATTR_CALLBACKS(win, old_object, hash_value,
old_attr, new_attr);
old_attr, new_object, new_attr);
break;
}
@ -1024,15 +1024,15 @@ static int set_value(ompi_attribute_type_t type, void *object,
if (OMPI_SUCCESS == ret) {
switch (type) {
case COMM_ATTR:
DELETE_ATTR_CALLBACKS(communicator, old_attr, key_item);
DELETE_ATTR_CALLBACKS(communicator, old_attr, key_item, object);
break;
case WIN_ATTR:
DELETE_ATTR_CALLBACKS(win, old_attr, key_item);
DELETE_ATTR_CALLBACKS(win, old_attr, key_item, object);
break;
case TYPE_ATTR:
DELETE_ATTR_CALLBACKS(datatype, old_attr, key_item);
DELETE_ATTR_CALLBACKS(datatype, old_attr, key_item, object);
break;
default:

Просмотреть файл

@ -36,7 +36,6 @@
#define ATTR_HASH_SIZE 10
/*
* Flags for keyvals
*/
@ -91,6 +90,18 @@ typedef void (ompi_mpi2_fortran_delete_attr_function)(MPI_Fint *obj,
void *attr_in,
void *extra_state,
MPI_Fint *ierr);
/*
* Internally the copy function for all kinds of MPI objects has one more
* argument, the pointer to the new object. Therefore, we can do on the
* flight modifications of the new communicator based on attributes stored
* on the main communicator.
*/
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);
/* Union to take care of proper casting of the function pointers
passed from the front end functions depending on the type. This
@ -101,9 +112,9 @@ union ompi_attribute_fn_ptr_union_t {
MPI_Type_delete_attr_function *attr_datatype_delete_fn;
MPI_Win_delete_attr_function *attr_win_delete_fn;
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;
MPI_Comm_internal_copy_attr_function *attr_communicator_copy_fn;
MPI_Type_internal_copy_attr_function *attr_datatype_copy_fn;
MPI_Win_internal_copy_attr_function *attr_win_copy_fn;
/* For Fortran old MPI-1 callback functions */

Просмотреть файл

@ -331,8 +331,8 @@ static int create_comm(int target_keyval, bool want_inherit)
ompi_attribute_fn_ptr_union_t del;
keyval = -1;
copy.attr_communicator_copy_fn =
want_inherit ? MPI_COMM_DUP_FN : MPI_COMM_NULL_COPY_FN;
copy.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function*)
(want_inherit ? MPI_COMM_DUP_FN : MPI_COMM_NULL_COPY_FN);
del.attr_communicator_delete_fn = MPI_COMM_NULL_DELETE_FN;
err = ompi_attr_create_keyval(COMM_ATTR, copy, del,
&keyval, NULL, OMPI_KEYVAL_PREDEFINED);
@ -361,7 +361,7 @@ static int create_win(int target_keyval)
ompi_attribute_fn_ptr_union_t del;
keyval = -1;
copy.attr_win_copy_fn = MPI_WIN_NULL_COPY_FN;
copy.attr_win_copy_fn = (MPI_Win_internal_copy_attr_function*)MPI_WIN_NULL_COPY_FN;
del.attr_win_delete_fn = MPI_WIN_NULL_DELETE_FN;
err = ompi_attr_create_keyval(WIN_ATTR, copy, del,
&keyval, NULL, OMPI_KEYVAL_PREDEFINED);

Просмотреть файл

@ -49,7 +49,7 @@ int MPI_Comm_create_keyval(MPI_Comm_copy_attr_function *comm_copy_attr_fn,
}
}
copy_fn.attr_communicator_copy_fn = comm_copy_attr_fn;
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function*)comm_copy_attr_fn;
del_fn.attr_communicator_delete_fn = comm_delete_attr_fn;
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn,

Просмотреть файл

@ -51,7 +51,7 @@ int MPI_Keyval_create(MPI_Copy_function *copy_attr_fn,
FUNC_NAME);
}
}
copy_fn.attr_communicator_copy_fn = copy_attr_fn;
copy_fn.attr_communicator_copy_fn = (MPI_Comm_internal_copy_attr_function*)copy_attr_fn;
del_fn.attr_communicator_delete_fn = delete_attr_fn;
ret = ompi_attr_create_keyval(COMM_ATTR, copy_fn,

Просмотреть файл

@ -51,7 +51,7 @@ int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
}
}
copy_fn.attr_datatype_copy_fn = type_copy_attr_fn;
copy_fn.attr_datatype_copy_fn = (MPI_Type_internal_copy_attr_function*)type_copy_attr_fn;
del_fn.attr_datatype_delete_fn = type_delete_attr_fn;
ret = ompi_attr_create_keyval(TYPE_ATTR, copy_fn, del_fn,

Просмотреть файл

@ -48,7 +48,7 @@ int MPI_Win_create_keyval(MPI_Win_copy_attr_function *win_copy_attr_fn,
FUNC_NAME);
}
}
copy_fn.attr_win_copy_fn = win_copy_attr_fn;
copy_fn.attr_win_copy_fn = (MPI_Win_internal_copy_attr_function*)win_copy_attr_fn;
del_fn.attr_win_delete_fn = win_delete_attr_fn;
ret = ompi_attr_create_keyval(WIN_ATTR, copy_fn, del_fn,