Commit f1b57b1c authored by David Goodell's avatar David Goodell
Browse files

[svn-r6938] use the new MPIU_OBJ_PUBLISH_HANDLE abstraction

This commit may be slightly conservative in some of the pt2pt code, but
it is not obvious that persistent requests handles don't need to be
published safely.  Until it is proven otherwise, we will take the
write memory barrier hit (on some platforms).

No reviewer.
parent 6c62bbd8
......@@ -48,7 +48,6 @@ int MPIR_Comm_create_keyval_impl(MPI_Comm_copy_attr_function *comm_copy_attr_fn,
field */
keyval_ptr->handle = (keyval_ptr->handle & ~(0x03c00000)) |
(MPID_COMM << 22);
*comm_keyval = keyval_ptr->handle;
MPIU_Object_set_ref(keyval_ptr,1);
keyval_ptr->was_freed = 0;
keyval_ptr->kind = MPID_COMM;
......@@ -58,6 +57,8 @@ int MPIR_Comm_create_keyval_impl(MPI_Comm_copy_attr_function *comm_copy_attr_fn,
keyval_ptr->delfn.user_function = comm_delete_attr_fn;
keyval_ptr->delfn.proxy = MPIR_Attr_delete_c_proxy;
MPIU_OBJ_PUBLISH_HANDLE(*comm_keyval, keyval_ptr->handle);
fn_exit:
return mpi_errno;
fn_fail:
......
......@@ -98,7 +98,6 @@ int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
field */
keyval_ptr->handle = (keyval_ptr->handle & ~(0x03c00000)) |
(MPID_DATATYPE << 22);
*type_keyval = keyval_ptr->handle;
MPIU_Object_set_ref(keyval_ptr,1);
keyval_ptr->was_freed = 0;
keyval_ptr->kind = MPID_DATATYPE;
......@@ -111,6 +110,8 @@ int MPI_Type_create_keyval(MPI_Type_copy_attr_function *type_copy_attr_fn,
/* Tell finalize to check for attributes on permenant types */
MPIR_DatatypeAttrFinalize();
MPIU_OBJ_PUBLISH_HANDLE(*type_keyval, keyval_ptr->handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -98,7 +98,6 @@ int MPI_Win_create_keyval(MPI_Win_copy_attr_function *win_copy_attr_fn,
field */
keyval_ptr->handle = (keyval_ptr->handle & ~(0x03c00000)) |
(MPID_WIN << 22);
*win_keyval = keyval_ptr->handle;
MPIU_Object_set_ref(keyval_ptr,1);
keyval_ptr->was_freed = 0;
keyval_ptr->kind = MPID_WIN;
......@@ -108,6 +107,7 @@ int MPI_Win_create_keyval(MPI_Win_copy_attr_function *win_copy_attr_fn,
keyval_ptr->delfn.user_function = win_delete_attr_fn;
keyval_ptr->delfn.proxy = MPIR_Attr_delete_c_proxy;
MPIU_OBJ_PUBLISH_HANDLE(*win_keyval, keyval_ptr->handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -107,13 +107,13 @@ int MPI_Op_create(MPI_User_function *function, int commute, MPI_Op *op)
}
/* --END ERROR HANDLING-- */
*op = op_ptr->handle;
op_ptr->language = MPID_LANG_C;
op_ptr->kind = commute ? MPID_OP_USER : MPID_OP_USER_NONCOMMUTE;
op_ptr->function.c_function = (void (*)(const void *, void *,
const int *, const MPI_Datatype *))function;
MPIU_Object_set_ref(op_ptr,1);
MPIU_OBJ_PUBLISH_HANDLE(*op, op_ptr->handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -290,7 +290,7 @@ PMPI_LOCAL int MPIR_Comm_create_intra(MPID_Comm *comm_ptr, MPID_Group *group_ptr
mpi_errno = MPIR_Comm_commit(newcomm_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
*newcomm = newcomm_ptr->handle;
MPIU_OBJ_PUBLISH_HANDLE(*newcomm, newcomm_ptr->handle);
}
else {
/* This process is not in the group */
......
......@@ -150,8 +150,8 @@ int MPI_Comm_dup(MPI_Comm comm, MPI_Comm *newcomm)
if (mpi_errno) goto fn_fail;
newcomm_ptr->attributes = new_attributes;
*newcomm = newcomm_ptr->handle;
MPIU_OBJ_PUBLISH_HANDLE(*newcomm, newcomm_ptr->handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -385,7 +385,7 @@ int MPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *newcomm)
mpi_errno = MPIR_Comm_commit(newcomm_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
*newcomm = newcomm_ptr->handle;
MPIU_OBJ_PUBLISH_HANDLE(*newcomm, newcomm_ptr->handle);
}
/* ... end of body of routine ... */
......
......@@ -566,9 +566,8 @@ int MPI_Intercomm_create(MPI_Comm local_comm, int local_leader,
MPID_Dev_comm_create_hook( newcomm_ptr );
mpi_errno = MPIR_Comm_commit(newcomm_ptr);
if (mpi_errno) MPIU_ERR_POP(mpi_errno);
*newintercomm = newcomm_ptr->handle;
MPIU_OBJ_PUBLISH_HANDLE(*newintercomm, newcomm_ptr->handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -53,6 +53,7 @@ int MPI_Type_contiguous(int count,
{
static const char FCNAME[] = "MPI_Type_contiguous";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_CONTIGUOUS);
......@@ -88,11 +89,11 @@ int MPI_Type_contiguous(int count,
mpi_errno = MPID_Type_contiguous(count,
old_type,
new_type_p);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPID_Datatype_get_ptr(*new_type_p, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_CONTIGUOUS,
1, /* ints (count) */
......@@ -104,6 +105,7 @@ int MPI_Type_contiguous(int count,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*new_type_p, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -368,6 +368,7 @@ int MPI_Type_create_darray(int size,
{
static const char FCNAME[] = "MPI_Type_create_darray";
int mpi_errno = MPI_SUCCESS, i;
MPI_Datatype new_handle;
int procs, tmp_rank, tmp_size, blklens[3], *coords;
MPI_Aint *st_offsets, orig_extent, disps[3];
......@@ -675,7 +676,7 @@ int MPI_Type_create_darray(int size,
blklens,
disps,
types,
newtype);
&new_handle);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
/* --END ERROR HANDLING-- */
......@@ -709,7 +710,7 @@ int MPI_Type_create_darray(int size,
ints[i + 3*ndims + 3] = array_of_psizes[i];
}
ints[4*ndims + 3] = order;
MPID_Datatype_get_ptr(*newtype, datatype_ptr);
MPID_Datatype_get_ptr(new_handle, datatype_ptr);
mpi_errno = MPID_Datatype_set_contents(datatype_ptr,
MPI_COMBINER_DARRAY,
4*ndims + 4,
......@@ -722,6 +723,7 @@ int MPI_Type_create_darray(int size,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
/* --END ERROR HANDLING-- */
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -59,6 +59,7 @@ int MPI_Type_create_hindexed(int count,
{
static const char FCNAME[] = "MPI_Type_create_hindexed";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int i, *ints;
MPIU_CHKLMEM_DECL(1);
......@@ -106,7 +107,7 @@ int MPI_Type_create_hindexed(int count,
displacements,
1, /* displacements in bytes */
oldtype,
newtype);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
......@@ -118,7 +119,7 @@ int MPI_Type_create_hindexed(int count,
{
ints[i+1] = blocklengths[i];
}
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_HINDEXED,
count+1, /* ints (count, blocklengths) */
......@@ -130,6 +131,7 @@ int MPI_Type_create_hindexed(int count,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -58,6 +58,7 @@ int MPI_Type_create_hvector(int count,
{
static const char FCNAME[] = "MPI_Type_create_hvector";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int ints[2];
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_CREATE_HVECTOR);
......@@ -96,12 +97,12 @@ int MPI_Type_create_hvector(int count,
stride,
1, /* stride in bytes */
oldtype,
newtype);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
ints[0] = count;
ints[1] = blocklength;
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_HVECTOR,
2, /* ints (count, blocklength) */
......@@ -113,6 +114,7 @@ int MPI_Type_create_hvector(int count,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -80,6 +80,7 @@ int MPI_Type_create_indexed_block(int count,
{
static const char FCNAME[] = "MPI_Type_create_indexed_block";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int i, *ints;
MPIU_CHKLMEM_DECL(1);
......@@ -125,7 +126,7 @@ int MPI_Type_create_indexed_block(int count,
array_of_displacements,
0, /* dispinbytes */
oldtype,
newtype);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
......@@ -139,7 +140,7 @@ int MPI_Type_create_indexed_block(int count,
ints[i+2] = array_of_displacements[i];
}
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_INDEXED_BLOCK,
count + 2, /* ints */
......@@ -150,6 +151,7 @@ int MPI_Type_create_indexed_block(int count,
&oldtype);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -55,6 +55,7 @@ int MPI_Type_create_resized(MPI_Datatype oldtype,
{
static const char FCNAME[] = "MPI_Type_create_resized";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
MPI_Aint aints[2];
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_CREATE_RESIZED);
......@@ -86,7 +87,7 @@ int MPI_Type_create_resized(MPI_Datatype oldtype,
/* ... body of routine ... */
mpi_errno = MPID_Type_create_resized(oldtype, lb, extent, newtype);
mpi_errno = MPID_Type_create_resized(oldtype, lb, extent, &new_handle);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
goto fn_fail;
......@@ -95,7 +96,7 @@ int MPI_Type_create_resized(MPI_Datatype oldtype,
aints[0] = lb;
aints[1] = extent;
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_RESIZED,
0,
......@@ -107,6 +108,7 @@ int MPI_Type_create_resized(MPI_Datatype oldtype,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -61,6 +61,7 @@ int MPI_Type_create_struct(int count,
static const char FCNAME[] = "MPI_Type_create_struct";
int mpi_errno = MPI_SUCCESS;
int i, *ints;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
MPIU_CHKLMEM_DECL(1);
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_CREATE_STRUCT);
......@@ -110,7 +111,7 @@ int MPI_Type_create_struct(int count,
array_of_blocklengths,
array_of_displacements,
array_of_types,
newtype);
&new_handle);
/* --BEGIN ERROR HANDLING-- */
if (mpi_errno != MPI_SUCCESS)
......@@ -125,7 +126,7 @@ int MPI_Type_create_struct(int count,
ints[i+1] = array_of_blocklengths[i];
}
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_STRUCT,
count+1, /* ints (cnt,blklen) */
......@@ -137,6 +138,7 @@ int MPI_Type_create_struct(int count,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -64,6 +64,7 @@ int MPI_Type_create_subarray(int ndims,
{
static const char FCNAME[] = "MPI_Type_create_subarray";
int mpi_errno = MPI_SUCCESS, i;
MPI_Datatype new_handle;
/* these variables are from the original version in ROMIO */
MPI_Aint size, extent, disps[3];
......@@ -284,7 +285,7 @@ int MPI_Type_create_subarray(int ndims,
blklens,
disps,
types,
newtype);
&new_handle);
NMPI_Type_free(&tmp1);
......@@ -308,7 +309,7 @@ int MPI_Type_create_subarray(int ndims,
}
ints[3*ndims + 1] = order;
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_SUBARRAY,
3 * ndims + 2, /* ints */
......@@ -320,6 +321,7 @@ int MPI_Type_create_subarray(int ndims,
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
MPIR_Nest_decr();
......
......@@ -49,6 +49,7 @@ int MPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype)
{
static const char FCNAME[] = "MPI_Type_dup";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *datatype_ptr = NULL;
MPID_Datatype *new_dtp;
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_DUP);
......@@ -90,11 +91,11 @@ int MPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype)
/* ... body of routine ... */
mpi_errno = MPID_Type_dup(datatype, newtype);
mpi_errno = MPID_Type_dup(datatype, &new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_DUP,
0, /* ints */
......@@ -104,7 +105,7 @@ int MPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype)
NULL,
&datatype);
mpi_errno = MPID_Type_commit(newtype);
mpi_errno = MPID_Type_commit(&new_handle);
if (mpi_errno) { MPIU_ERR_POP(mpi_errno); }
/* Copy attributes, executing the attribute copy functions */
......@@ -122,13 +123,13 @@ int MPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype)
if (mpi_errno)
{
MPID_Datatype_release(new_dtp);
*newtype = MPI_DATATYPE_NULL;
goto fn_fail;
}
}
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......@@ -138,6 +139,7 @@ int MPI_Type_dup(MPI_Datatype datatype, MPI_Datatype *newtype)
fn_fail:
/* --BEGIN ERROR HANDLING-- */
*newtype = MPI_DATATYPE_NULL;
# ifdef HAVE_ERROR_CHECKING
{
mpi_errno = MPIR_Err_create_code(
......
......@@ -84,6 +84,7 @@ int MPI_Type_hindexed(int count,
{
static const char FCNAME[] = "MPI_Type_hindexed";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int i, *ints;
MPIU_CHKLMEM_DECL(1);
......@@ -131,7 +132,7 @@ int MPI_Type_hindexed(int count,
indices,
1, /* displacements in bytes */
old_type,
newtype);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_CHKLMEM_MALLOC(ints, int *, (count + 1) * sizeof(int), mpi_errno, "contents integer array");
......@@ -143,7 +144,7 @@ int MPI_Type_hindexed(int count,
ints[i+1] = blocklens[i];
}
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_HINDEXED,
count+1, /* ints */
......@@ -154,6 +155,7 @@ int MPI_Type_hindexed(int count,
&old_type);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -53,6 +53,7 @@ int MPI_Type_hvector(int count,
{
static const char FCNAME[] = "MPI_Type_hvector";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int ints[2];
MPID_MPI_STATE_DECL(MPID_STATE_MPI_TYPE_HVECTOR);
......@@ -91,12 +92,12 @@ int MPI_Type_hvector(int count,
(MPI_Aint) stride,
1, /* stride in bytes */
old_type,
newtype_p);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
ints[0] = count;
ints[1] = blocklen;
MPID_Datatype_get_ptr(*newtype_p, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_HVECTOR,
2, /* ints (count, blocklen) */
......@@ -107,6 +108,7 @@ int MPI_Type_hvector(int count,
&old_type);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype_p, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
......@@ -81,6 +81,7 @@ int MPI_Type_indexed(int count,
{
static const char FCNAME[] = "MPI_Type_indexed";
int mpi_errno = MPI_SUCCESS;
MPI_Datatype new_handle;
MPID_Datatype *new_dtp;
int i, *ints;
MPIU_CHKLMEM_DECL(1);
......@@ -129,7 +130,7 @@ int MPI_Type_indexed(int count,
indices,
0, /* displacements not in bytes */
old_type,
newtype);
&new_handle);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
/* copy all integer values into a temporary buffer; this
......@@ -145,7 +146,7 @@ int MPI_Type_indexed(int count,
for (i=0; i < count; i++) {
ints[i + count + 1] = indices[i];
}
MPID_Datatype_get_ptr(*newtype, new_dtp);
MPID_Datatype_get_ptr(new_handle, new_dtp);
mpi_errno = MPID_Datatype_set_contents(new_dtp,
MPI_COMBINER_INDEXED,
2*count + 1, /* ints */
......@@ -156,6 +157,7 @@ int MPI_Type_indexed(int count,
&old_type);
if (mpi_errno != MPI_SUCCESS) goto fn_fail;
MPIU_OBJ_PUBLISH_HANDLE(*newtype, new_handle);
/* ... end of body of routine ... */
fn_exit:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment