static s_smpi_mpi_datatype_t mpi_##name = { \
(char*) # name, \
sizeof(type), /* size */ \
- 0, /*was 1 has_subtype*/ \
+ 0, /*was 1 sizeof_substruct*/ \
0, /* lb */ \
sizeof(type), /* ub = lb + size */ \
DT_FLAG_BASIC, /* flags */ \
static s_smpi_mpi_datatype_t mpi_##name = { \
(char*) # name, \
0, /* size */ \
- 0, /* was 1 has_subtype*/ \
+ 0, /* was 1 sizeof_substruct*/ \
0, /* lb */ \
0, /* ub = lb + size */ \
DT_FLAG_BASIC, /* flags */ \
int ret=MPI_SUCCESS;
*new_t= xbt_new(s_smpi_mpi_datatype_t,1);
memcpy(*new_t, datatype, sizeof(s_smpi_mpi_datatype_t));
- if (datatype->has_subtype){
- //FIXME: may copy too much information.
- (*new_t)->substruct=xbt_new(s_smpi_mpi_struct_t,1);
- memcpy((*new_t)->substruct, datatype->substruct, sizeof(s_smpi_mpi_struct_t));
+ (*new_t)->in_use=1;
+ (*new_t)->flags &= ~DT_FLAG_PREDEFINED;
+ if (datatype->sizeof_substruct){
+ (*new_t)->substruct=xbt_malloc(datatype->sizeof_substruct);
+ memcpy((*new_t)->substruct, datatype->substruct, datatype->sizeof_substruct);
}
if(datatype->name)
(*new_t)->name = xbt_strdup(datatype->name);
if(elem && elem->copy_fn!=MPI_NULL_COPY_FN){
ret = elem->copy_fn(datatype, *key, NULL, value_in, &value_out, &flag );
if(ret!=MPI_SUCCESS){
+ smpi_datatype_unuse(*new_t);
*new_t=MPI_DATATYPE_NULL;
return ret;
}
}
void smpi_datatype_set_name(MPI_Datatype datatype, char* name){
+ if(datatype->name!=NULL && !(datatype->flags & DT_FLAG_PREDEFINED))
+ xbt_free(datatype->name);
datatype->name = xbt_strdup(name);;
}
recvcount *= smpi_datatype_size(recvtype);
count = sendcount < recvcount ? sendcount : recvcount;
- if(sendtype->has_subtype == 0 && recvtype->has_subtype == 0) {
+ if(sendtype->sizeof_substruct == 0 && recvtype->sizeof_substruct == 0) {
if(!smpi_process_get_replaying()) memcpy(recvbuf, sendbuf, count);
}
- else if (sendtype->has_subtype == 0)
+ else if (sendtype->sizeof_substruct == 0)
{
s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(recvtype->substruct);
subtype->unserialize( sendbuf, recvbuf, recvcount/smpi_datatype_size(recvtype), subtype, MPI_REPLACE);
}
- else if (recvtype->has_subtype == 0)
+ else if (recvtype->sizeof_substruct == 0)
{
s_smpi_subtype_t *subtype = static_cast<s_smpi_subtype_t*>(sendtype->substruct);
subtype->serialize(sendbuf, recvbuf, sendcount/smpi_datatype_size(sendtype), subtype);
char* noncontiguous_vector_char = (char*)noncontiguous_vector;
for (i = 0; i < type_c->block_count * count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
char* noncontiguous_vector_char = (char*)noncontiguous_vector;
for (i = 0; i < type_c->block_count * count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length,
&type_c->old_type);
/* memcpy(noncontiguous_vector_char,
new_t->base.serialize = &serialize_vector;
new_t->base.unserialize = &unserialize_vector;
new_t->base.subtype_free = &free_vector;
+ new_t->base.subtype_use = &use_vector;
new_t->block_stride = block_stride;
new_t->block_length = block_length;
new_t->block_count = block_count;
return new_t;
}
-void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int has_subtype, void *struct_type,
+void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int sizeof_substruct, void *struct_type,
int flags){
MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1);
new_t->name = NULL;
new_t->size = size;
- new_t->has_subtype = size>0? has_subtype:0;
+ new_t->sizeof_substruct = size>0? sizeof_substruct:0;
new_t->lb = lb;
new_t->ub = ub;
new_t->flags = flags;
new_t->substruct = struct_type;
- new_t->in_use=0;
+ new_t->in_use=1;
new_t->attributes=NULL;
*new_type = new_t;
-#ifdef HAVE_MC
+#if HAVE_MC
if(MC_is_active())
MC_ignore(&(new_t->in_use), sizeof(new_t->in_use));
#endif
void smpi_datatype_free(MPI_Datatype* type){
xbt_assert((*type)->in_use >= 0);
+
+ if((*type)->flags & DT_FLAG_PREDEFINED)return;
+
+ //if still used, mark for deletion
+ if((*type)->in_use!=0){
+ (*type)->flags |=DT_FLAG_DESTROYED;
+ return;
+ }
+
if((*type)->attributes !=NULL){
xbt_dict_cursor_t cursor = NULL;
int* key;
}
}
- if((*type)->flags & DT_FLAG_PREDEFINED)return;
-
- //if still used, mark for deletion
- if((*type)->in_use!=0){
- (*type)->flags |=DT_FLAG_DESTROYED;
- return;
- }
-
- if ((*type)->has_subtype == 1){
- ((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
+ if ((*type)->sizeof_substruct != 0){
+ //((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
xbt_free((*type)->substruct);
}
- if ((*type)->name != NULL){
- xbt_free((*type)->name);
- }
+ xbt_free((*type)->name);
xbt_free(*type);
*type = MPI_DATATYPE_NULL;
}
void smpi_datatype_use(MPI_Datatype type){
+
if(type)type->in_use++;
-#ifdef HAVE_MC
+ if(type->sizeof_substruct!=0){
+ ((s_smpi_subtype_t *)(type)->substruct)->subtype_use(&type);
+ }
+#if HAVE_MC
if(MC_is_active())
MC_ignore(&(type->in_use), sizeof(type->in_use));
#endif
if (type->in_use > 0)
type->in_use--;
- if(type && type->in_use == 0 && (type->flags & DT_FLAG_DESTROYED))
- smpi_datatype_free(&type);
+ if(type->sizeof_substruct!=0){
+ ((s_smpi_subtype_t *)(type)->substruct)->subtype_free(&type);
+ }
-#ifdef HAVE_MC
+ if(type && type->in_use == 0){
+ smpi_datatype_free(&type);
+ }
+#if HAVE_MC
if(MC_is_active())
MC_ignore(&(type->in_use), sizeof(type->in_use));
#endif
}
void free_contiguous(MPI_Datatype* d){
- smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
+ smpi_datatype_unuse(((s_smpi_mpi_contiguous_t *)(*d)->substruct)->old_type);
+}
+
+void use_contiguous(MPI_Datatype* d){
+ smpi_datatype_use(((s_smpi_mpi_contiguous_t *)(*d)->substruct)->old_type);
}
/* Create a Sub type contiguous to be able to serialize and unserialize it the structure s_smpi_mpi_contiguous_t is
* erived from s_smpi_subtype which required the functions unserialize and serialize */
s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count, MPI_Datatype old_type,
int size_oldtype){
+ if(block_count==0)return NULL;
s_smpi_mpi_contiguous_t *new_t= xbt_new(s_smpi_mpi_contiguous_t,1);
new_t->base.serialize = &serialize_contiguous;
new_t->base.unserialize = &unserialize_contiguous;
new_t->base.subtype_free = &free_contiguous;
+ new_t->base.subtype_use = &use_contiguous;
new_t->lb = lb;
new_t->block_count = block_count;
new_t->old_type = old_type;
+ smpi_datatype_use(old_type);
new_t->size_oldtype = size_oldtype;
smpi_datatype_use(old_type);
return new_t;
int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type, MPI_Aint lb)
{
int retval;
- if(old_type->has_subtype){
+ if(old_type->sizeof_substruct){
//handle this case as a hvector with stride equals to the extent of the datatype
return smpi_datatype_hvector(count, 1, smpi_datatype_get_extent(old_type), old_type, new_type);
}
s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, count, old_type,smpi_datatype_size(old_type));
smpi_datatype_create(new_type, count * smpi_datatype_size(old_type),lb,lb + count * smpi_datatype_size(old_type),
- 1,subtype, DT_FLAG_CONTIGUOUS);
+ sizeof(s_smpi_mpi_contiguous_t),subtype, DT_FLAG_CONTIGUOUS);
retval=MPI_SUCCESS;
return retval;
}
lb=smpi_datatype_lb(old_type);
ub=((count-1)*stride+blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
}
- if(old_type->has_subtype || stride != blocklen){
+ if(old_type->sizeof_substruct || stride != blocklen){
s_smpi_mpi_vector_t* subtype = smpi_datatype_vector_create(stride, blocklen, count, old_type,
smpi_datatype_size(old_type));
- smpi_datatype_create(new_type, count * (blocklen) * smpi_datatype_size(old_type), lb, ub, 1, subtype,
+ smpi_datatype_create(new_type, count * (blocklen) * smpi_datatype_size(old_type), lb, ub, sizeof(s_smpi_mpi_vector_t), subtype,
DT_FLAG_VECTOR);
retval=MPI_SUCCESS;
}else{
smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
}
+void use_vector(MPI_Datatype* d){
+ smpi_datatype_use(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
+}
+
/* Hvector Implementation - Vector with stride in bytes */
/* Copies noncontiguous data into contiguous memory.
char* noncontiguous_vector_char = (char*)noncontiguous_hvector;
for (i = 0; i < type_c->block_count * count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_vector_char, noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_vector_char,
char* noncontiguous_vector_char = (char*)noncontiguous_vector;
for (i = 0; i < type_c->block_count * count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_vector_char, noncontiguous_vector_char, &type_c->block_length, &type_c->old_type);
/*memcpy(noncontiguous_vector_char,
contiguous_vector_char, type_c->block_length * type_c->size_oldtype);*/
new_t->base.serialize = &serialize_hvector;
new_t->base.unserialize = &unserialize_hvector;
new_t->base.subtype_free = &free_hvector;
+ new_t->base.subtype_use = &use_hvector;
new_t->block_stride = block_stride;
new_t->block_length = block_length;
new_t->block_count = block_count;
//do nothing for vector types
void free_hvector(MPI_Datatype* d){
- smpi_datatype_unuse(((s_smpi_mpi_indexed_t *)(*d)->substruct)->old_type);
+ smpi_datatype_unuse(((s_smpi_mpi_hvector_t *)(*d)->substruct)->old_type);
+}
+
+void use_hvector(MPI_Datatype* d){
+ smpi_datatype_use(((s_smpi_mpi_hvector_t *)(*d)->substruct)->old_type);
}
int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
lb=smpi_datatype_lb(old_type);
ub=((count-1)*stride)+(blocklen-1)*smpi_datatype_get_extent(old_type)+smpi_datatype_ub(old_type);
}
- if(old_type->has_subtype || stride != blocklen*smpi_datatype_get_extent(old_type)){
+ if(old_type->sizeof_substruct || stride != blocklen*smpi_datatype_get_extent(old_type)){
s_smpi_mpi_hvector_t* subtype = smpi_datatype_hvector_create( stride, blocklen, count, old_type,
smpi_datatype_size(old_type));
- smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type), lb,ub, 1, subtype, DT_FLAG_VECTOR);
+ smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type), lb,ub, sizeof(s_smpi_mpi_hvector_t), subtype, DT_FLAG_VECTOR);
retval=MPI_SUCCESS;
}else{
smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type),0,count * blocklen *
char* noncontiguous_indexed_char = (char*)noncontiguous_indexed+type_c->block_indices[0] * type_c->size_oldtype;
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_indexed_char, noncontiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_indexed_char,
(char*)noncontiguous_indexed+type_c->block_indices[0]*smpi_datatype_get_extent(type_c->old_type);
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_indexed_char, noncontiguous_indexed_char, &type_c->block_lengths[i],
&type_c->old_type);
/*memcpy(noncontiguous_indexed_char ,
}
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);
+ if((*type)->in_use==0){
+ 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);
}
+void use_indexed(MPI_Datatype* type){
+ smpi_datatype_use(((s_smpi_mpi_indexed_t *)(*type)->substruct)->old_type);
+}
+
+
/* Create a Sub type indexed to be able to serialize and unserialize it the structure s_smpi_mpi_indexed_t is derived
* from s_smpi_subtype which required the functions unserialize and serialize */
s_smpi_mpi_indexed_t* smpi_datatype_indexed_create( int* block_lengths, int* block_indices, int block_count,
new_t->base.serialize = &serialize_indexed;
new_t->base.unserialize = &unserialize_indexed;
new_t->base.subtype_free = &free_indexed;
- //TODO : add a custom function for each time to clean these
+ new_t->base.subtype_use = &use_indexed;
new_t->block_lengths= xbt_new(int, block_count);
new_t->block_indices= xbt_new(int, block_count);
int i;
if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )contiguous=0;
}
- if (old_type->has_subtype == 1)
+ if (old_type->sizeof_substruct != 0)
contiguous=0;
if(!contiguous){
s_smpi_mpi_indexed_t* subtype = smpi_datatype_indexed_create( blocklens, indices, count, old_type,
smpi_datatype_size(old_type));
- smpi_datatype_create(new_type, size * smpi_datatype_size(old_type),lb,ub,1, subtype, DT_FLAG_DATA);
+ smpi_datatype_create(new_type, size * smpi_datatype_size(old_type),lb,ub,sizeof(s_smpi_mpi_indexed_t), subtype, DT_FLAG_DATA);
}else{
s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, size, old_type,
smpi_datatype_size(old_type));
- smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub, 1, subtype,
+ smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub, sizeof(s_smpi_mpi_contiguous_t), subtype,
DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
}
retval=MPI_SUCCESS;
char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
memcpy(contiguous_hindexed_char, noncontiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
else
((s_smpi_subtype_t*)type_c->old_type->substruct)->serialize( noncontiguous_hindexed_char,
char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_type->has_subtype == 0)
+ if (type_c->old_type->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_hindexed_char, noncontiguous_hindexed_char, &type_c->block_lengths[i],
&type_c->old_type);
/*memcpy(noncontiguous_hindexed_char,contiguous_hindexed_char,type_c->block_lengths[i]*type_c->size_oldtype);*/
}
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);
+ if((*type)->in_use==0){
+ 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 use_hindexed(MPI_Datatype* type){
+ smpi_datatype_use(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->old_type);
+}
+
/* Create a Sub type hindexed to be able to serialize and unserialize it the structure s_smpi_mpi_hindexed_t is derived
* from s_smpi_subtype which required the functions unserialize and serialize
*/
new_t->base.serialize = &serialize_hindexed;
new_t->base.unserialize = &unserialize_hindexed;
new_t->base.subtype_free = &free_hindexed;
- //TODO : add a custom function for each time to clean these
+ new_t->base.subtype_use = &use_hindexed;
new_t->block_lengths= xbt_new(int, block_count);
new_t->block_indices= xbt_new(MPI_Aint, block_count);
int i;
}
new_t->block_count = block_count;
new_t->old_type = old_type;
+ smpi_datatype_use(old_type);
new_t->size_oldtype = size_oldtype;
return new_t;
}
if ( (i< count -1) && (indices[i]+blocklens[i]*static_cast<int>(smpi_datatype_size(old_type)) != indices[i+1]) )
contiguous=0;
}
- if (old_type->has_subtype == 1 || lb!=0)
+ if (old_type->sizeof_substruct != 0 || lb!=0)
contiguous=0;
if(!contiguous){
s_smpi_mpi_hindexed_t* subtype = smpi_datatype_hindexed_create( blocklens, indices, count, old_type,
smpi_datatype_size(old_type));
- smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub ,1, subtype, DT_FLAG_DATA);
+ smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), lb, ub ,sizeof(s_smpi_mpi_hindexed_t), subtype, DT_FLAG_DATA);
}else{
s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create(lb,size, old_type, smpi_datatype_size(old_type));
smpi_datatype_create(new_type, size * smpi_datatype_size(old_type), 0,size * smpi_datatype_size(old_type),
char* noncontiguous_struct_char = (char*)noncontiguous_struct+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_types[i]->has_subtype == 0)
+ if (type_c->old_types[i]->sizeof_substruct == 0)
memcpy(contiguous_struct_char, noncontiguous_struct_char,
type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
else
char* noncontiguous_struct_char = (char*)noncontiguous_struct+ type_c->block_indices[0];
for(j=0; j<count;j++){
for (i = 0; i < type_c->block_count; i++) {
- if (type_c->old_types[i]->has_subtype == 0)
+ if (type_c->old_types[i]->sizeof_substruct == 0)
smpi_op_apply(op, contiguous_struct_char, noncontiguous_struct_char, &type_c->block_lengths[i],
& type_c->old_types[i]);
/*memcpy(noncontiguous_struct_char,
}
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);
+ if((*type)->in_use==0){
+ xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_lengths);
+ xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_indices);
+ xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types);
+ }
+}
+
+void use_struct(MPI_Datatype* type){
+ int i=0;
+ for (i = 0; i < ((s_smpi_mpi_struct_t *)(*type)->substruct)->block_count; i++)
+ smpi_datatype_use(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types[i]);
}
/* Create a Sub type struct to be able to serialize and unserialize it the structure s_smpi_mpi_struct_t is derived
new_t->base.serialize = &serialize_struct;
new_t->base.unserialize = &unserialize_struct;
new_t->base.subtype_free = &free_struct;
- //TODO : add a custom function for each time to clean these
+ new_t->base.subtype_use = &use_struct;
new_t->block_lengths= xbt_new(int, block_count);
new_t->block_indices= xbt_new(MPI_Aint, block_count);
new_t->old_types= xbt_new(MPI_Datatype, block_count);
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;
new_t->block_count = block_count;
- //new_t->old_types = old_types;
return new_t;
}
for(i=0; i< count; i++){
if (blocklens[i]<0)
return MPI_ERR_ARG;
- if (old_types[i]->has_subtype == 1)
+ if (old_types[i]->sizeof_substruct != 0)
contiguous=0;
size += blocklens[i]*smpi_datatype_size(old_types[i]);
if(!contiguous){
s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocklens, indices, count, old_types);
- smpi_datatype_create(new_type, size, lb, ub,1, subtype, DT_FLAG_DATA);
+ smpi_datatype_create(new_type, size, lb, ub,sizeof(s_smpi_mpi_struct_t), subtype, DT_FLAG_DATA);
}else{
s_smpi_mpi_contiguous_t* subtype = smpi_datatype_contiguous_create( lb, size, MPI_CHAR, 1);
smpi_datatype_create(new_type, size, lb, ub,1, subtype, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
}
#define CREATE_MPI_OP(name, func) \
- static s_smpi_mpi_op_t mpi_##name = { &(func) /* func */, TRUE }; \
+ static s_smpi_mpi_op_t mpi_##name = { &(func) /* func */, true }; \
MPI_Op name = &mpi_##name;
CREATE_MPI_OP(MPI_MAX, max_func);