#include "smpi_win.hpp"
#include "src/smpi/include/smpi_actor.hpp"
+#include <string>
+
static int running_processes = 0;
void smpi_init_fortran_types()
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)
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<void*>(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();
}
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<MPI_Aint*>(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)
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--;
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)
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)
}
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<int*>(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) {
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){
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){
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<keylen; i++)
+ for (auto i = static_cast<unsigned>(strlen(key)); i < keylen; i++)
key[i]=' ';
}