return datatype->ub;
}
+MPI_Datatype smpi_datatype_dup(MPI_Datatype datatype)
+{
+ MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1);
+ memcpy(new_t, datatype, sizeof(s_smpi_mpi_datatype_t));
+ if (datatype->has_subtype)
+ memcpy(new_t->substruct, datatype->substruct, sizeof(s_smpi_subtype_t));
+ return new_t;
+}
+
int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
MPI_Aint * extent)
{
new_t->block_stride = block_stride;
new_t->block_length = block_length;
new_t->block_count = block_count;
+ smpi_datatype_use(old_type);
new_t->old_type = old_type;
new_t->size_oldtype = size_oldtype;
return new_t;
void smpi_datatype_unuse(MPI_Datatype type){
if(type && type->in_use-- == 0 && (type->flags & DT_FLAG_DESTROYED))
smpi_datatype_free(&type);
-
+
#ifdef HAVE_MC
if(MC_is_active())
MC_ignore(&(type->in_use), sizeof(type->in_use));
}
void free_contiguous(MPI_Datatype* d){
+ smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
}
/*
new_t->block_count = block_count;
new_t->old_type = old_type;
new_t->size_oldtype = size_oldtype;
+ smpi_datatype_use(old_type);
return new_t;
}
}
void free_vector(MPI_Datatype* d){
+ smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
}
/*
new_t->block_count = block_count;
new_t->old_type = old_type;
new_t->size_oldtype = size_oldtype;
+ smpi_datatype_use(old_type);
return new_t;
}
//do nothing for vector types
void free_hvector(MPI_Datatype* d){
+ smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
}
int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
void free_indexed(MPI_Datatype* type){
xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_lengths);
xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_indices);
+ smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
}
/*
new_t->block_indices[i]=block_indices[i];
}
new_t->block_count = block_count;
+ smpi_datatype_use(old_type);
new_t->old_type = old_type;
new_t->size_oldtype = size_oldtype;
return new_t;
void free_hindexed(MPI_Datatype* type){
xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_lengths);
xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_indices);
+ smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
}
/*
void free_struct(MPI_Datatype* type){
xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_lengths);
xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_indices);
+ int i=0;
+ for (i = 0; i < ((s_smpi_mpi_struct_t *)(*type)->substruct)->block_count; i++)
+ smpi_datatype_unuse(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types[i]);
xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types);
}
new_t->block_lengths[i]=block_lengths[i];
new_t->block_indices[i]=block_indices[i];
new_t->old_types[i]=old_types[i];
+ smpi_datatype_use(new_t->old_types[i]);
}
//new_t->block_lengths = block_lengths;
//new_t->block_indices = block_indices;
#define BXOR_OP(a, b) (b) ^= (a)
#define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : (a)
#define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : (b)
-//TODO : MINLOC & MAXLOC
+#define REPLACE_OP(a,b) (b) = (a)
#define APPLY_FUNC(a, b, length, type, func) \
{ \
}
}
+static void replace_func(void *a, void *b, int *length,
+ MPI_Datatype * datatype)
+{
+ if (*datatype == MPI_CHAR) {
+ APPLY_FUNC(a, b, length, char, REPLACE_OP);
+ } else if (*datatype == MPI_SHORT) {
+ APPLY_FUNC(a, b, length, short, REPLACE_OP);
+ } else if (*datatype == MPI_INT) {
+ APPLY_FUNC(a, b, length, int, REPLACE_OP);
+ } else if (*datatype == MPI_LONG) {
+ APPLY_FUNC(a, b, length, long, REPLACE_OP);
+ } else if (*datatype == MPI_UNSIGNED_SHORT) {
+ APPLY_FUNC(a, b, length, unsigned short, REPLACE_OP);
+ } else if (*datatype == MPI_UNSIGNED) {
+ APPLY_FUNC(a, b, length, unsigned int, REPLACE_OP);
+ } else if (*datatype == MPI_UNSIGNED_LONG) {
+ APPLY_FUNC(a, b, length, unsigned long, REPLACE_OP);
+ } else if (*datatype == MPI_BYTE) {
+ APPLY_FUNC(a, b, length, uint8_t, REPLACE_OP);
+ }
+}
#define CREATE_MPI_OP(name, func) \
static s_smpi_mpi_op_t mpi_##name = { &(func) /* func */, TRUE }; \
CREATE_MPI_OP(MPI_BXOR, bxor_func);
CREATE_MPI_OP(MPI_MAXLOC, maxloc_func);
CREATE_MPI_OP(MPI_MINLOC, minloc_func);
+CREATE_MPI_OP(MPI_REPLACE, replace_func);
+
MPI_Op smpi_op_new(MPI_User_function * function, int commute)
{