-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2010-2021. 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. */
#include "smpi_win.hpp"
#include "src/smpi/include/smpi_actor.hpp"
+#include <string>
+
static int running_processes = 0;
void smpi_init_fortran_types()
MPI_LB->add_f();
MPI_UB->add_f();
+ simgrid::smpi::F2C::finish_initialization();
}
}
{
MPI_Win tmp = simgrid::smpi::Win::f2c(*win);
*ierr = MPI_Win_free(&tmp);
- if(*ierr == MPI_SUCCESS) {
- simgrid::smpi::F2C::free_f(*win);
- }
}
void mpi_win_create_(int* base, MPI_Aint* size, int* disp_unit, int* info, int* comm, int* win, int* ierr)
MPI_Win tmp;
*ierr = MPI_Win_create( static_cast<void*>(base), *size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),&tmp);
if (*ierr == MPI_SUCCESS) {
- *win = tmp->add_f();
+ *win = tmp->c2f();
}
}
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)
*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();
+ *win = tmp->c2f();
}
}
MPI_Win tmp;
*ierr = MPI_Win_create_dynamic( simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),&tmp);
if(*ierr == MPI_SUCCESS) {
- *win = tmp->add_f();
+ *win = tmp->c2f();
}
}
MPI_Info tmp;
*ierr = MPI_Win_get_info(simgrid::smpi::Win::f2c(*win), &tmp);
if (*ierr == MPI_SUCCESS) {
- *info = tmp->add_f();
+ *info = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Win_get_group(simgrid::smpi::Win::f2c(*win), &tmp);
if (*ierr == MPI_SUCCESS) {
- *group = tmp->add_f();
+ *group = tmp->c2f();
}
}
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)
MPI_Info tmp;
*ierr = MPI_Info_create(&tmp);
if(*ierr == MPI_SUCCESS) {
- *info = tmp->add_f();
+ *info = tmp->c2f();
}
}
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)
*ierr = MPI_Rget( static_cast<void*>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win), &req);
if(*ierr == MPI_SUCCESS) {
- *request = req->add_f();
+ *request = req->c2f();
}
}
*ierr = MPI_Raccumulate( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win),&req);
if(*ierr == MPI_SUCCESS) {
- *request = req->add_f();
+ *request = req->c2f();
}
}
*ierr = MPI_Rput( static_cast<void *>(origin_addr),*origin_count, simgrid::smpi::Datatype::f2c(*origin_datatype),*target_rank,
*target_disp, *target_count, simgrid::smpi::Datatype::f2c(*tarsmpi_type_f2c), simgrid::smpi::Win::f2c(*win),&req);
if(*ierr == MPI_SUCCESS) {
- *request = req->add_f();
+ *request = req->c2f();
}
}
*target_count, simgrid::smpi::Datatype::f2c(*target_datatype),
simgrid::smpi::Op::f2c(*op), simgrid::smpi::Win::f2c(*win), &req);
if(*ierr == MPI_SUCCESS) {
- *request = req->add_f();
+ *request = req->c2f();
}
}
*ierr = MPI_Op_create(reinterpret_cast<MPI_User_function*>(function), *commute, &tmp);
if (*ierr == MPI_SUCCESS) {
tmp->set_fortran_op();
- *op = tmp->add_f();
+ *op = tmp->c2f();
}
}
{
MPI_Op tmp= simgrid::smpi::Op::f2c(*op);
*ierr = MPI_Op_free(& tmp);
- if(*ierr == MPI_SUCCESS) {
- simgrid::smpi::F2C::free_f(*op);
- }
}
void mpi_op_commutative_(int* op, int* commute, int* ierr)
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;
}
MPI_Group tmp;
*ierr = MPI_Group_union(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
if (*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Group_intersection(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
if (*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Group_difference(simgrid::smpi::Group::f2c(*group1), simgrid::smpi::Group::f2c(*group2), &tmp);
if (*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Group_excl(simgrid::smpi::Group::f2c(*group), *n, ranks, &tmp);
if (*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Group_range_incl(simgrid::smpi::Group::f2c(*group), *n, ranges, &tmp);
if (*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
MPI_Group tmp;
*ierr = MPI_Group_range_excl(simgrid::smpi::Group::f2c(*group), *n, ranges, &tmp);
if(*ierr == MPI_SUCCESS) {
- *newgroup = tmp->add_f();
+ *newgroup = tmp->c2f();
}
}
void mpi_request_free_ (int* request, int* ierr){
MPI_Request tmp=simgrid::smpi::Request::f2c(*request);
*ierr = MPI_Request_free(&tmp);
- if(*ierr == MPI_SUCCESS) {
- simgrid::smpi::Request::free_f(*request);
- }
}
void mpi_pack_size_ (int* incount, int* datatype, int* comm, int* size, int* ierr) {
MPI_Comm tmp;
*ierr = MPI_Cart_create(simgrid::smpi::Comm::f2c(*comm_old), *ndims, dims, periods, *reorder, &tmp);
if(*ierr == MPI_SUCCESS) {
- *comm_cart = tmp->add_f();
+ *comm_cart = tmp->c2f();
}
}
MPI_Comm tmp;
*ierr = MPI_Cart_sub(simgrid::smpi::Comm::f2c(*comm), remain_dims, &tmp);
if(*ierr == MPI_SUCCESS) {
- *comm_new = tmp->add_f();
+ *comm_new = tmp->c2f();
}
}
MPI_Comm tmp;
*ierr = MPI_Graph_create(simgrid::smpi::Comm::f2c(*comm_old), *nnodes, index, edges, *reorder, &tmp);
if(*ierr == MPI_SUCCESS) {
- *comm_graph = tmp->add_f();
+ *comm_graph = tmp->c2f();
}
}
*ierr = MPI_Intercomm_create(simgrid::smpi::Comm::f2c(*local_comm), *local_leader, simgrid::smpi::Comm::f2c(*peer_comm), *remote_leader,
*tag, &tmp);
if(*ierr == MPI_SUCCESS) {
- *comm_out = tmp->add_f();
+ *comm_out = tmp->c2f();
}
}
MPI_Comm tmp;
*ierr = MPI_Intercomm_merge(simgrid::smpi::Comm::f2c(*comm), *high, &tmp);
if(*ierr == MPI_SUCCESS) {
- *comm_out = tmp->add_f();
+ *comm_out = tmp->c2f();
}
}
}
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) {
MPI_Info tmp;
*ierr = MPI_Info_dup(simgrid::smpi::Info::f2c(*info), &tmp);
if(*ierr==MPI_SUCCESS){
- *newinfo= tmp->add_f();
+ *newinfo= tmp->c2f();
}
}
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]=' ';
}
*ierr = MPI_Grequest_start( reinterpret_cast<MPI_Grequest_query_function*>(query_fn), reinterpret_cast<MPI_Grequest_free_function*>(free_fn),
reinterpret_cast<MPI_Grequest_cancel_function*>(cancel_fn), extra_state, &tmp);
if(*ierr == MPI_SUCCESS) {
- *request = tmp->add_f();
+ *request = tmp->c2f();
}
}