#include "private.h"
#include "xbt.h"
-static xbt_dict_t comm_lookup = NULL;
-static xbt_dict_t group_lookup = NULL;
-static xbt_dict_t request_lookup = NULL;
-static xbt_dict_t datatype_lookup = NULL;
-static xbt_dict_t op_lookup = NULL;
-static xbt_dict_t win_lookup = NULL;
-static xbt_dict_t info_lookup = NULL;
+static xbt_dict_t comm_lookup = nullptr;
+static xbt_dict_t group_lookup = nullptr;
+static xbt_dict_t request_lookup = nullptr;
+static xbt_dict_t datatype_lookup = nullptr;
+static xbt_dict_t op_lookup = nullptr;
+static xbt_dict_t win_lookup = nullptr;
+static xbt_dict_t info_lookup = nullptr;
static int running_processes = 0;
}
static void smpi_init_fortran_types(){
- if(comm_lookup == NULL){
- comm_lookup = xbt_dict_new_homogeneous(NULL);
+ if(comm_lookup == nullptr){
+ comm_lookup = xbt_dict_new_homogeneous(nullptr);
smpi_comm_c2f(MPI_COMM_WORLD);
- group_lookup = xbt_dict_new_homogeneous(NULL);
- request_lookup = xbt_dict_new_homogeneous(NULL);
- datatype_lookup = xbt_dict_new_homogeneous(NULL);
- win_lookup = xbt_dict_new_homogeneous(NULL);
- info_lookup = xbt_dict_new_homogeneous(NULL);
+ group_lookup = xbt_dict_new_homogeneous(nullptr);
+ request_lookup = xbt_dict_new_homogeneous(nullptr);
+ datatype_lookup = xbt_dict_new_homogeneous(nullptr);
+ win_lookup = xbt_dict_new_homogeneous(nullptr);
+ info_lookup = xbt_dict_new_homogeneous(nullptr);
smpi_type_c2f(MPI_BYTE);//MPI_BYTE
smpi_type_c2f(MPI_CHAR);//MPI_CHARACTER
#if defined(__alpha__) || defined(__sparc64__) || defined(__x86_64__) || defined(__ia64__)
smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_COMPLEX16
smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_COMPLEX32
smpi_type_c2f(MPI_DATATYPE_NULL);//MPI_PACKED
- op_lookup = xbt_dict_new_homogeneous(NULL);
+ op_lookup = xbt_dict_new_homogeneous(nullptr);
smpi_op_c2f(MPI_MAX);
smpi_op_c2f(MPI_MIN);
smpi_op_c2f(MPI_MAXLOC);
int smpi_comm_c2f(MPI_Comm comm) {
static int comm_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(comm_lookup, comm==MPI_COMM_WORLD? get_key(key, comm_id) : get_key_id(key, comm_id), comm, NULL);
+ xbt_dict_set(comm_lookup, comm==MPI_COMM_WORLD? get_key(key, comm_id) : get_key_id(key, comm_id), comm, nullptr);
comm_id++;
return comm_id-1;
}
return MPI_COMM_SELF;
} else if(comm==0){
return MPI_COMM_WORLD;
- } else if(comm_lookup != NULL && comm >= 0) {
+ } else if(comm_lookup != nullptr && comm >= 0) {
char key[KEY_SIZE];
MPI_Comm tmp = static_cast<MPI_Comm>(xbt_dict_get_or_null(comm_lookup,get_key_id(key, comm)));
- return tmp != NULL ? tmp : MPI_COMM_NULL ;
+ return tmp != nullptr ? tmp : MPI_COMM_NULL ;
} else {
return MPI_COMM_NULL;
}
int smpi_group_c2f(MPI_Group group) {
static int group_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(group_lookup, get_key(key, group_id), group, NULL);
+ xbt_dict_set(group_lookup, get_key(key, group_id), group, nullptr);
group_id++;
return group_id-1;
}
smpi_init_fortran_types();
if(group == -2) {
return MPI_GROUP_EMPTY;
- } else if(group_lookup != NULL && group >= 0) {
+ } else if(group_lookup != nullptr && group >= 0) {
char key[KEY_SIZE];
return static_cast<MPI_Group>(xbt_dict_get_or_null(group_lookup, get_key(key, group)));
} else {
int smpi_request_c2f(MPI_Request req) {
static int request_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(request_lookup, get_key_id(key, request_id), req, NULL);
+ xbt_dict_set(request_lookup, get_key_id(key, request_id), req, nullptr);
request_id++;
return request_id-1;
}
int smpi_type_c2f(MPI_Datatype datatype) {
static int datatype_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(datatype_lookup, get_key(key, datatype_id), datatype, NULL);
+ xbt_dict_set(datatype_lookup, get_key(key, datatype_id), datatype, nullptr);
datatype_id++;
return datatype_id-1;
}
int smpi_op_c2f(MPI_Op op) {
static int op_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(op_lookup, get_key(key, op_id), op, NULL);
+ xbt_dict_set(op_lookup, get_key(key, op_id), op, nullptr);
op_id++;
return op_id-1;
}
int smpi_win_c2f(MPI_Win win) {
static int win_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(win_lookup, get_key(key, win_id), win, NULL);
+ xbt_dict_set(win_lookup, get_key(key, win_id), win, nullptr);
win_id++;
return win_id-1;
}
int smpi_info_c2f(MPI_Info info) {
static int info_id = 0;
char key[KEY_SIZE];
- xbt_dict_set(info_lookup, get_key(key, info_id), info, NULL);
+ xbt_dict_set(info_lookup, get_key(key, info_id), info, nullptr);
info_id++;
return info_id-1;
}
void mpi_init_(int* ierr) {
smpi_init_fortran_types();
- *ierr = MPI_Init(NULL, NULL);
+ *ierr = MPI_Init(nullptr, nullptr);
running_processes++;
}
*ierr = MPI_Comm_size(smpi_comm_f2c(*comm), size);
}
-double mpi_wtime_(void) {
+double mpi_wtime_() {
return MPI_Wtime();
}
-double mpi_wtick_(void) {
+double mpi_wtick_() {
return MPI_Wtick();
}
}
void mpi_testall_ (int* count, int * requests, int *flag, MPI_Status * statuses, int* ierr){
- MPI_Request* reqs;
int i;
- reqs = xbt_new(MPI_Request, *count);
+ MPI_Request* reqs = xbt_new(MPI_Request, *count);
for(i = 0; i < *count; i++) {
reqs[i] = smpi_request_f2c(requests[i]);
}
requests[i]=MPI_FORTRAN_REQUEST_NULL;
}
}
+ xbt_free(reqs);
}
void mpi_get_processor_name_(char *name, int *resultlen, int* ierr){
}
char* tvalue = xbt_new(char,valuelen+1);
strncpy(tvalue, value, valuelen);
-
tvalue[valuelen]='\0';
+
*ierr = MPI_Info_set( smpi_info_f2c(*info), tkey, tvalue);
xbt_free(tkey);
+ xbt_free(tvalue);
}
void mpi_info_get_ (int* info,char *key,int* valuelen, char *value, int *flag, int* ierr, unsigned int keylen ){
void mpi_init_thread_ (int* required, int *provided, int* ierr){
smpi_init_fortran_types();
- *ierr = MPI_Init_thread(NULL, NULL,*required, provided);
+ *ierr = MPI_Init_thread(nullptr, nullptr,*required, provided);
running_processes++;
}
void mpi_comm_spawn_ ( char *command, char *argv, int* maxprocs, int* info, int* root, int* comm, int* intercomm,
int* array_of_errcodes, int* ierr){
MPI_Comm tmp;
- *ierr = MPI_Comm_spawn( command, NULL, *maxprocs, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp,
+ *ierr = MPI_Comm_spawn( command, nullptr, *maxprocs, *reinterpret_cast<MPI_Info*>(info), *root, smpi_comm_f2c(*comm), &tmp,
array_of_errcodes);
if(*ierr == MPI_SUCCESS) {
*intercomm = smpi_comm_c2f(tmp);