X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/47950eebfede4e41862022469d15e5e4fe19c7ba..fa40abdc1d0705869a181ee3f2e9be45325d4e25:/src/smpi/bindings/smpi_f77.cpp diff --git a/src/smpi/bindings/smpi_f77.cpp b/src/smpi/bindings/smpi_f77.cpp index beea76c12e..3e71af21b1 100644 --- a/src/smpi/bindings/smpi_f77.cpp +++ b/src/smpi/bindings/smpi_f77.cpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2010-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2010-2020. 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. */ @@ -7,11 +7,14 @@ #include "smpi_comm.hpp" #include "smpi_datatype.hpp" #include "smpi_errhandler.hpp" +#include "smpi_file.hpp" #include "smpi_op.hpp" #include "smpi_request.hpp" #include "smpi_win.hpp" #include "src/smpi/include/smpi_actor.hpp" +#include + static int running_processes = 0; void smpi_init_fortran_types() @@ -71,6 +74,9 @@ void smpi_init_fortran_types() MPI_ERRORS_RETURN->add_f(); MPI_ERRORS_ARE_FATAL->add_f(); + + MPI_LB->add_f(); + MPI_UB->add_f(); } } @@ -196,11 +202,8 @@ void mpi_win_set_name_(int* win, char* name, int* ierr, int size) size--; name++; } - char* tname = xbt_new(char,size+1); - strncpy(tname, name, size); - tname[size]='\0'; - *ierr = MPI_Win_set_name(simgrid::smpi::Win::f2c(*win), tname); - xbt_free(tname); + std::string tname(name, size); + *ierr = MPI_Win_set_name(simgrid::smpi::Win::f2c(*win), tname.c_str()); } void mpi_win_get_name_(int* win, char* name, int* len, int* ierr) @@ -213,7 +216,8 @@ void mpi_win_get_name_(int* win, char* name, int* len, int* ierr) void mpi_win_allocate_(MPI_Aint* size, int* disp_unit, int* info, int* comm, void* base, int* win, int* ierr) { MPI_Win tmp; - *ierr = MPI_Win_allocate( *size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),static_cast(base),&tmp); + *ierr = + MPI_Win_allocate(*size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm), base, &tmp); if(*ierr == MPI_SUCCESS) { *win = tmp->add_f(); } @@ -271,9 +275,9 @@ void mpi_win_get_attr_(int* win, int* type_keyval, MPI_Aint* attribute_val, 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); + auto* val = static_cast(xbt_malloc(sizeof(MPI_Aint))); + *val = *att; + *ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val); } void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr) @@ -366,9 +370,7 @@ void mpi_info_set_(int* info, char* key, char* value, int* ierr, unsigned int ke keylen--; key++; } - char* tkey = xbt_new(char,keylen+1); - strncpy(tkey, key, keylen); - tkey[keylen]='\0'; + std::string tkey(key, keylen); while(value[valuelen-1]==' ') valuelen--; @@ -376,13 +378,9 @@ void mpi_info_set_(int* info, char* key, char* value, int* ierr, unsigned int ke valuelen--; value++; } - char* tvalue = xbt_new(char,valuelen+1); - strncpy(tvalue, value, valuelen); - tvalue[valuelen]='\0'; + std::string tvalue(value, valuelen); - *ierr = MPI_Info_set( simgrid::smpi::Info::f2c(*info), tkey, tvalue); - xbt_free(tkey); - xbt_free(tvalue); + *ierr = MPI_Info_set(simgrid::smpi::Info::f2c(*info), tkey.c_str(), tvalue.c_str()); } void mpi_info_get_(int* info, char* key, int* valuelen, char* value, int* flag, int* ierr, unsigned int keylen) @@ -393,15 +391,11 @@ void mpi_info_get_(int* info, char* key, int* valuelen, char* value, int* flag, keylen--; key++; } - char* tkey = xbt_new(char,keylen+1); - strncpy(tkey, key, keylen); - tkey[keylen]='\0'; - *ierr = MPI_Info_get(simgrid::smpi::Info::f2c(*info),tkey,*valuelen, value, flag); - xbt_free(tkey); + std::string tkey(key, keylen); + *ierr = MPI_Info_get(simgrid::smpi::Info::f2c(*info), tkey.c_str(), *valuelen, value, flag); if(*flag!=0){ int replace=0; - int i=0; - for (i=0; i<*valuelen; i++){ + for (int i = 0; i < *valuelen; i++) { if(value[i]=='\0') replace=1; if(replace) @@ -816,9 +810,9 @@ void mpi_attr_delete_ (int* comm, int* keyval, int* ierr) { } void mpi_attr_put_ (int* comm, int* keyval, int* attr_value, int* ierr) { - int* val = (int*)xbt_malloc(sizeof(int)); - *val=*attr_value; - *ierr = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, val); + auto* val = static_cast(xbt_malloc(sizeof(int))); + *val = *attr_value; + *ierr = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, val); } void mpi_keyval_create_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr) { @@ -870,11 +864,8 @@ void mpi_info_get_valuelen_ ( int* info, char *key, int *valuelen, int *flag, in keylen--; key++; } - char* tkey = xbt_new(char, keylen+1); - strncpy(tkey, key, keylen); - tkey[keylen]='\0'; - *ierr = MPI_Info_get_valuelen( simgrid::smpi::Info::f2c(*info), tkey, valuelen, flag); - xbt_free(tkey); + std::string tkey(key, keylen); + *ierr = MPI_Info_get_valuelen(simgrid::smpi::Info::f2c(*info), tkey.c_str(), valuelen, flag); } void mpi_info_delete_ (int* info, char *key, int* ierr, unsigned int keylen){ @@ -884,11 +875,8 @@ void mpi_info_delete_ (int* info, char *key, int* ierr, unsigned int keylen){ keylen--; key++; } - char* tkey = xbt_new(char, keylen+1); - strncpy(tkey, key, keylen); - tkey[keylen]='\0'; - *ierr = MPI_Info_delete(simgrid::smpi::Info::f2c(*info), tkey); - xbt_free(tkey); + std::string tkey(key, keylen); + *ierr = MPI_Info_delete(simgrid::smpi::Info::f2c(*info), tkey.c_str()); } void mpi_info_get_nkeys_ ( int* info, int *nkeys, int* ierr){ @@ -897,8 +885,7 @@ void mpi_info_get_nkeys_ ( int* info, int *nkeys, int* ierr){ void mpi_info_get_nthkey_ ( int* info, int* n, char *key, int* ierr, unsigned int keylen){ *ierr = MPI_Info_get_nthkey( simgrid::smpi::Info::f2c(*info), *n, key); - unsigned int i = 0; - for (i=strlen(key); i(strlen(key)); i < keylen; i++) key[i]=' '; } @@ -955,28 +942,20 @@ void mpi_close_port_ ( char *port_name, int* ierr){ *ierr = MPI_Close_port( port_name); } -void mpi_file_close_ ( int* file, int* ierr){ - *ierr= MPI_File_close(reinterpret_cast(*file)); -} - -void mpi_file_delete_ ( char* filename, int* info, int* ierr){ - *ierr= MPI_File_delete(filename, simgrid::smpi::Info::f2c(*info)); -} - -void mpi_file_open_ ( int* comm, char* filename, int* amode, int* info, int* fh, int* ierr){ - *ierr= MPI_File_open(simgrid::smpi::Comm::f2c(*comm), filename, *amode, simgrid::smpi::Info::f2c(*info), reinterpret_cast(*fh)); +void smpi_execute_flops_(double* flops){ + smpi_execute_flops(*flops); } -void mpi_file_set_view_ ( int* fh, long long int* offset, int* etype, int* filetype, char* datarep, int* info, int* ierr){ - *ierr= MPI_File_set_view(reinterpret_cast(*fh) , reinterpret_cast(*offset), simgrid::smpi::Datatype::f2c(*etype), simgrid::smpi::Datatype::f2c(*filetype), datarep, simgrid::smpi::Info::f2c(*info)); +void smpi_execute_flops_benched_(double* flops){ + smpi_execute_flops_benched(*flops); } -void mpi_file_read_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr){ - *ierr= MPI_File_read(reinterpret_cast(*fh), buf, *count, simgrid::smpi::Datatype::f2c(*datatype), status); +void smpi_execute_(double* duration){ + smpi_execute(*duration); } -void mpi_file_write_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status* status, int* ierr){ - *ierr= MPI_File_write(reinterpret_cast(*fh), buf, *count, simgrid::smpi::Datatype::f2c(*datatype), status); +void smpi_execute_benched_(double* duration){ + smpi_execute_benched(*duration); } } // extern "C"