X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/b9de37e23ac70fadc9fe1c55a6bd1d892ba5ba53..92b61e41082d8e54e25b87d7d1b772f0447e4802:/src/smpi/bindings/smpi_f77.cpp diff --git a/src/smpi/bindings/smpi_f77.cpp b/src/smpi/bindings/smpi_f77.cpp index f28922c280..9e96429ed9 100644 --- a/src/smpi/bindings/smpi_f77.cpp +++ b/src/smpi/bindings/smpi_f77.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,6 +6,7 @@ #include "private.hpp" #include "smpi_comm.hpp" #include "smpi_datatype.hpp" +#include "smpi_errhandler.hpp" #include "smpi_op.hpp" #include "smpi_request.hpp" #include "smpi_win.hpp" @@ -33,8 +34,8 @@ void smpi_init_fortran_types(){ MPI_REAL4->add_f();//MPI_REAL4 MPI_REAL8->add_f();//MPI_REAL8 MPI_DOUBLE->add_f();//MPI_DOUBLE_PRECISION - MPI_C_FLOAT_COMPLEX->add_f();//MPI_COMPLEX - MPI_C_DOUBLE_COMPLEX->add_f();//MPI_DOUBLE_COMPLEX + MPI_COMPLEX8->add_f();//MPI_COMPLEX + MPI_COMPLEX16->add_f();//MPI_DOUBLE_COMPLEX #if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__) MPI_2INT->add_f();//MPI_2INTEGER #else @@ -51,6 +52,9 @@ void smpi_init_fortran_types(){ MPI_AINT->add_f();//MPI_COUNT MPI_REAL16->add_f();//MPI_REAL16 MPI_PACKED->add_f();//MPI_PACKED + MPI_COMPLEX8->add_f();//MPI_COMPLEX8 + MPI_COMPLEX16->add_f();//MPI_COMPLEX16 + MPI_COMPLEX32->add_f();//MPI_COMPLEX32 MPI_MAX->add_f(); MPI_MIN->add_f(); @@ -64,6 +68,9 @@ void smpi_init_fortran_types(){ MPI_BAND->add_f(); MPI_BOR->add_f(); MPI_BXOR->add_f(); + + MPI_ERRORS_RETURN->add_f(); + MPI_ERRORS_ARE_FATAL->add_f(); } } @@ -98,7 +105,7 @@ void mpi_group_incl_(int* group, int* n, int* ranks, int* group_out, int* ierr) *ierr = MPI_Group_incl(simgrid::smpi::Group::f2c(*group), *n, ranks, &tmp); if(*ierr == MPI_SUCCESS) { - *group_out = tmp->add_f(); + *group_out = tmp->c2f(); } } @@ -107,6 +114,8 @@ void mpi_initialized_(int* flag, int* ierr){ } void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){ + //fortran does not handle string endings cleanly, so initialize everything before + memset(name, 0, MPI_MAX_PROCESSOR_NAME); *ierr = MPI_Get_processor_name(name, resultlen); } @@ -226,15 +235,15 @@ void mpi_win_get_group_(int* win, int* group, int* ierr){ } } -void mpi_win_get_attr_(int* win, int* type_keyval, int* attribute_val, int* flag, int* ierr){ - int* value = nullptr; +void mpi_win_get_attr_(int* win, int* type_keyval, MPI_Aint* attribute_val, int* flag, int* ierr){ + MPI_Aint* value = nullptr; *ierr = MPI_Win_get_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, &value, flag); if (*flag == 1) *attribute_val = *value; } -void mpi_win_set_attr_(int* win, int* type_keyval, int* att, int* ierr){ - int* val = (int*)xbt_malloc(sizeof(int)); +void mpi_win_set_attr_(int* win, int* type_keyval, MPI_Aint* att, int* ierr){ + MPI_Aint* val = (MPI_Aint*)xbt_malloc(sizeof(MPI_Aint)); *val=*att; *ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val); } @@ -244,8 +253,9 @@ void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr){ } void mpi_win_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){ - *ierr = MPI_Win_create_keyval(reinterpret_cast(copy_fn), - reinterpret_cast(delete_fn), keyval, extra_state); + smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast(copy_fn)}; + smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast(delete_fn)}; + *ierr = simgrid::smpi::Keyval::keyval_create(_copy_fn, _delete_fn, keyval, extra_state); } void mpi_win_free_keyval_(int* keyval, int* ierr){ @@ -283,6 +293,21 @@ void mpi_win_flush_local_all_(int* win, int* ierr){ *ierr = MPI_Win_flush_local_all(simgrid::smpi::Win::f2c(*win)); } +void mpi_win_null_copy_fn_(int* /*win*/, int* /*keyval*/, int* /*extrastate*/, MPI_Aint* /*valin*/, + MPI_Aint* /*valout*/, int* flag, int* ierr) +{ + *flag=0; + *ierr=MPI_SUCCESS; +} + +void mpi_win_dup_fn_(int* /*win*/, int* /*keyval*/, int* /*extrastate*/, MPI_Aint* valin, MPI_Aint* valout, int* flag, + int* ierr) +{ + *flag=1; + *valout=*valin; + *ierr=MPI_SUCCESS; +} + void mpi_info_create_( int *info, int* ierr){ MPI_Info tmp; *ierr = MPI_Info_create(&tmp); @@ -492,11 +517,12 @@ void mpi_op_commutative_ (int* op, int* commute, int* ierr){ } void mpi_group_free_ (int* group, int* ierr){ - MPI_Group tmp = simgrid::smpi::Group::f2c(*group); - *ierr = MPI_Group_free(&tmp); - if(*ierr == MPI_SUCCESS) { - simgrid::smpi::F2C::free_f(*group); - } + MPI_Group tmp = simgrid::smpi::Group::f2c(*group); + if(tmp != MPI_COMM_WORLD->group() && tmp != MPI_GROUP_EMPTY){ + simgrid::smpi::Group::unref(tmp); + simgrid::smpi::F2C::free_f(*group); + } + *ierr = MPI_SUCCESS; } void mpi_group_size_ (int* group, int *size, int* ierr){ @@ -658,20 +684,32 @@ void mpi_error_class_ (int* errorcode, int* errorclass, int* ierr) { *ierr = MPI_Error_class(*errorcode, errorclass); } -void mpi_errhandler_create_ (void* function, void* errhandler, int* ierr) { - *ierr = MPI_Errhandler_create(reinterpret_cast(function), static_cast(errhandler)); +void mpi_errhandler_create_ (void* function, int* errhandler, int* ierr) { + MPI_Errhandler tmp; + *ierr = MPI_Errhandler_create( reinterpret_cast(function), &tmp); + if(*ierr==MPI_SUCCESS){ + *errhandler = tmp->c2f(); + } } -void mpi_errhandler_free_ (void* errhandler, int* ierr) { - *ierr = MPI_Errhandler_free(static_cast(errhandler)); +void mpi_errhandler_free_ (int* errhandler, int* ierr) { + MPI_Errhandler tmp = simgrid::smpi::Errhandler::f2c(*errhandler); + *ierr = MPI_Errhandler_free(&tmp); + if(*ierr == MPI_SUCCESS) { + simgrid::smpi::F2C::free_f(*errhandler); + } } -void mpi_errhandler_get_ (int* comm, void* errhandler, int* ierr) { - *ierr = MPI_Errhandler_get(simgrid::smpi::Comm::f2c(*comm), static_cast(errhandler)); +void mpi_errhandler_get_ (int* comm, int* errhandler, int* ierr) { + MPI_Errhandler tmp; + *ierr = MPI_Errhandler_get(simgrid::smpi::Comm::f2c(*comm), &tmp); + if(*ierr == MPI_SUCCESS) { + *errhandler = tmp->c2f(); + } } -void mpi_errhandler_set_ (int* comm, void* errhandler, int* ierr) { - *ierr = MPI_Errhandler_set(simgrid::smpi::Comm::f2c(*comm), *static_cast(errhandler)); +void mpi_errhandler_set_ (int* comm, int* errhandler, int* ierr) { + *ierr = MPI_Errhandler_set(simgrid::smpi::Comm::f2c(*comm), simgrid::smpi::Errhandler::f2c(*errhandler)); } void mpi_cancel_ (int* request, int* ierr) { @@ -718,7 +756,9 @@ void mpi_attr_put_ (int* comm, int* keyval, int* attr_value, int* ierr) { } void mpi_keyval_create_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr) { - *ierr = MPI_Keyval_create(reinterpret_cast(copy_fn),reinterpret_cast(delete_fn), keyval, extra_state); + smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast(copy_fn),nullptr,nullptr}; + smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast(delete_fn),nullptr,nullptr}; + *ierr = simgrid::smpi::Keyval::keyval_create(_copy_fn, _delete_fn, keyval, extra_state); } void mpi_keyval_free_ (int* keyval, int* ierr) { @@ -830,19 +870,19 @@ void mpi_status_set_elements_ ( MPI_Status* status, int* datatype, int* count, i } void mpi_publish_name_ ( char *service_name, int* info, char *port_name, int* ierr){ - *ierr = MPI_Publish_name( service_name, *reinterpret_cast(info), port_name); + *ierr = MPI_Publish_name( service_name, simgrid::smpi::Info::f2c(*info), port_name); } void mpi_unpublish_name_ ( char *service_name, int* info, char *port_name, int* ierr){ - *ierr = MPI_Unpublish_name( service_name, *reinterpret_cast(info), port_name); + *ierr = MPI_Unpublish_name( service_name, simgrid::smpi::Info::f2c(*info), port_name); } void mpi_lookup_name_ ( char *service_name, int* info, char *port_name, int* ierr){ - *ierr = MPI_Lookup_name( service_name, *reinterpret_cast(info), port_name); + *ierr = MPI_Lookup_name( service_name, simgrid::smpi::Info::f2c(*info), port_name); } void mpi_open_port_ ( int* info, char *port_name, int* ierr){ - *ierr = MPI_Open_port( *reinterpret_cast(info),port_name); + *ierr = MPI_Open_port( simgrid::smpi::Info::f2c(*info),port_name); } void mpi_close_port_ ( char *port_name, int* ierr){