Skip to content

Commit

Permalink
add support for sessions
Browse files Browse the repository at this point in the history
Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Signed-off-by: Howard Pritchard <howardp@lanl.gov>
  • Loading branch information
hjelmn authored and hppritcha committed May 20, 2021
1 parent 19b9b7f commit c226352
Show file tree
Hide file tree
Showing 165 changed files with 12,872 additions and 2,143 deletions.
1 change: 1 addition & 0 deletions ompi/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ include patterns/net/Makefile.am
include patterns/comm/Makefile.am
include mca/Makefile.am
include util/Makefile.am
include instance/Makefile.am

distclean-local:
rm -f mpiext/static-components.h
44 changes: 39 additions & 5 deletions ompi/attribute/attribute.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -14,6 +15,8 @@
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -240,6 +243,7 @@
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/communicator/communicator.h" /* ompi_communicator_t generated in [COPY|DELETE]_ATTR_CALLBACKS */
#include "ompi/win/win.h" /* ompi_win_t generated in [COPY|DELETE]_ATTR_CALLBACKS */
#include "ompi/instance/instance.h"
#include "ompi/mpi/fortran/base/fint_2_int.h"

/*
Expand All @@ -255,6 +259,7 @@
#define attr_communicator_f c_f_to_c_index
#define attr_datatype_f d_f_to_c_index
#define attr_win_f w_f_to_c_index
#define attr_instance_f i_f_to_c_index

#define CREATE_KEY(key) opal_bitmap_find_and_set_first_unset_bit(key_bitmap, (key))

Expand Down Expand Up @@ -424,6 +429,7 @@ static MPI_Fint translate_to_fint(attribute_value_t *val);
static MPI_Aint translate_to_aint(attribute_value_t *val);

static int compare_attr_sequence(const void *attr1, const void *attr2);
static int ompi_attr_finalize (void);


/*
Expand Down Expand Up @@ -560,14 +566,16 @@ int ompi_attr_init(void)
return ret;
}

ompi_mpi_instance_append_finalize (ompi_attr_finalize);

return OMPI_SUCCESS;
}


/*
* Cleanup everything during MPI_Finalize().
*/
int ompi_attr_finalize(void)
static int ompi_attr_finalize (void)
{
ompi_attr_free_predefined();
OBJ_DESTRUCT(&attribute_lock);
Expand Down Expand Up @@ -635,11 +643,22 @@ int ompi_attr_create_keyval(ompi_attribute_type_t type,
void *bindings_extra_state)
{
ompi_attribute_fortran_ptr_t es_tmp;
int rc;

rc = ompi_mpi_instance_retain ();
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
return rc;
}

es_tmp.c_ptr = extra_state;
return ompi_attr_create_keyval_impl(type, copy_attr_fn, delete_attr_fn,
key, &es_tmp, flags,
bindings_extra_state);
rc = ompi_attr_create_keyval_impl(type, copy_attr_fn, delete_attr_fn,
key, &es_tmp, flags,
bindings_extra_state);
if (OPAL_UNLIKELY(OMPI_SUCCESS != rc)) {
ompi_mpi_instance_release ();
}

return rc;
}

int ompi_attr_create_keyval_fint(ompi_attribute_type_t type,
Expand Down Expand Up @@ -707,6 +726,9 @@ int ompi_attr_free_keyval(ompi_attribute_type_t type, int *key,
opal_atomic_wmb();
OPAL_THREAD_UNLOCK(&attribute_lock);

/* balance out retain in keyval_create */
ompi_mpi_instance_release ();

return MPI_SUCCESS;
}

Expand Down Expand Up @@ -929,6 +951,10 @@ int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,
return MPI_SUCCESS;
}

if (INSTANCE_ATTR == type) {
return MPI_ERR_ARG;
}

OPAL_THREAD_LOCK(&attribute_lock);

/* Get the first attribute in the object's hash */
Expand Down Expand Up @@ -1053,7 +1079,7 @@ static int ompi_attr_delete_impl(ompi_attribute_type_t type, void *object,
goto exit;
}

/* Check if the key is valid for the communicator/window/dtype. If
/* Check if the key is valid for the communicator/window/dtype/instance. If
yes, then delete the attribute and key entry from the object's
hash */
ret = opal_hash_table_get_value_uint32(attr_hash, key, (void**) &attr);
Expand All @@ -1071,6 +1097,10 @@ static int ompi_attr_delete_impl(ompi_attribute_type_t type, void *object,
DELETE_ATTR_CALLBACKS(datatype, attr, keyval, object, ret);
break;

case INSTANCE_ATTR:
DELETE_ATTR_CALLBACKS(instance, attr, keyval, object, ret);
break;

default:
/* This should not happen */
assert(0);
Expand Down Expand Up @@ -1230,6 +1260,10 @@ static int set_value(ompi_attribute_type_t type, void *object,
DELETE_ATTR_CALLBACKS(datatype, old_attr, keyval, object, ret);
break;

case INSTANCE_ATTR:
DELETE_ATTR_CALLBACKS(instance, old_attr, keyval, object, ret);
break;

default:
/* This should not happen */
assert(0);
Expand Down
66 changes: 33 additions & 33 deletions ompi/attribute/attribute.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
Expand All @@ -12,7 +13,9 @@
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
* Copyright (c) 2018 Triad National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
Expand Down Expand Up @@ -55,7 +58,8 @@ enum ompi_attribute_type_t {
* with 1 so that we can have it initialized to 0
* using memset in the constructor */
TYPE_ATTR, /**< The attribute belongs to datatype object */
WIN_ATTR /**< The attribute belongs to a win object */
WIN_ATTR, /**< The attribute belongs to a win object */
INSTANCE_ATTR, /**< The attribute belongs to a session object */
};
typedef enum ompi_attribute_type_t ompi_attribute_type_t;

Expand Down Expand Up @@ -119,6 +123,7 @@ union ompi_attribute_fn_ptr_union_t {
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;
MPI_Session_delete_attr_function *attr_instance_delete_fn;

MPI_Comm_internal_copy_attr_function *attr_communicator_copy_fn;
MPI_Type_internal_copy_attr_function *attr_datatype_copy_fn;
Expand Down Expand Up @@ -155,7 +160,7 @@ typedef union ompi_attribute_fortran_ptr_t ompi_attribute_fortran_ptr_t;

struct ompi_attribute_keyval_t {
opal_object_t super;
ompi_attribute_type_t attr_type; /**< One of COMM/WIN/DTYPE. This
ompi_attribute_type_t attr_type; /**< One of COMM/WIN/DTYPE/INSTANCE. This
will be used to cast the
copy/delete attribute functions
properly and error checking */
Expand Down Expand Up @@ -208,17 +213,11 @@ int ompi_attr_hash_init(opal_hash_table_t **hash)

int ompi_attr_init(void);

/**
* Destroy the main attribute hash that stores the keyvals and meta data
*/

int ompi_attr_finalize(void);


/**
* Create a new key for use by attribute of Comm/Win/Datatype
* Create a new key for use by attribute of Comm/Win/Datatype/Instance
*
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param copy_attr_fn Union variable containing the function pointer
* to be used in order to copy the attribute (IN)
* @param delete_attr_fn Function pointer to be used for deleting the
Expand Down Expand Up @@ -277,7 +276,7 @@ OMPI_DECLSPEC int ompi_attr_create_keyval_aint(ompi_attribute_type_t type,

/**
* Free an attribute keyval
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param key key, which is set to MPI_KEY_INVALID (IN/OUT)
* @return OMPI error code
*/
Expand All @@ -286,10 +285,10 @@ int ompi_attr_free_keyval(ompi_attribute_type_t type, int *key,
bool predefined);

/**
* Set an attribute on the comm/win/datatype in a form valid for C.
* Set an attribute on the comm/win/datatype/instance 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 type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The actual Comm/Win/Datatype/Instance 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 pointer (IN)
Expand Down Expand Up @@ -317,8 +316,8 @@ int ompi_attr_set_c(ompi_attribute_type_t type, void *object,
/**
* 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 type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The actual Comm/Win/Datatype/Instance 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)
Expand All @@ -344,11 +343,11 @@ int ompi_attr_set_int(ompi_attribute_type_t type, void *object,
int key, int attribute, bool predefined);

/**
* Set an attribute on the comm/win/datatype in a form valid for
* Set an attribute on the comm/win/datatype/instance in a form valid for
* Fortran MPI-1.
*
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param object The actual Comm/Win/Datatype object (IN)
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The actual Comm/Win/Datatype/Instance 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 pointer (IN)
Expand All @@ -375,11 +374,11 @@ OMPI_DECLSPEC int ompi_attr_set_fint(ompi_attribute_type_t type, void *object,
bool predefined);

/**
* Set an attribute on the comm/win/datatype in a form valid for
* Set an attribute on the comm/win/datatype/instance in a form valid for
* Fortran MPI-2.
*
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param object The actual Comm/Win/Datatype object (IN)
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The actual Comm/Win/Datatype/Instance 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 pointer (IN)
Expand All @@ -406,7 +405,7 @@ OMPI_DECLSPEC int ompi_attr_set_aint(ompi_attribute_type_t type, void *object,
bool predefined);

/**
* Get an attribute on the comm/win/datatype in a form valid for C.
* Get an attribute on the comm/win/datatype/instance in a form valid for C.
*
* @param attr_hash The attribute hash table hanging on the object(IN)
* @param key Key val for the attribute (IN)
Expand All @@ -432,7 +431,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,


/**
* Get an attribute on the comm/win/datatype in a form valid for
* Get an attribute on the comm/win/datatype/instance in a form valid for
* Fortran MPI-1.
*
* @param attr_hash The attribute hash table hanging on the object(IN)
Expand All @@ -459,7 +458,7 @@ int ompi_attr_get_c(opal_hash_table_t *attr_hash, int key,


/**
* Get an attribute on the comm/win/datatype in a form valid for
* Get an attribute on the comm/win/datatype/instance in a form valid for
* Fortran MPI-2.
*
* @param attr_hash The attribute hash table hanging on the object(IN)
Expand All @@ -486,9 +485,9 @@ OMPI_DECLSPEC int ompi_attr_get_aint(opal_hash_table_t *attr_hash, int key,


/**
* 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)
* Delete an attribute on the comm/win/datatype/instance
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The actual Comm/Win/Datatype/Instance object (IN)
* @param attr_hash The attribute hash table hanging on the object(IN)
* @param key Key val for the attribute (IN)
* @param predefined Whether the key is predefined or not 0/1 (IN)
Expand All @@ -503,7 +502,7 @@ int ompi_attr_delete(ompi_attribute_type_t type, void *object,

/**
* This to be used from functions like MPI_*_DUP in order to copy all
* the attributes from the old Comm/Win/Dtype object to a new
* the attributes from the old Comm/Win/Dtype/Instance object to a new
* object.
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param old_object The old COMM/WIN/DTYPE object (IN)
Expand All @@ -512,6 +511,7 @@ int ompi_attr_delete(ompi_attribute_type_t type, void *object,
* @param newattr_hash The attribute hash table hanging on new object(IN)
* @return OMPI error code
*
* Note: not valid for instance objects as they can not be copied
*/

int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,
Expand All @@ -520,10 +520,10 @@ int ompi_attr_copy_all(ompi_attribute_type_t type, void *old_object,


/**
* This to be used to delete all the attributes from the Comm/Win/Dtype
* This to be used to delete all the attributes from the Comm/Win/Dtype/Instance
* object in one shot
* @param type Type of attribute (COMM/WIN/DTYPE) (IN)
* @param object The COMM/WIN/DTYPE object (IN)
* @param type Type of attribute (COMM/WIN/DTYPE/INSTANCE) (IN)
* @param object The COMM/WIN/DTYPE/INSTANCE object (IN)
* @param attr_hash The attribute hash table hanging on the object(IN)
* @return OMPI error code
*
Expand Down
Loading

0 comments on commit c226352

Please sign in to comment.