typedef struct s_smpi_mpi_op {
MPI_User_function *func;
bool is_commute;
+ bool is_fortran_op;
} s_smpi_mpi_op_t;
#define MAX_OP(a, b) (b) = (a) < (b) ? (b) : (a)
}
#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, false }; \
MPI_Op name = &mpi_##name;
CREATE_MPI_OP(MPI_MAX, max_func);
op = xbt_new(s_smpi_mpi_op_t, 1);
op->func = function;
op-> is_commute = commute;
+ op-> is_fortran_op = false;
return op;
}
xbt_free(op);
}
+void smpi_op_set_fortran(MPI_Op op)
+{
+ //tell that we were created from fortran, so we need to translate the type to fortran when called
+ op->is_fortran_op = true;
+}
+
void smpi_op_apply(MPI_Op op, const void *invec, void *inoutvec, int *len, MPI_Datatype * datatype)
{
if(op==MPI_OP_NULL)
smpi_switch_data_segment(smpi_process_index());
}
- if(!smpi_process_get_replaying())
- op->func(const_cast<void*>(invec), inoutvec, len, datatype);
+ if(!smpi_process_get_replaying()){
+ if(! op->is_fortran_op)
+ op->func(const_cast<void*>(invec), inoutvec, len, datatype);
+ else{
+ int tmp = smpi_type_c2f(*datatype);
+ op->func(const_cast<void*>(invec), inoutvec, len, reinterpret_cast<MPI_Datatype*>(&tmp) );
+ }
+ }
}
int smpi_type_attr_delete(MPI_Datatype type, int keyval){