Skip to content

ompi/attributes: revamp attribute handling. #3891

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
283 changes: 187 additions & 96 deletions ompi/attribute/attribute.c

Large diffs are not rendered by default.

111 changes: 71 additions & 40 deletions ompi/attribute/attribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -41,7 +43,7 @@
*/
#define OMPI_KEYVAL_PREDEFINED 0x0001
#define OMPI_KEYVAL_F77 0x0002
#define OMPI_KEYVAL_F77_MPI1 0x0004
#define OMPI_KEYVAL_F77_INT 0x0004


BEGIN_C_DECLS
Expand All @@ -62,14 +64,14 @@ typedef enum ompi_attribute_type_t ompi_attribute_type_t;
delete. These will only be used here and not in the front end
functions. */

typedef void (ompi_mpi1_fortran_copy_attr_function)(MPI_Fint *oldobj,
typedef void (ompi_fint_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,
typedef void (ompi_fint_delete_attr_function)(MPI_Fint *obj,
MPI_Fint *keyval,
MPI_Fint *attr_in,
MPI_Fint *extra_state,
Expand All @@ -79,18 +81,18 @@ typedef void (ompi_mpi1_fortran_delete_attr_function)(MPI_Fint *obj,
delete. These will only be used here and not in the front end
functions. */

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 void (ompi_aint_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_aint_delete_attr_function)(MPI_Fint *obj,
MPI_Fint *keyval,
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
Expand Down Expand Up @@ -124,13 +126,13 @@ union ompi_attribute_fn_ptr_union_t {

/* For Fortran old MPI-1 callback functions */

ompi_mpi1_fortran_delete_attr_function *attr_mpi1_fortran_delete_fn;
ompi_mpi1_fortran_copy_attr_function *attr_mpi1_fortran_copy_fn;
ompi_fint_delete_attr_function *attr_fint_delete_fn;
ompi_fint_copy_attr_function *attr_fint_copy_fn;

/* For Fortran new MPI-2 callback functions */

ompi_mpi2_fortran_delete_attr_function *attr_mpi2_fortran_delete_fn;
ompi_mpi2_fortran_copy_attr_function *attr_mpi2_fortran_copy_fn;
ompi_aint_delete_attr_function *attr_aint_delete_fn;
ompi_aint_copy_attr_function *attr_aint_copy_fn;
};

typedef union ompi_attribute_fn_ptr_union_t ompi_attribute_fn_ptr_union_t;
Expand Down Expand Up @@ -297,8 +299,8 @@ int ompi_attr_free_keyval(ompi_attribute_type_t type, int *key,
* 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())
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
* ompi_attr_set_fint(), and ompi_attr_set_aint())
* 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
Expand All @@ -312,6 +314,35 @@ 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 int predefined attribute in a form valid for C.
*
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param object The actual Comm/Win/Datatype object (IN)
* @param attr_hash The attribute hash table hanging on the object(IN/OUT)
* @param key Key val for the attribute (IN)
* @param attribute The actual attribute value (IN)
* @param predefined Whether the key is predefined or not 0/1 (IN)
* @return OMPI error code
*
* If (*attr_hash) == NULL, a new hash will be created and
* initialized.
*
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
* ompi_attr_set_fint(), and ompi_attr_set_aint())
* 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_set_int(ompi_attribute_type_t type, void *object,
opal_hash_table_t **attr_hash,
int key, int attribute, bool predefined);

/**
* Set an attribute on the comm/win/datatype in a form valid for
* Fortran MPI-1.
Expand All @@ -327,8 +358,8 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
* 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())
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
* ompi_attr_set_fint(), and ompi_attr_set_aint())
* 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
Expand All @@ -338,10 +369,10 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
* 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);
OMPI_DECLSPEC int ompi_attr_set_fint(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
Expand All @@ -358,8 +389,8 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1(ompi_attribute_type_t type, void *o
* 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())
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
* ompi_attr_set_fint(), and ompi_attr_set_aint())
* 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
Expand All @@ -369,10 +400,10 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1(ompi_attribute_type_t type, void *o
* 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);
OMPI_DECLSPEC int ompi_attr_set_aint(ompi_attribute_type_t type, void *object,
opal_hash_table_t **attr_hash,
int key, MPI_Aint attribute,
bool predefined);

/**
* Get an attribute on the comm/win/datatype in a form valid for C.
Expand All @@ -385,7 +416,7 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi2(ompi_attribute_type_t type, void *o
* @return OMPI error code
*
* All three of these functions (ompi_attr_get_c(),
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
* ompi_attr_get_fint(), and ompi_attr_get_aint())
* 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
Expand All @@ -412,7 +443,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
* @return OMPI error code
*
* All three of these functions (ompi_attr_get_c(),
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
* ompi_attr_get_fint(), and ompi_attr_get_aint())
* 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
Expand All @@ -423,8 +454,8 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
* (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);
OMPI_DECLSPEC int ompi_attr_get_fint(opal_hash_table_t *attr_hash, int key,
MPI_Fint *attribute, int *flag);


/**
Expand All @@ -439,7 +470,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
* @return OMPI error code
*
* All three of these functions (ompi_attr_get_c(),
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
* ompi_attr_get_fint(), and ompi_attr_get_aint())
* 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
Expand All @@ -450,8 +481,8 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
* (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);
OMPI_DECLSPEC int ompi_attr_get_aint(opal_hash_table_t *attr_hash, int key,
MPI_Aint *attribute, int *flag);


/**
Expand Down
10 changes: 6 additions & 4 deletions ompi/attribute/attribute_predefined.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* All rights reserved.
* Copyright (c) 2006 University of Houston. All rights reserved.
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -270,8 +272,8 @@ static int free_win(int keyval)

static int set_f(int keyval, MPI_Fint value)
{
return ompi_attr_set_fortran_mpi1(COMM_ATTR, MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
keyval, value,
true);
return ompi_attr_set_fint(COMM_ATTR, MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
keyval, value,
true);
}
14 changes: 7 additions & 7 deletions ompi/mpi/c/add_error_class.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -66,12 +66,12 @@ int MPI_Add_error_class(int *errorclass)
** in attribute/attribute.c and attribute/attribute_predefined.c
** why we have to call the fortran attr_set function
*/
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true);
rc = ompi_attr_set_fint (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true);
if ( MPI_SUCCESS != rc ) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
}
Expand Down
14 changes: 7 additions & 7 deletions ompi/mpi/c/add_error_code.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2006 University of Houston. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -73,12 +73,12 @@ int MPI_Add_error_code(int errorclass, int *errorcode)
** in attribute/attribute.c and attribute/attribute_predefined.c
** why we have to call the fortran attr_set function
*/
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true);
rc = ompi_attr_set_fint (COMM_ATTR,
MPI_COMM_WORLD,
&MPI_COMM_WORLD->c_keyhash,
MPI_LASTUSEDCODE,
ompi_mpi_errcode_lastused,
true);
if ( MPI_SUCCESS != rc ) {
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
}
Expand Down
10 changes: 5 additions & 5 deletions ompi/mpi/fortran/mpif-h/attr_get_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -77,10 +77,10 @@ void ompi_attr_get_f(MPI_Fint *comm, MPI_Fint *keyval,
/* This stuff is very confusing. Be sure to see the comment at
the top of src/attributes/attributes.c. */

c_ierr = ompi_attr_get_fortran_mpi1(c_comm->c_keyhash,
OMPI_FINT_2_INT(*keyval),
attribute_val,
OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag));
c_ierr = ompi_attr_get_fint(c_comm->c_keyhash,
OMPI_FINT_2_INT(*keyval),
attribute_val,
OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag));
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);

OMPI_SINGLE_INT_2_LOGICAL(flag);
Expand Down
14 changes: 7 additions & 7 deletions ompi/mpi/fortran/mpif-h/attr_put_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
Expand Down Expand Up @@ -76,11 +76,11 @@ void ompi_attr_put_f(MPI_Fint *comm, MPI_Fint *keyval, MPI_Fint *attribute_val,
/* This stuff is very confusing. Be sure to see the comment at
the top of src/attributes/attributes.c. */

c_err = ompi_attr_set_fortran_mpi1(COMM_ATTR,
c_comm,
&c_comm->c_keyhash,
OMPI_FINT_2_INT(*keyval),
*attribute_val,
false);
c_err = ompi_attr_set_fint(COMM_ATTR,
c_comm,
&c_comm->c_keyhash,
OMPI_FINT_2_INT(*keyval),
*attribute_val,
false);
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_err);
}
Loading