Skip to content

Commit 72cfbb6

Browse files
committed
ompi/attributes: revamp attribute handling.
we now have 12 cases to deal (4 writers and 3 readers) : 1. C `void*` is written into the attribute value, and the value is read into a C `void*` (unity) 2. C `void*` is written, Fortran `INTEGER` is read 3. C `void*` is written, Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is read 4. Fortran `INTEGER` is written, C `void*` is read 5. Fortran `INTEGER` is written, Fortran `INTEGER` is read (unity) 6. Fortran `INTEGER` is written, Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is read 7. Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is written, C `void*` is read 8. Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is written, Fortran `INTEGER` is read 9. Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is written, Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is read (unity) 10. Intrinsic is written, C `void*` is read 11. Intrinsic is written, Fortran `INTEGER` is read 12. Intrinsic is written, Fortran `INTEGER(KIND=MPI_ADDRESS_KIND)` is read MPI-2 Fortran "integer representation" has type `INTEGER(KIND=MPI_ADDRESS_KIND)` as clarified at mpiwg-rma/rma-issues#1 Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
1 parent 9118777 commit 72cfbb6

20 files changed

+377
-251
lines changed

ompi/attribute/attribute.c

+187-96
Large diffs are not rendered by default.

ompi/attribute/attribute.h

+71-40
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2017 Research Organization for Information Science
14+
* and Technology (RIST). All rights reserved.
1315
* $COPYRIGHT$
1416
*
1517
* Additional copyrights may follow
@@ -41,7 +43,7 @@
4143
*/
4244
#define OMPI_KEYVAL_PREDEFINED 0x0001
4345
#define OMPI_KEYVAL_F77 0x0002
44-
#define OMPI_KEYVAL_F77_MPI1 0x0004
46+
#define OMPI_KEYVAL_F77_INT 0x0004
4547

4648

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

65-
typedef void (ompi_mpi1_fortran_copy_attr_function)(MPI_Fint *oldobj,
67+
typedef void (ompi_fint_copy_attr_function)(MPI_Fint *oldobj,
6668
MPI_Fint *keyval,
6769
MPI_Fint *extra_state,
6870
MPI_Fint *attr_in,
6971
MPI_Fint *attr_out,
7072
ompi_fortran_logical_t *flag,
7173
MPI_Fint *ierr);
72-
typedef void (ompi_mpi1_fortran_delete_attr_function)(MPI_Fint *obj,
74+
typedef void (ompi_fint_delete_attr_function)(MPI_Fint *obj,
7375
MPI_Fint *keyval,
7476
MPI_Fint *attr_in,
7577
MPI_Fint *extra_state,
@@ -79,18 +81,18 @@ typedef void (ompi_mpi1_fortran_delete_attr_function)(MPI_Fint *obj,
7981
delete. These will only be used here and not in the front end
8082
functions. */
8183

82-
typedef void (ompi_mpi2_fortran_copy_attr_function)(MPI_Fint *oldobj,
83-
MPI_Fint *keyval,
84-
void *extra_state,
85-
void *attr_in,
86-
void *attr_out,
87-
ompi_fortran_logical_t *flag,
88-
MPI_Fint *ierr);
89-
typedef void (ompi_mpi2_fortran_delete_attr_function)(MPI_Fint *obj,
90-
MPI_Fint *keyval,
91-
void *attr_in,
92-
void *extra_state,
93-
MPI_Fint *ierr);
84+
typedef void (ompi_aint_copy_attr_function)(MPI_Fint *oldobj,
85+
MPI_Fint *keyval,
86+
void *extra_state,
87+
void *attr_in,
88+
void *attr_out,
89+
ompi_fortran_logical_t *flag,
90+
MPI_Fint *ierr);
91+
typedef void (ompi_aint_delete_attr_function)(MPI_Fint *obj,
92+
MPI_Fint *keyval,
93+
void *attr_in,
94+
void *extra_state,
95+
MPI_Fint *ierr);
9496
/*
9597
* Internally the copy function for all kinds of MPI objects has one more
9698
* argument, the pointer to the new object. Therefore, we can do on the
@@ -124,13 +126,13 @@ union ompi_attribute_fn_ptr_union_t {
124126

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

127-
ompi_mpi1_fortran_delete_attr_function *attr_mpi1_fortran_delete_fn;
128-
ompi_mpi1_fortran_copy_attr_function *attr_mpi1_fortran_copy_fn;
129+
ompi_fint_delete_attr_function *attr_fint_delete_fn;
130+
ompi_fint_copy_attr_function *attr_fint_copy_fn;
129131

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

132-
ompi_mpi2_fortran_delete_attr_function *attr_mpi2_fortran_delete_fn;
133-
ompi_mpi2_fortran_copy_attr_function *attr_mpi2_fortran_copy_fn;
134+
ompi_aint_delete_attr_function *attr_aint_delete_fn;
135+
ompi_aint_copy_attr_function *attr_aint_copy_fn;
134136
};
135137

136138
typedef union ompi_attribute_fn_ptr_union_t ompi_attribute_fn_ptr_union_t;
@@ -297,8 +299,8 @@ int ompi_attr_free_keyval(ompi_attribute_type_t type, int *key,
297299
* If (*attr_hash) == NULL, a new hash will be created and
298300
* initialized.
299301
*
300-
* All three of these functions (ompi_attr_set_c(),
301-
* ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2())
302+
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
303+
* ompi_attr_set_fint(), and ompi_attr_set_aint())
302304
* could have been combined into one function that took some kind of
303305
* (void*) and an enum to indicate which way to translate the final
304306
* representation, but that just seemed to make an already complicated
@@ -312,6 +314,35 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
312314
opal_hash_table_t **attr_hash,
313315
int key, void *attribute, bool predefined);
314316

317+
/**
318+
* Set an int predefined attribute in a form valid for C.
319+
*
320+
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
321+
* @param object The actual Comm/Win/Datatype object (IN)
322+
* @param attr_hash The attribute hash table hanging on the object(IN/OUT)
323+
* @param key Key val for the attribute (IN)
324+
* @param attribute The actual attribute value (IN)
325+
* @param predefined Whether the key is predefined or not 0/1 (IN)
326+
* @return OMPI error code
327+
*
328+
* If (*attr_hash) == NULL, a new hash will be created and
329+
* initialized.
330+
*
331+
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
332+
* ompi_attr_set_fint(), and ompi_attr_set_aint())
333+
* could have been combined into one function that took some kind of
334+
* (void*) and an enum to indicate which way to translate the final
335+
* representation, but that just seemed to make an already complicated
336+
* situation more complicated through yet another layer of
337+
* indirection.
338+
*
339+
* So yes, this is more code, but it's clearer and less error-prone
340+
* (read: better) this way.
341+
*/
342+
int ompi_attr_set_int(ompi_attribute_type_t type, void *object,
343+
opal_hash_table_t **attr_hash,
344+
int key, int attribute, bool predefined);
345+
315346
/**
316347
* Set an attribute on the comm/win/datatype in a form valid for
317348
* Fortran MPI-1.
@@ -327,8 +358,8 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
327358
* If (*attr_hash) == NULL, a new hash will be created and
328359
* initialized.
329360
*
330-
* All three of these functions (ompi_attr_set_c(),
331-
* ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2())
361+
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
362+
* ompi_attr_set_fint(), and ompi_attr_set_aint())
332363
* could have been combined into one function that took some kind of
333364
* (void*) and an enum to indicate which way to translate the final
334365
* representation, but that just seemed to make an already complicated
@@ -338,10 +369,10 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
338369
* So yes, this is more code, but it's clearer and less error-prone
339370
* (read: better) this way.
340371
*/
341-
OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1(ompi_attribute_type_t type, void *object,
342-
opal_hash_table_t **attr_hash,
343-
int key, MPI_Fint attribute,
344-
bool predefined);
372+
OMPI_DECLSPEC int ompi_attr_set_fint(ompi_attribute_type_t type, void *object,
373+
opal_hash_table_t **attr_hash,
374+
int key, MPI_Fint attribute,
375+
bool predefined);
345376

346377
/**
347378
* Set an attribute on the comm/win/datatype in a form valid for
@@ -358,8 +389,8 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1(ompi_attribute_type_t type, void *o
358389
* If (*attr_hash) == NULL, a new hash will be created and
359390
* initialized.
360391
*
361-
* All three of these functions (ompi_attr_set_c(),
362-
* ompi_attr_set_fortran_mpi1(), and ompi_attr_set_fortran_mpi2())
392+
* All four of these functions (ompi_attr_set_c(), ompi_attr_set_int(),
393+
* ompi_attr_set_fint(), and ompi_attr_set_aint())
363394
* could have been combined into one function that took some kind of
364395
* (void*) and an enum to indicate which way to translate the final
365396
* representation, but that just seemed to make an already complicated
@@ -369,10 +400,10 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi1(ompi_attribute_type_t type, void *o
369400
* So yes, this is more code, but it's clearer and less error-prone
370401
* (read: better) this way.
371402
*/
372-
OMPI_DECLSPEC int ompi_attr_set_fortran_mpi2(ompi_attribute_type_t type, void *object,
373-
opal_hash_table_t **attr_hash,
374-
int key, MPI_Aint attribute,
375-
bool predefined);
403+
OMPI_DECLSPEC int ompi_attr_set_aint(ompi_attribute_type_t type, void *object,
404+
opal_hash_table_t **attr_hash,
405+
int key, MPI_Aint attribute,
406+
bool predefined);
376407

377408
/**
378409
* Get an attribute on the comm/win/datatype in a form valid for C.
@@ -385,7 +416,7 @@ OMPI_DECLSPEC int ompi_attr_set_fortran_mpi2(ompi_attribute_type_t type, void *o
385416
* @return OMPI error code
386417
*
387418
* All three of these functions (ompi_attr_get_c(),
388-
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
419+
* ompi_attr_get_fint(), and ompi_attr_get_aint())
389420
* could have been combined into one function that took some kind of
390421
* (void*) and an enum to indicate which way to translate the final
391422
* representation, but that just seemed to make an already complicated
@@ -412,7 +443,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
412443
* @return OMPI error code
413444
*
414445
* All three of these functions (ompi_attr_get_c(),
415-
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
446+
* ompi_attr_get_fint(), and ompi_attr_get_aint())
416447
* could have been combined into one function that took some kind of
417448
* (void*) and an enum to indicate which way to translate the final
418449
* representation, but that just seemed to make an already complicated
@@ -423,8 +454,8 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
423454
* (read: better) this way.
424455
*/
425456

426-
OMPI_DECLSPEC int ompi_attr_get_fortran_mpi1(opal_hash_table_t *attr_hash, int key,
427-
MPI_Fint *attribute, int *flag);
457+
OMPI_DECLSPEC int ompi_attr_get_fint(opal_hash_table_t *attr_hash, int key,
458+
MPI_Fint *attribute, int *flag);
428459

429460

430461
/**
@@ -439,7 +470,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
439470
* @return OMPI error code
440471
*
441472
* All three of these functions (ompi_attr_get_c(),
442-
* ompi_attr_get_fortran_mpi1(), and ompi_attr_get_fortran_mpi2())
473+
* ompi_attr_get_fint(), and ompi_attr_get_aint())
443474
* could have been combined into one function that took some kind of
444475
* (void*) and an enum to indicate which way to translate the final
445476
* representation, but that just seemed to make an already complicated
@@ -450,8 +481,8 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,
450481
* (read: better) this way.
451482
*/
452483

453-
OMPI_DECLSPEC int ompi_attr_get_fortran_mpi2(opal_hash_table_t *attr_hash, int key,
454-
MPI_Aint *attribute, int *flag);
484+
OMPI_DECLSPEC int ompi_attr_get_aint(opal_hash_table_t *attr_hash, int key,
485+
MPI_Aint *attribute, int *flag);
455486

456487

457488
/**

ompi/attribute/attribute_predefined.c

+6-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* All rights reserved.
1212
* Copyright (c) 2006 University of Houston. All rights reserved.
1313
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
14+
* Copyright (c) 2017 Research Organization for Information Science
15+
* and Technology (RIST). All rights reserved.
1416
* $COPYRIGHT$
1517
*
1618
* Additional copyrights may follow
@@ -270,8 +272,8 @@ static int free_win(int keyval)
270272

271273
static int set_f(int keyval, MPI_Fint value)
272274
{
273-
return ompi_attr_set_fortran_mpi1(COMM_ATTR, MPI_COMM_WORLD,
274-
&MPI_COMM_WORLD->c_keyhash,
275-
keyval, value,
276-
true);
275+
return ompi_attr_set_fint(COMM_ATTR, MPI_COMM_WORLD,
276+
&MPI_COMM_WORLD->c_keyhash,
277+
keyval, value,
278+
true);
277279
}

ompi/mpi/c/add_error_class.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006 University of Houston. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -66,12 +66,12 @@ int MPI_Add_error_class(int *errorclass)
6666
** in attribute/attribute.c and attribute/attribute_predefined.c
6767
** why we have to call the fortran attr_set function
6868
*/
69-
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
70-
MPI_COMM_WORLD,
71-
&MPI_COMM_WORLD->c_keyhash,
72-
MPI_LASTUSEDCODE,
73-
ompi_mpi_errcode_lastused,
74-
true);
69+
rc = ompi_attr_set_fint (COMM_ATTR,
70+
MPI_COMM_WORLD,
71+
&MPI_COMM_WORLD->c_keyhash,
72+
MPI_LASTUSEDCODE,
73+
ompi_mpi_errcode_lastused,
74+
true);
7575
if ( MPI_SUCCESS != rc ) {
7676
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
7777
}

ompi/mpi/c/add_error_code.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2006 University of Houston. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -73,12 +73,12 @@ int MPI_Add_error_code(int errorclass, int *errorcode)
7373
** in attribute/attribute.c and attribute/attribute_predefined.c
7474
** why we have to call the fortran attr_set function
7575
*/
76-
rc = ompi_attr_set_fortran_mpi1 (COMM_ATTR,
77-
MPI_COMM_WORLD,
78-
&MPI_COMM_WORLD->c_keyhash,
79-
MPI_LASTUSEDCODE,
80-
ompi_mpi_errcode_lastused,
81-
true);
76+
rc = ompi_attr_set_fint (COMM_ATTR,
77+
MPI_COMM_WORLD,
78+
&MPI_COMM_WORLD->c_keyhash,
79+
MPI_LASTUSEDCODE,
80+
ompi_mpi_errcode_lastused,
81+
true);
8282
if ( MPI_SUCCESS != rc ) {
8383
return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, rc, FUNC_NAME);
8484
}

ompi/mpi/fortran/mpif-h/attr_get_f.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -77,10 +77,10 @@ void ompi_attr_get_f(MPI_Fint *comm, MPI_Fint *keyval,
7777
/* This stuff is very confusing. Be sure to see the comment at
7878
the top of src/attributes/attributes.c. */
7979

80-
c_ierr = ompi_attr_get_fortran_mpi1(c_comm->c_keyhash,
81-
OMPI_FINT_2_INT(*keyval),
82-
attribute_val,
83-
OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag));
80+
c_ierr = ompi_attr_get_fint(c_comm->c_keyhash,
81+
OMPI_FINT_2_INT(*keyval),
82+
attribute_val,
83+
OMPI_LOGICAL_SINGLE_NAME_CONVERT(flag));
8484
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_ierr);
8585

8686
OMPI_SINGLE_INT_2_LOGICAL(flag);

ompi/mpi/fortran/mpif-h/attr_put_f.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2011-2012 Cisco Systems, Inc. All rights reserved.
13-
* Copyright (c) 2015 Research Organization for Information Science
13+
* Copyright (c) 2015-2017 Research Organization for Information Science
1414
* and Technology (RIST). All rights reserved.
1515
* $COPYRIGHT$
1616
*
@@ -76,11 +76,11 @@ void ompi_attr_put_f(MPI_Fint *comm, MPI_Fint *keyval, MPI_Fint *attribute_val,
7676
/* This stuff is very confusing. Be sure to see the comment at
7777
the top of src/attributes/attributes.c. */
7878

79-
c_err = ompi_attr_set_fortran_mpi1(COMM_ATTR,
80-
c_comm,
81-
&c_comm->c_keyhash,
82-
OMPI_FINT_2_INT(*keyval),
83-
*attribute_val,
84-
false);
79+
c_err = ompi_attr_set_fint(COMM_ATTR,
80+
c_comm,
81+
&c_comm->c_keyhash,
82+
OMPI_FINT_2_INT(*keyval),
83+
*attribute_val,
84+
false);
8585
if (NULL != ierr) *ierr = OMPI_INT_2_FINT(c_err);
8686
}

0 commit comments

Comments
 (0)