1 /* smpi_mpi_dt.c -- MPI primitives to handle datatypes */
2 /* FIXME: a very incomplete implementation */
4 /* Copyright (c) 2009, 2010. The SimGrid Team.
5 * All rights reserved. */
7 /* This program is free software; you can redistribute it and/or modify it
8 * under the terms of the license (GNU LGPL) which comes with this package. */
15 #include "smpi_mpi_dt_private.h"
17 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi,
18 "Logging specific to SMPI (datatype)");
20 #define CREATE_MPI_DATATYPE(name, type) \
21 static s_smpi_mpi_datatype_t mpi_##name = { \
22 sizeof(type), /* size */ \
23 0, /*was 1 has_subtype*/ \
25 sizeof(type), /* ub = lb + size */ \
26 DT_FLAG_BASIC, /* flags */ \
27 NULL /* pointer on extended struct*/ \
29 MPI_Datatype name = &mpi_##name;
31 #define CREATE_MPI_DATATYPE_NULL(name) \
32 static s_smpi_mpi_datatype_t mpi_##name = { \
34 0, /*was 1 has_subtype*/ \
36 0, /* ub = lb + size */ \
37 DT_FLAG_BASIC, /* flags */ \
38 NULL /* pointer on extended struct*/ \
40 MPI_Datatype name = &mpi_##name;
42 //The following are datatypes for the MPI functions MPI_MAXLOC and MPI_MINLOC.
68 // Predefined data types
69 CREATE_MPI_DATATYPE(MPI_CHAR, char);
70 CREATE_MPI_DATATYPE(MPI_SHORT, short);
71 CREATE_MPI_DATATYPE(MPI_INT, int);
72 CREATE_MPI_DATATYPE(MPI_LONG, long);
73 CREATE_MPI_DATATYPE(MPI_LONG_LONG, long long);
74 CREATE_MPI_DATATYPE(MPI_SIGNED_CHAR, signed char);
75 CREATE_MPI_DATATYPE(MPI_UNSIGNED_CHAR, unsigned char);
76 CREATE_MPI_DATATYPE(MPI_UNSIGNED_SHORT, unsigned short);
77 CREATE_MPI_DATATYPE(MPI_UNSIGNED, unsigned int);
78 CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG, unsigned long);
79 CREATE_MPI_DATATYPE(MPI_UNSIGNED_LONG_LONG, unsigned long long);
80 CREATE_MPI_DATATYPE(MPI_FLOAT, float);
81 CREATE_MPI_DATATYPE(MPI_DOUBLE, double);
82 CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE, long double);
83 CREATE_MPI_DATATYPE(MPI_WCHAR, wchar_t);
84 CREATE_MPI_DATATYPE(MPI_C_BOOL, _Bool);
85 CREATE_MPI_DATATYPE(MPI_INT8_T, int8_t);
86 CREATE_MPI_DATATYPE(MPI_INT16_T, int16_t);
87 CREATE_MPI_DATATYPE(MPI_INT32_T, int32_t);
88 CREATE_MPI_DATATYPE(MPI_INT64_T, int64_t);
89 CREATE_MPI_DATATYPE(MPI_UINT8_T, uint8_t);
90 CREATE_MPI_DATATYPE(MPI_UINT16_T, uint16_t);
91 CREATE_MPI_DATATYPE(MPI_UINT32_T, uint32_t);
92 CREATE_MPI_DATATYPE(MPI_UINT64_T, uint64_t);
93 CREATE_MPI_DATATYPE(MPI_C_FLOAT_COMPLEX, float _Complex);
94 CREATE_MPI_DATATYPE(MPI_C_DOUBLE_COMPLEX, double _Complex);
95 CREATE_MPI_DATATYPE(MPI_C_LONG_DOUBLE_COMPLEX, long double _Complex);
96 CREATE_MPI_DATATYPE(MPI_AINT, MPI_Aint);
97 CREATE_MPI_DATATYPE(MPI_OFFSET, MPI_Offset);
99 CREATE_MPI_DATATYPE(MPI_FLOAT_INT, float_int);
100 CREATE_MPI_DATATYPE(MPI_LONG_INT, long_int);
101 CREATE_MPI_DATATYPE(MPI_DOUBLE_INT, double_int);
102 CREATE_MPI_DATATYPE(MPI_SHORT_INT, short_int);
103 CREATE_MPI_DATATYPE(MPI_2INT, int_int);
104 CREATE_MPI_DATATYPE(MPI_LONG_DOUBLE_INT, long_double_int);
106 CREATE_MPI_DATATYPE_NULL(MPI_UB);
107 CREATE_MPI_DATATYPE_NULL(MPI_LB);
109 CREATE_MPI_DATATYPE(MPI_PTR, void*);
112 size_t smpi_datatype_size(MPI_Datatype datatype)
114 return datatype->size;
119 MPI_Aint smpi_datatype_lb(MPI_Datatype datatype)
124 MPI_Aint smpi_datatype_ub(MPI_Datatype datatype)
129 int smpi_datatype_extent(MPI_Datatype datatype, MPI_Aint * lb,
134 if ((datatype->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
135 retval = MPI_ERR_TYPE;
138 *extent = datatype->ub - datatype->lb;
139 retval = MPI_SUCCESS;
144 int smpi_datatype_copy(void *sendbuf, int sendcount, MPI_Datatype sendtype,
145 void *recvbuf, int recvcount, MPI_Datatype recvtype)
149 /* First check if we really have something to do */
150 if (recvcount == 0) {
151 retval = sendcount == 0 ? MPI_SUCCESS : MPI_ERR_TRUNCATE;
153 /* FIXME: treat packed cases */
154 sendcount *= smpi_datatype_size(sendtype);
155 recvcount *= smpi_datatype_size(recvtype);
156 count = sendcount < recvcount ? sendcount : recvcount;
158 if(sendtype->has_subtype == 0 && recvtype->has_subtype == 0) {
159 memcpy(recvbuf, sendbuf, count);
161 else if (sendtype->has_subtype == 0)
163 s_smpi_subtype_t *subtype = recvtype->substruct;
164 subtype->unserialize( sendbuf, recvbuf,1, subtype);
166 else if (recvtype->has_subtype == 0)
168 s_smpi_subtype_t *subtype = sendtype->substruct;
169 subtype->serialize(sendbuf, recvbuf,1, subtype);
171 s_smpi_subtype_t *subtype = sendtype->substruct;
173 s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)sendtype;
175 void * buf_tmp = malloc(count * type_c->size_oldtype);
177 subtype->serialize( sendbuf, buf_tmp,1, subtype);
178 subtype = recvtype->substruct;
179 subtype->unserialize(recvbuf, buf_tmp,1, subtype);
183 retval = sendcount > recvcount ? MPI_ERR_TRUNCATE : MPI_SUCCESS;
190 * Copies noncontiguous data into contiguous memory.
191 * @param contiguous_vector - output vector
192 * @param noncontiguous_vector - input vector
193 * @param type - pointer contening :
194 * - stride - stride of between noncontiguous data
195 * - block_length - the width or height of blocked matrix
196 * - count - the number of rows of matrix
198 void serialize_vector( const void *noncontiguous_vector,
199 void *contiguous_vector,
203 s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
205 char* contiguous_vector_char = (char*)contiguous_vector;
206 char* noncontiguous_vector_char = (char*)noncontiguous_vector;
208 for (i = 0; i < type_c->block_count * count; i++) {
209 memcpy(contiguous_vector_char,
210 noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
212 contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
213 noncontiguous_vector_char += type_c->block_stride*type_c->size_oldtype;
218 * Copies contiguous data into noncontiguous memory.
219 * @param noncontiguous_vector - output vector
220 * @param contiguous_vector - input vector
221 * @param type - pointer contening :
222 * - stride - stride of between noncontiguous data
223 * - block_length - the width or height of blocked matrix
224 * - count - the number of rows of matrix
226 void unserialize_vector( const void *contiguous_vector,
227 void *noncontiguous_vector,
231 s_smpi_mpi_vector_t* type_c = (s_smpi_mpi_vector_t*)type;
234 char* contiguous_vector_char = (char*)contiguous_vector;
235 char* noncontiguous_vector_char = (char*)noncontiguous_vector;
237 for (i = 0; i < type_c->block_count * count; i++) {
238 memcpy(noncontiguous_vector_char,
239 contiguous_vector_char, type_c->block_length * type_c->size_oldtype);
241 contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
242 noncontiguous_vector_char += type_c->block_stride*type_c->size_oldtype;
247 * Create a Sub type vector to be able to serialize and unserialize it
248 * the structure s_smpi_mpi_vector_t is derived from s_smpi_subtype which
249 * required the functions unserialize and serialize
252 s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride,
255 MPI_Datatype old_type,
257 s_smpi_mpi_vector_t *new_t= xbt_new(s_smpi_mpi_vector_t,1);
258 new_t->base.serialize = &serialize_vector;
259 new_t->base.unserialize = &unserialize_vector;
260 new_t->base.subtype_free = &free_vector;
261 new_t->block_stride = block_stride;
262 new_t->block_length = block_length;
263 new_t->block_count = block_count;
264 new_t->old_type = old_type;
265 new_t->size_oldtype = size_oldtype;
269 void smpi_datatype_create(MPI_Datatype* new_type, int size, int has_subtype,
270 void *struct_type, int flags){
271 MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1);
273 new_t->has_subtype = has_subtype;
276 new_t->flags = flags;
277 new_t->substruct = struct_type;
281 void smpi_datatype_free(MPI_Datatype* type){
282 if ((*type)->has_subtype == 1){
283 ((s_smpi_subtype_t *)(*type)->substruct)->subtype_free(type);
288 int smpi_datatype_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_type)
291 if ((old_type->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
292 retval = MPI_ERR_TYPE;
294 smpi_datatype_create(new_type, count *
295 smpi_datatype_size(old_type),0,NULL, DT_FLAG_CONTIGUOUS);
301 int smpi_datatype_vector(int count, int blocklen, int stride, MPI_Datatype old_type, MPI_Datatype* new_type)
304 if (blocklen<=0) return MPI_ERR_ARG;
305 if ((old_type->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
306 retval = MPI_ERR_TYPE;
308 if(stride != blocklen){
309 if (old_type->has_subtype == 1)
310 XBT_WARN("vector contains a complex type - not yet handled");
311 s_smpi_mpi_vector_t* subtype = smpi_datatype_vector_create( stride,
315 smpi_datatype_size(old_type));
317 smpi_datatype_create(new_type, count * (blocklen) *
318 smpi_datatype_size(old_type),
324 /* in this situation the data are contignous thus it's not
325 * required to serialize and unserialize it*/
326 smpi_datatype_create(new_type, count * blocklen *
327 smpi_datatype_size(old_type),
330 DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS);
337 void free_vector(MPI_Datatype* d){
341 Hvector Implementation - Vector with stride in bytes
346 * Copies noncontiguous data into contiguous memory.
347 * @param contiguous_hvector - output hvector
348 * @param noncontiguous_hvector - input hvector
349 * @param type - pointer contening :
350 * - stride - stride of between noncontiguous data, in bytes
351 * - block_length - the width or height of blocked matrix
352 * - count - the number of rows of matrix
354 void serialize_hvector( const void *noncontiguous_hvector,
355 void *contiguous_hvector,
359 s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
361 char* contiguous_vector_char = (char*)contiguous_hvector;
362 char* noncontiguous_vector_char = (char*)noncontiguous_hvector;
364 for (i = 0; i < type_c->block_count * count; i++) {
365 memcpy(contiguous_vector_char,
366 noncontiguous_vector_char, type_c->block_length * type_c->size_oldtype);
368 contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
369 noncontiguous_vector_char += type_c->block_stride;
373 * Copies contiguous data into noncontiguous memory.
374 * @param noncontiguous_vector - output hvector
375 * @param contiguous_vector - input hvector
376 * @param type - pointer contening :
377 * - stride - stride of between noncontiguous data, in bytes
378 * - block_length - the width or height of blocked matrix
379 * - count - the number of rows of matrix
381 void unserialize_hvector( const void *contiguous_vector,
382 void *noncontiguous_vector,
386 s_smpi_mpi_hvector_t* type_c = (s_smpi_mpi_hvector_t*)type;
389 char* contiguous_vector_char = (char*)contiguous_vector;
390 char* noncontiguous_vector_char = (char*)noncontiguous_vector;
392 for (i = 0; i < type_c->block_count * count; i++) {
393 memcpy(noncontiguous_vector_char,
394 contiguous_vector_char, type_c->block_length * type_c->size_oldtype);
396 contiguous_vector_char += type_c->block_length*type_c->size_oldtype;
397 noncontiguous_vector_char += type_c->block_stride;
402 * Create a Sub type vector to be able to serialize and unserialize it
403 * the structure s_smpi_mpi_vector_t is derived from s_smpi_subtype which
404 * required the functions unserialize and serialize
407 s_smpi_mpi_hvector_t* smpi_datatype_hvector_create( MPI_Aint block_stride,
410 MPI_Datatype old_type,
412 s_smpi_mpi_hvector_t *new_t= xbt_new(s_smpi_mpi_hvector_t,1);
413 new_t->base.serialize = &serialize_hvector;
414 new_t->base.unserialize = &unserialize_hvector;
415 new_t->base.subtype_free = &free_hvector;
416 new_t->block_stride = block_stride;
417 new_t->block_length = block_length;
418 new_t->block_count = block_count;
419 new_t->old_type = old_type;
420 new_t->size_oldtype = size_oldtype;
424 //do nothing for vector types
425 void free_hvector(MPI_Datatype* d){
428 int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype old_type, MPI_Datatype* new_type)
431 if (blocklen<=0) return MPI_ERR_ARG;
432 if ((old_type->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
433 retval = MPI_ERR_TYPE;
435 if (old_type->has_subtype == 1)
436 XBT_WARN("hvector contains a complex type - not yet handled");
437 if(stride != blocklen*smpi_datatype_size(old_type)){
438 s_smpi_mpi_hvector_t* subtype = smpi_datatype_hvector_create( stride,
442 smpi_datatype_size(old_type));
444 smpi_datatype_create(new_type, count * blocklen *
445 smpi_datatype_size(old_type),
451 smpi_datatype_create(new_type, count * blocklen *
452 smpi_datatype_size(old_type),
455 DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS);
464 Indexed Implementation
468 * Copies noncontiguous data into contiguous memory.
469 * @param contiguous_indexed - output indexed
470 * @param noncontiguous_indexed - input indexed
471 * @param type - pointer contening :
472 * - block_lengths - the width or height of blocked matrix
473 * - block_indices - indices of each data, in element
474 * - count - the number of rows of matrix
476 void serialize_indexed( const void *noncontiguous_indexed,
477 void *contiguous_indexed,
481 s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
483 char* contiguous_indexed_char = (char*)contiguous_indexed;
484 char* noncontiguous_indexed_char = (char*)noncontiguous_indexed;
485 for(j=0; j<count;j++){
486 for (i = 0; i < type_c->block_count; i++) {
487 memcpy(contiguous_indexed_char,
488 noncontiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
490 contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
491 if (i<type_c->block_count-1)noncontiguous_indexed_char = (char*)noncontiguous_indexed + type_c->block_indices[i+1]*type_c->size_oldtype;
492 else noncontiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
494 noncontiguous_indexed=(void*)noncontiguous_indexed_char;
498 * Copies contiguous data into noncontiguous memory.
499 * @param noncontiguous_indexed - output indexed
500 * @param contiguous_indexed - input indexed
501 * @param type - pointer contening :
502 * - block_lengths - the width or height of blocked matrix
503 * - block_indices - indices of each data, in element
504 * - count - the number of rows of matrix
506 void unserialize_indexed( const void *contiguous_indexed,
507 void *noncontiguous_indexed,
511 s_smpi_mpi_indexed_t* type_c = (s_smpi_mpi_indexed_t*)type;
514 char* contiguous_indexed_char = (char*)contiguous_indexed;
515 char* noncontiguous_indexed_char = (char*)noncontiguous_indexed;
516 for(j=0; j<count;j++){
517 for (i = 0; i < type_c->block_count; i++) {
518 memcpy(noncontiguous_indexed_char,
519 contiguous_indexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
521 contiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
522 if (i<type_c->block_count-1)noncontiguous_indexed_char = (char*)noncontiguous_indexed + type_c->block_indices[i+1]*type_c->size_oldtype;
523 else noncontiguous_indexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
525 noncontiguous_indexed=(void*)noncontiguous_indexed_char;
529 void free_indexed(MPI_Datatype* type){
530 xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_lengths);
531 xbt_free(((s_smpi_mpi_indexed_t *)(*type)->substruct)->block_indices);
535 * Create a Sub type indexed to be able to serialize and unserialize it
536 * the structure s_smpi_mpi_indexed_t is derived from s_smpi_subtype which
537 * required the functions unserialize and serialize
539 s_smpi_mpi_indexed_t* smpi_datatype_indexed_create( int* block_lengths,
542 MPI_Datatype old_type,
544 s_smpi_mpi_indexed_t *new_t= xbt_new(s_smpi_mpi_indexed_t,1);
545 new_t->base.serialize = &serialize_indexed;
546 new_t->base.unserialize = &unserialize_indexed;
547 new_t->base.subtype_free = &free_indexed;
548 //TODO : add a custom function for each time to clean these
549 new_t->block_lengths= xbt_new(int, block_count);
550 new_t->block_indices= xbt_new(int, block_count);
552 for(i=0;i<block_count;i++){
553 new_t->block_lengths[i]=block_lengths[i];
554 new_t->block_indices[i]=block_indices[i];
556 new_t->block_count = block_count;
557 new_t->old_type = old_type;
558 new_t->size_oldtype = size_oldtype;
563 int smpi_datatype_indexed(int count, int* blocklens, int* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
569 for(i=0; i< count; i++){
572 size += blocklens[i];
574 if ( (i< count -1) && (indices[i]+blocklens[i] != indices[i+1]) )contiguous=0;
576 if ((old_type->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
577 retval = MPI_ERR_TYPE;
580 if (old_type->has_subtype == 1)
581 XBT_WARN("indexed contains a complex type - not yet handled");
584 s_smpi_mpi_indexed_t* subtype = smpi_datatype_indexed_create( blocklens,
588 smpi_datatype_size(old_type));
590 smpi_datatype_create(new_type, size *
591 smpi_datatype_size(old_type),1, subtype, DT_FLAG_DATA);
593 smpi_datatype_create(new_type, size *
594 smpi_datatype_size(old_type),0, NULL, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
603 Hindexed Implementation - Indexed with indices in bytes
607 * Copies noncontiguous data into contiguous memory.
608 * @param contiguous_hindexed - output hindexed
609 * @param noncontiguous_hindexed - input hindexed
610 * @param type - pointer contening :
611 * - block_lengths - the width or height of blocked matrix
612 * - block_indices - indices of each data, in bytes
613 * - count - the number of rows of matrix
615 void serialize_hindexed( const void *noncontiguous_hindexed,
616 void *contiguous_hindexed,
620 s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
622 char* contiguous_hindexed_char = (char*)contiguous_hindexed;
623 char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed;
624 for(j=0; j<count;j++){
625 for (i = 0; i < type_c->block_count; i++) {
626 memcpy(contiguous_hindexed_char,
627 noncontiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
629 contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
630 if (i<type_c->block_count-1)noncontiguous_hindexed_char = (char*)noncontiguous_hindexed + type_c->block_indices[i+1];
631 else noncontiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
633 noncontiguous_hindexed=(void*)noncontiguous_hindexed_char;
637 * Copies contiguous data into noncontiguous memory.
638 * @param noncontiguous_hindexed - output hindexed
639 * @param contiguous_hindexed - input hindexed
640 * @param type - pointer contening :
641 * - block_lengths - the width or height of blocked matrix
642 * - block_indices - indices of each data, in bytes
643 * - count - the number of rows of matrix
645 void unserialize_hindexed( const void *contiguous_hindexed,
646 void *noncontiguous_hindexed,
650 s_smpi_mpi_hindexed_t* type_c = (s_smpi_mpi_hindexed_t*)type;
653 char* contiguous_hindexed_char = (char*)contiguous_hindexed;
654 char* noncontiguous_hindexed_char = (char*)noncontiguous_hindexed;
655 for(j=0; j<count;j++){
656 for (i = 0; i < type_c->block_count; i++) {
657 memcpy(noncontiguous_hindexed_char,
658 contiguous_hindexed_char, type_c->block_lengths[i] * type_c->size_oldtype);
660 contiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
661 if (i<type_c->block_count-1)noncontiguous_hindexed_char = (char*)noncontiguous_hindexed + type_c->block_indices[i+1];
662 else noncontiguous_hindexed_char += type_c->block_lengths[i]*type_c->size_oldtype;
664 noncontiguous_hindexed=(void*)noncontiguous_hindexed_char;
668 void free_hindexed(MPI_Datatype* type){
669 xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_lengths);
670 xbt_free(((s_smpi_mpi_hindexed_t *)(*type)->substruct)->block_indices);
674 * Create a Sub type hindexed to be able to serialize and unserialize it
675 * the structure s_smpi_mpi_hindexed_t is derived from s_smpi_subtype which
676 * required the functions unserialize and serialize
678 s_smpi_mpi_hindexed_t* smpi_datatype_hindexed_create( int* block_lengths,
679 MPI_Aint* block_indices,
681 MPI_Datatype old_type,
683 s_smpi_mpi_hindexed_t *new_t= xbt_new(s_smpi_mpi_hindexed_t,1);
684 new_t->base.serialize = &serialize_hindexed;
685 new_t->base.unserialize = &unserialize_hindexed;
686 new_t->base.subtype_free = &free_hindexed;
687 //TODO : add a custom function for each time to clean these
688 new_t->block_lengths= xbt_new(int, block_count);
689 new_t->block_indices= xbt_new(MPI_Aint, block_count);
691 for(i=0;i<block_count;i++){
692 new_t->block_lengths[i]=block_lengths[i];
693 new_t->block_indices[i]=block_indices[i];
695 new_t->block_count = block_count;
696 new_t->old_type = old_type;
697 new_t->size_oldtype = size_oldtype;
702 int smpi_datatype_hindexed(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype old_type, MPI_Datatype* new_type)
708 for(i=0; i< count; i++){
711 size += blocklens[i];
714 if ( (i< count -1) && (indices[i]+blocklens[i]*smpi_datatype_size(old_type) != indices[i+1]) )contiguous=0;
716 if ((old_type->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED) {
717 retval = MPI_ERR_TYPE;
719 if (old_type->has_subtype == 1)
720 XBT_WARN("hindexed contains a complex type - not yet handled");
723 s_smpi_mpi_hindexed_t* subtype = smpi_datatype_hindexed_create( blocklens,
727 smpi_datatype_size(old_type));
729 smpi_datatype_create(new_type, size *
730 smpi_datatype_size(old_type),1, subtype, DT_FLAG_DATA);
732 smpi_datatype_create(new_type, size *
733 smpi_datatype_size(old_type),0, NULL, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
742 struct Implementation - Indexed with indices in bytes
746 * Copies noncontiguous data into contiguous memory.
747 * @param contiguous_struct - output struct
748 * @param noncontiguous_struct - input struct
749 * @param type - pointer contening :
750 * - stride - stride of between noncontiguous data
751 * - block_length - the width or height of blocked matrix
752 * - count - the number of rows of matrix
754 void serialize_struct( const void *noncontiguous_struct,
755 void *contiguous_struct,
759 s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
761 char* contiguous_struct_char = (char*)contiguous_struct;
762 char* noncontiguous_struct_char = (char*)noncontiguous_struct;
763 for(j=0; j<count;j++){
764 for (i = 0; i < type_c->block_count; i++) {
765 memcpy(contiguous_struct_char,
766 noncontiguous_struct_char, type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
767 contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
768 if (i<type_c->block_count-1)noncontiguous_struct_char = (char*)noncontiguous_struct + type_c->block_indices[i+1];
769 else noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);//let's hope this is MPI_UB ?
771 noncontiguous_struct=(void*)noncontiguous_struct_char;
775 * Copies contiguous data into noncontiguous memory.
776 * @param noncontiguous_struct - output struct
777 * @param contiguous_struct - input struct
778 * @param type - pointer contening :
779 * - stride - stride of between noncontiguous data
780 * - block_length - the width or height of blocked matrix
781 * - count - the number of rows of matrix
783 void unserialize_struct( const void *contiguous_struct,
784 void *noncontiguous_struct,
788 s_smpi_mpi_struct_t* type_c = (s_smpi_mpi_struct_t*)type;
791 char* contiguous_struct_char = (char*)contiguous_struct;
792 char* noncontiguous_struct_char = (char*)noncontiguous_struct;
793 for(j=0; j<count;j++){
794 for (i = 0; i < type_c->block_count; i++) {
795 memcpy(noncontiguous_struct_char,
796 contiguous_struct_char, type_c->block_lengths[i] * smpi_datatype_size(type_c->old_types[i]));
797 contiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
798 if (i<type_c->block_count-1)noncontiguous_struct_char = (char*)noncontiguous_struct + type_c->block_indices[i+1];
799 else noncontiguous_struct_char += type_c->block_lengths[i]*smpi_datatype_size(type_c->old_types[i]);
801 noncontiguous_struct=(void*)noncontiguous_struct_char;
806 void free_struct(MPI_Datatype* type){
807 xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_lengths);
808 xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->block_indices);
809 xbt_free(((s_smpi_mpi_struct_t *)(*type)->substruct)->old_types);
813 * Create a Sub type struct to be able to serialize and unserialize it
814 * the structure s_smpi_mpi_struct_t is derived from s_smpi_subtype which
815 * required the functions unserialize and serialize
817 s_smpi_mpi_struct_t* smpi_datatype_struct_create( int* block_lengths,
818 MPI_Aint* block_indices,
820 MPI_Datatype* old_types){
821 s_smpi_mpi_struct_t *new_t= xbt_new(s_smpi_mpi_struct_t,1);
822 new_t->base.serialize = &serialize_struct;
823 new_t->base.unserialize = &unserialize_struct;
824 new_t->base.subtype_free = &free_struct;
825 //TODO : add a custom function for each time to clean these
826 new_t->block_lengths= xbt_new(int, block_count);
827 new_t->block_indices= xbt_new(MPI_Aint, block_count);
828 new_t->old_types= xbt_new(MPI_Datatype, block_count);
830 for(i=0;i<block_count;i++){
831 new_t->block_lengths[i]=block_lengths[i];
832 new_t->block_indices[i]=block_indices[i];
833 new_t->old_types[i]=old_types[i];
835 //new_t->block_lengths = block_lengths;
836 //new_t->block_indices = block_indices;
837 new_t->block_count = block_count;
838 //new_t->old_types = old_types;
843 int smpi_datatype_struct(int count, int* blocklens, MPI_Aint* indices, MPI_Datatype* old_types, MPI_Datatype* new_type)
849 for(i=0; i< count; i++){
852 if ((old_types[i]->flags & DT_FLAG_COMMITED) != DT_FLAG_COMMITED)
854 if (old_types[i]->has_subtype == 1)
855 XBT_WARN("Struct contains a complex type - not yet handled");
856 size += blocklens[i]*smpi_datatype_size(old_types[i]);
858 if ( (i< count -1) && (indices[i]+blocklens[i]*smpi_datatype_size(old_types[i]) != indices[i+1]) )contiguous=0;
862 s_smpi_mpi_struct_t* subtype = smpi_datatype_struct_create( blocklens,
867 smpi_datatype_create(new_type, size ,1, subtype, DT_FLAG_DATA);
869 smpi_datatype_create(new_type, size,0, NULL, DT_FLAG_DATA|DT_FLAG_CONTIGUOUS);
874 void smpi_datatype_commit(MPI_Datatype *datatype)
876 (*datatype)->flags= ((*datatype)->flags | DT_FLAG_COMMITED);
879 typedef struct s_smpi_mpi_op {
880 MPI_User_function *func;
883 #define MAX_OP(a, b) (b) = (a) < (b) ? (b) : (a)
884 #define MIN_OP(a, b) (b) = (a) < (b) ? (a) : (b)
885 #define SUM_OP(a, b) (b) += (a)
886 #define PROD_OP(a, b) (b) *= (a)
887 #define LAND_OP(a, b) (b) = (a) && (b)
888 #define LOR_OP(a, b) (b) = (a) || (b)
889 #define LXOR_OP(a, b) (b) = (!(a) && (b)) || ((a) && !(b))
890 #define BAND_OP(a, b) (b) &= (a)
891 #define BOR_OP(a, b) (b) |= (a)
892 #define BXOR_OP(a, b) (b) ^= (a)
893 #define MAXLOC_OP(a, b) (b) = (a.value) < (b.value) ? (b) : (a)
894 #define MINLOC_OP(a, b) (b) = (a.value) < (b.value) ? (a) : (b)
895 //TODO : MINLOC & MAXLOC
897 #define APPLY_FUNC(a, b, length, type, func) \
900 type* x = (type*)(a); \
901 type* y = (type*)(b); \
902 for(i = 0; i < *(length); i++) { \
907 static void max_func(void *a, void *b, int *length,
908 MPI_Datatype * datatype)
910 if (*datatype == MPI_CHAR) {
911 APPLY_FUNC(a, b, length, char, MAX_OP);
912 } else if (*datatype == MPI_SHORT) {
913 APPLY_FUNC(a, b, length, short, MAX_OP);
914 } else if (*datatype == MPI_INT) {
915 APPLY_FUNC(a, b, length, int, MAX_OP);
916 } else if (*datatype == MPI_LONG) {
917 APPLY_FUNC(a, b, length, long, MAX_OP);
918 } else if (*datatype == MPI_UNSIGNED_SHORT) {
919 APPLY_FUNC(a, b, length, unsigned short, MAX_OP);
920 } else if (*datatype == MPI_UNSIGNED) {
921 APPLY_FUNC(a, b, length, unsigned int, MAX_OP);
922 } else if (*datatype == MPI_UNSIGNED_LONG) {
923 APPLY_FUNC(a, b, length, unsigned long, MAX_OP);
924 } else if (*datatype == MPI_FLOAT) {
925 APPLY_FUNC(a, b, length, float, MAX_OP);
926 } else if (*datatype == MPI_DOUBLE) {
927 APPLY_FUNC(a, b, length, double, MAX_OP);
928 } else if (*datatype == MPI_LONG_DOUBLE) {
929 APPLY_FUNC(a, b, length, long double, MAX_OP);
933 static void min_func(void *a, void *b, int *length,
934 MPI_Datatype * datatype)
936 if (*datatype == MPI_CHAR) {
937 APPLY_FUNC(a, b, length, char, MIN_OP);
938 } else if (*datatype == MPI_SHORT) {
939 APPLY_FUNC(a, b, length, short, MIN_OP);
940 } else if (*datatype == MPI_INT) {
941 APPLY_FUNC(a, b, length, int, MIN_OP);
942 } else if (*datatype == MPI_LONG) {
943 APPLY_FUNC(a, b, length, long, MIN_OP);
944 } else if (*datatype == MPI_UNSIGNED_SHORT) {
945 APPLY_FUNC(a, b, length, unsigned short, MIN_OP);
946 } else if (*datatype == MPI_UNSIGNED) {
947 APPLY_FUNC(a, b, length, unsigned int, MIN_OP);
948 } else if (*datatype == MPI_UNSIGNED_LONG) {
949 APPLY_FUNC(a, b, length, unsigned long, MIN_OP);
950 } else if (*datatype == MPI_FLOAT) {
951 APPLY_FUNC(a, b, length, float, MIN_OP);
952 } else if (*datatype == MPI_DOUBLE) {
953 APPLY_FUNC(a, b, length, double, MIN_OP);
954 } else if (*datatype == MPI_LONG_DOUBLE) {
955 APPLY_FUNC(a, b, length, long double, MIN_OP);
959 static void sum_func(void *a, void *b, int *length,
960 MPI_Datatype * datatype)
962 if (*datatype == MPI_CHAR) {
963 APPLY_FUNC(a, b, length, char, SUM_OP);
964 } else if (*datatype == MPI_SHORT) {
965 APPLY_FUNC(a, b, length, short, SUM_OP);
966 } else if (*datatype == MPI_INT) {
967 APPLY_FUNC(a, b, length, int, SUM_OP);
968 } else if (*datatype == MPI_LONG) {
969 APPLY_FUNC(a, b, length, long, SUM_OP);
970 } else if (*datatype == MPI_UNSIGNED_SHORT) {
971 APPLY_FUNC(a, b, length, unsigned short, SUM_OP);
972 } else if (*datatype == MPI_UNSIGNED) {
973 APPLY_FUNC(a, b, length, unsigned int, SUM_OP);
974 } else if (*datatype == MPI_UNSIGNED_LONG) {
975 APPLY_FUNC(a, b, length, unsigned long, SUM_OP);
976 } else if (*datatype == MPI_FLOAT) {
977 APPLY_FUNC(a, b, length, float, SUM_OP);
978 } else if (*datatype == MPI_DOUBLE) {
979 APPLY_FUNC(a, b, length, double, SUM_OP);
980 } else if (*datatype == MPI_LONG_DOUBLE) {
981 APPLY_FUNC(a, b, length, long double, SUM_OP);
982 } else if (*datatype == MPI_C_FLOAT_COMPLEX) {
983 APPLY_FUNC(a, b, length, float _Complex, SUM_OP);
984 } else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
985 APPLY_FUNC(a, b, length, double _Complex, SUM_OP);
986 } else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
987 APPLY_FUNC(a, b, length, long double _Complex, SUM_OP);
991 static void prod_func(void *a, void *b, int *length,
992 MPI_Datatype * datatype)
994 if (*datatype == MPI_CHAR) {
995 APPLY_FUNC(a, b, length, char, PROD_OP);
996 } else if (*datatype == MPI_SHORT) {
997 APPLY_FUNC(a, b, length, short, PROD_OP);
998 } else if (*datatype == MPI_INT) {
999 APPLY_FUNC(a, b, length, int, PROD_OP);
1000 } else if (*datatype == MPI_LONG) {
1001 APPLY_FUNC(a, b, length, long, PROD_OP);
1002 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1003 APPLY_FUNC(a, b, length, unsigned short, PROD_OP);
1004 } else if (*datatype == MPI_UNSIGNED) {
1005 APPLY_FUNC(a, b, length, unsigned int, PROD_OP);
1006 } else if (*datatype == MPI_UNSIGNED_LONG) {
1007 APPLY_FUNC(a, b, length, unsigned long, PROD_OP);
1008 } else if (*datatype == MPI_FLOAT) {
1009 APPLY_FUNC(a, b, length, float, PROD_OP);
1010 } else if (*datatype == MPI_DOUBLE) {
1011 APPLY_FUNC(a, b, length, double, PROD_OP);
1012 } else if (*datatype == MPI_LONG_DOUBLE) {
1013 APPLY_FUNC(a, b, length, long double, PROD_OP);
1014 } else if (*datatype == MPI_C_FLOAT_COMPLEX) {
1015 APPLY_FUNC(a, b, length, float _Complex, PROD_OP);
1016 } else if (*datatype == MPI_C_DOUBLE_COMPLEX) {
1017 APPLY_FUNC(a, b, length, double _Complex, PROD_OP);
1018 } else if (*datatype == MPI_C_LONG_DOUBLE_COMPLEX) {
1019 APPLY_FUNC(a, b, length, long double _Complex, PROD_OP);
1023 static void land_func(void *a, void *b, int *length,
1024 MPI_Datatype * datatype)
1026 if (*datatype == MPI_CHAR) {
1027 APPLY_FUNC(a, b, length, char, LAND_OP);
1028 } else if (*datatype == MPI_SHORT) {
1029 APPLY_FUNC(a, b, length, short, LAND_OP);
1030 } else if (*datatype == MPI_INT) {
1031 APPLY_FUNC(a, b, length, int, LAND_OP);
1032 } else if (*datatype == MPI_LONG) {
1033 APPLY_FUNC(a, b, length, long, LAND_OP);
1034 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1035 APPLY_FUNC(a, b, length, unsigned short, LAND_OP);
1036 } else if (*datatype == MPI_UNSIGNED) {
1037 APPLY_FUNC(a, b, length, unsigned int, LAND_OP);
1038 } else if (*datatype == MPI_UNSIGNED_LONG) {
1039 APPLY_FUNC(a, b, length, unsigned long, LAND_OP);
1040 } else if (*datatype == MPI_C_BOOL) {
1041 APPLY_FUNC(a, b, length, _Bool, LAND_OP);
1045 static void lor_func(void *a, void *b, int *length,
1046 MPI_Datatype * datatype)
1048 if (*datatype == MPI_CHAR) {
1049 APPLY_FUNC(a, b, length, char, LOR_OP);
1050 } else if (*datatype == MPI_SHORT) {
1051 APPLY_FUNC(a, b, length, short, LOR_OP);
1052 } else if (*datatype == MPI_INT) {
1053 APPLY_FUNC(a, b, length, int, LOR_OP);
1054 } else if (*datatype == MPI_LONG) {
1055 APPLY_FUNC(a, b, length, long, LOR_OP);
1056 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1057 APPLY_FUNC(a, b, length, unsigned short, LOR_OP);
1058 } else if (*datatype == MPI_UNSIGNED) {
1059 APPLY_FUNC(a, b, length, unsigned int, LOR_OP);
1060 } else if (*datatype == MPI_UNSIGNED_LONG) {
1061 APPLY_FUNC(a, b, length, unsigned long, LOR_OP);
1062 } else if (*datatype == MPI_C_BOOL) {
1063 APPLY_FUNC(a, b, length, _Bool, LOR_OP);
1067 static void lxor_func(void *a, void *b, int *length,
1068 MPI_Datatype * datatype)
1070 if (*datatype == MPI_CHAR) {
1071 APPLY_FUNC(a, b, length, char, LXOR_OP);
1072 } else if (*datatype == MPI_SHORT) {
1073 APPLY_FUNC(a, b, length, short, LXOR_OP);
1074 } else if (*datatype == MPI_INT) {
1075 APPLY_FUNC(a, b, length, int, LXOR_OP);
1076 } else if (*datatype == MPI_LONG) {
1077 APPLY_FUNC(a, b, length, long, LXOR_OP);
1078 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1079 APPLY_FUNC(a, b, length, unsigned short, LXOR_OP);
1080 } else if (*datatype == MPI_UNSIGNED) {
1081 APPLY_FUNC(a, b, length, unsigned int, LXOR_OP);
1082 } else if (*datatype == MPI_UNSIGNED_LONG) {
1083 APPLY_FUNC(a, b, length, unsigned long, LXOR_OP);
1084 } else if (*datatype == MPI_C_BOOL) {
1085 APPLY_FUNC(a, b, length, _Bool, LXOR_OP);
1089 static void band_func(void *a, void *b, int *length,
1090 MPI_Datatype * datatype)
1092 if (*datatype == MPI_CHAR) {
1093 APPLY_FUNC(a, b, length, char, BAND_OP);
1095 if (*datatype == MPI_SHORT) {
1096 APPLY_FUNC(a, b, length, short, BAND_OP);
1097 } else if (*datatype == MPI_INT) {
1098 APPLY_FUNC(a, b, length, int, BAND_OP);
1099 } else if (*datatype == MPI_LONG) {
1100 APPLY_FUNC(a, b, length, long, BAND_OP);
1101 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1102 APPLY_FUNC(a, b, length, unsigned short, BAND_OP);
1103 } else if (*datatype == MPI_UNSIGNED) {
1104 APPLY_FUNC(a, b, length, unsigned int, BAND_OP);
1105 } else if (*datatype == MPI_UNSIGNED_LONG) {
1106 APPLY_FUNC(a, b, length, unsigned long, BAND_OP);
1107 } else if (*datatype == MPI_BYTE) {
1108 APPLY_FUNC(a, b, length, uint8_t, BAND_OP);
1112 static void bor_func(void *a, void *b, int *length,
1113 MPI_Datatype * datatype)
1115 if (*datatype == MPI_CHAR) {
1116 APPLY_FUNC(a, b, length, char, BOR_OP);
1117 } else if (*datatype == MPI_SHORT) {
1118 APPLY_FUNC(a, b, length, short, BOR_OP);
1119 } else if (*datatype == MPI_INT) {
1120 APPLY_FUNC(a, b, length, int, BOR_OP);
1121 } else if (*datatype == MPI_LONG) {
1122 APPLY_FUNC(a, b, length, long, BOR_OP);
1123 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1124 APPLY_FUNC(a, b, length, unsigned short, BOR_OP);
1125 } else if (*datatype == MPI_UNSIGNED) {
1126 APPLY_FUNC(a, b, length, unsigned int, BOR_OP);
1127 } else if (*datatype == MPI_UNSIGNED_LONG) {
1128 APPLY_FUNC(a, b, length, unsigned long, BOR_OP);
1129 } else if (*datatype == MPI_BYTE) {
1130 APPLY_FUNC(a, b, length, uint8_t, BOR_OP);
1134 static void bxor_func(void *a, void *b, int *length,
1135 MPI_Datatype * datatype)
1137 if (*datatype == MPI_CHAR) {
1138 APPLY_FUNC(a, b, length, char, BXOR_OP);
1139 } else if (*datatype == MPI_SHORT) {
1140 APPLY_FUNC(a, b, length, short, BXOR_OP);
1141 } else if (*datatype == MPI_INT) {
1142 APPLY_FUNC(a, b, length, int, BXOR_OP);
1143 } else if (*datatype == MPI_LONG) {
1144 APPLY_FUNC(a, b, length, long, BXOR_OP);
1145 } else if (*datatype == MPI_UNSIGNED_SHORT) {
1146 APPLY_FUNC(a, b, length, unsigned short, BXOR_OP);
1147 } else if (*datatype == MPI_UNSIGNED) {
1148 APPLY_FUNC(a, b, length, unsigned int, BXOR_OP);
1149 } else if (*datatype == MPI_UNSIGNED_LONG) {
1150 APPLY_FUNC(a, b, length, unsigned long, BXOR_OP);
1151 } else if (*datatype == MPI_BYTE) {
1152 APPLY_FUNC(a, b, length, uint8_t, BXOR_OP);
1156 static void minloc_func(void *a, void *b, int *length,
1157 MPI_Datatype * datatype)
1159 if (*datatype == MPI_FLOAT_INT) {
1160 APPLY_FUNC(a, b, length, float_int, MINLOC_OP);
1161 } else if (*datatype == MPI_LONG_INT) {
1162 APPLY_FUNC(a, b, length, long_int, MINLOC_OP);
1163 } else if (*datatype == MPI_DOUBLE_INT) {
1164 APPLY_FUNC(a, b, length, double_int, MINLOC_OP);
1165 } else if (*datatype == MPI_SHORT_INT) {
1166 APPLY_FUNC(a, b, length, short_int, MINLOC_OP);
1167 } else if (*datatype == MPI_2INT) {
1168 APPLY_FUNC(a, b, length, int_int, MINLOC_OP);
1169 } else if (*datatype == MPI_LONG_DOUBLE_INT) {
1170 APPLY_FUNC(a, b, length, long_double_int, MINLOC_OP);
1174 static void maxloc_func(void *a, void *b, int *length,
1175 MPI_Datatype * datatype)
1177 if (*datatype == MPI_FLOAT_INT) {
1178 APPLY_FUNC(a, b, length, float_int, MAXLOC_OP);
1179 } else if (*datatype == MPI_LONG_INT) {
1180 APPLY_FUNC(a, b, length, long_int, MAXLOC_OP);
1181 } else if (*datatype == MPI_DOUBLE_INT) {
1182 APPLY_FUNC(a, b, length, double_int, MAXLOC_OP);
1183 } else if (*datatype == MPI_SHORT_INT) {
1184 APPLY_FUNC(a, b, length, short_int, MAXLOC_OP);
1185 } else if (*datatype == MPI_2INT) {
1186 APPLY_FUNC(a, b, length, int_int, MAXLOC_OP);
1187 } else if (*datatype == MPI_LONG_DOUBLE_INT) {
1188 APPLY_FUNC(a, b, length, long_double_int, MAXLOC_OP);
1193 #define CREATE_MPI_OP(name, func) \
1194 static s_smpi_mpi_op_t mpi_##name = { &(func) /* func */ }; \
1195 MPI_Op name = &mpi_##name;
1197 CREATE_MPI_OP(MPI_MAX, max_func);
1198 CREATE_MPI_OP(MPI_MIN, min_func);
1199 CREATE_MPI_OP(MPI_SUM, sum_func);
1200 CREATE_MPI_OP(MPI_PROD, prod_func);
1201 CREATE_MPI_OP(MPI_LAND, land_func);
1202 CREATE_MPI_OP(MPI_LOR, lor_func);
1203 CREATE_MPI_OP(MPI_LXOR, lxor_func);
1204 CREATE_MPI_OP(MPI_BAND, band_func);
1205 CREATE_MPI_OP(MPI_BOR, bor_func);
1206 CREATE_MPI_OP(MPI_BXOR, bxor_func);
1207 CREATE_MPI_OP(MPI_MAXLOC, maxloc_func);
1208 CREATE_MPI_OP(MPI_MINLOC, minloc_func);
1210 MPI_Op smpi_op_new(MPI_User_function * function, int commute)
1214 //FIXME: add commute param
1215 op = xbt_new(s_smpi_mpi_op_t, 1);
1216 op->func = function;
1220 void smpi_op_destroy(MPI_Op op)
1225 void smpi_op_apply(MPI_Op op, void *invec, void *inoutvec, int *len,
1226 MPI_Datatype * datatype)
1228 op->func(invec, inoutvec, len, datatype);