From c540b8009e2e13d461ecaa7cf17f68950b3539fb Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Wed, 8 Jun 2016 23:20:59 +0200 Subject: [PATCH 1/1] [SMPI] NULL -> nullptr substitution I used the following command: (the '**' means recursion in ZSH) sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp We check for the underscore to avoid replacing MPI_*_NULL --- src/smpi/instr_smpi.cpp | 32 ++--- src/smpi/smpi_base.cpp | 95 +++++++------ src/smpi/smpi_bench.cpp | 30 ++--- src/smpi/smpi_coll.cpp | 26 ++-- src/smpi/smpi_comm.cpp | 74 +++++----- src/smpi/smpi_deployment.cpp | 20 +-- src/smpi/smpi_f77.cpp | 56 ++++---- src/smpi/smpi_global.cpp | 52 ++++---- src/smpi/smpi_group.cpp | 14 +- src/smpi/smpi_mpi_dt.cpp | 58 ++++---- src/smpi/smpi_pmpi.cpp | 252 +++++++++++++++++------------------ src/smpi/smpi_replay.cpp | 80 +++++------ src/smpi/smpi_rma.cpp | 26 ++-- src/smpi/smpi_topo.cpp | 10 +- 14 files changed, 412 insertions(+), 413 deletions(-) diff --git a/src/smpi/instr_smpi.cpp b/src/smpi/instr_smpi.cpp index 36ee8d52aa..4079b4cd81 100644 --- a/src/smpi/instr_smpi.cpp +++ b/src/smpi/instr_smpi.cpp @@ -55,7 +55,7 @@ static const char *smpi_colors[] ={ "win_wait", "1 0.8 0", "win_start", "0.8 0 1", "win_complete", "0.8 1 0", - NULL, NULL, + nullptr, nullptr, }; static char *str_tolower (const char *str) @@ -70,10 +70,10 @@ static char *str_tolower (const char *str) static const char *instr_find_color (const char *state) { char *target = str_tolower (state); - const char *ret = NULL; + const char *ret = nullptr; unsigned int i = 0; const char *current = smpi_colors[i]; - while ((current != NULL)){ + while ((current != nullptr)){ if (strcmp (state, current) == 0 //exact match || strstr(target, current) != 0 ){//as substring ret = smpi_colors[i+1]; @@ -107,9 +107,9 @@ static char *TRACE_smpi_put_key(int src, int dst, char *key, int n) return key; } - if (d == NULL) { + if (d == nullptr) { d = xbt_dynar_new(sizeof(char *), &xbt_free_ref); - xbt_dict_set(keys, aux, d, NULL); + xbt_dict_set(keys, aux, d, nullptr); } //generate the key @@ -138,17 +138,17 @@ static char *TRACE_smpi_get_key(int src, int dst, char *key, int n) char *s = xbt_dynar_get_as (d, 0, char *); snprintf (key, n, "%s", s); - xbt_dynar_remove_at (d, 0, NULL); + xbt_dynar_remove_at (d, 0, nullptr); return key; } static xbt_dict_t process_category; static void cleanup_extra_data (instr_extra_data extra){ - if(extra!=NULL){ - if(extra->sendcounts!=NULL) + if(extra!=nullptr){ + if(extra->sendcounts!=nullptr) xbt_free(extra->sendcounts); - if(extra->recvcounts!=NULL) + if(extra->recvcounts!=nullptr) xbt_free(extra->recvcounts); xbt_free(extra); } @@ -166,14 +166,14 @@ void TRACE_internal_smpi_set_category (const char *category) snprintf (processid, INSTR_DEFAULT_STR_SIZE, "%p", SIMIX_process_self()); if (xbt_dict_get_or_null (process_category, processid)) xbt_dict_remove (process_category, processid); - if (category != NULL) - xbt_dict_set (process_category, processid, xbt_strdup(category), NULL); + if (category != nullptr) + xbt_dict_set (process_category, processid, xbt_strdup(category), nullptr); } const char *TRACE_internal_smpi_get_category (void) { if (!TRACE_smpi_is_enabled()) - return NULL; + return nullptr; char processid[INSTR_DEFAULT_STR_SIZE]; snprintf (processid, INSTR_DEFAULT_STR_SIZE, "%p", SIMIX_process_self()); @@ -206,7 +206,7 @@ void TRACE_smpi_init(int rank) }else{ father = PJ_container_get_root (); } - xbt_assert(father!=NULL, + xbt_assert(father!=nullptr, "Could not find a parent for mpi rank %s at function %s", str, __FUNCTION__); PJ_container_new(str, INSTR_SMPI, father); } @@ -278,7 +278,7 @@ void TRACE_smpi_computing_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("computing", NULL, type); + val_t value = PJ_value_get_or_new ("computing", nullptr, type); new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -320,7 +320,7 @@ void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("sleeping", NULL, type); + val_t value = PJ_value_get_or_new ("sleeping", nullptr, type); new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast(extra)); } @@ -347,7 +347,7 @@ void TRACE_smpi_testing_in(int rank, instr_extra_data extra) smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); type_t type = PJ_type_get ("MPI_STATE", container->type); - val_t value = PJ_value_get_or_new ("test", NULL, type); + val_t value = PJ_value_get_or_new ("test", nullptr, type); new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast(extra)); } diff --git a/src/smpi/smpi_base.cpp b/src/smpi/smpi_base.cpp index a1db869ed9..679ab29c2b 100644 --- a/src/smpi/smpi_base.cpp +++ b/src/smpi/smpi_base.cpp @@ -97,14 +97,14 @@ static int factor_cmp(const void *pa, const void *pb) static xbt_dynar_t parse_factor(const char *smpi_coef_string) { - char *value = NULL; + char *value = nullptr; unsigned int iter = 0; s_smpi_factor_multival_t fact; fact.nb_values=0; unsigned int i=0; - xbt_dynar_t radical_elements2 = NULL; + xbt_dynar_t radical_elements2 = nullptr; - xbt_dynar_t smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_multival_t), NULL); + xbt_dynar_t smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_multival_t), nullptr); xbt_dynar_t radical_elements = xbt_str_split(smpi_coef_string, ";"); xbt_dynar_foreach(radical_elements, iter, value) { memset(&fact, 0, sizeof(s_smpi_factor_multival_t)); @@ -250,9 +250,9 @@ double smpi_mpi_wtime(){ static MPI_Request build_request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) { - MPI_Request request = NULL; + MPI_Request request = nullptr; - void *old_buf = NULL; + void *old_buf = nullptr; request = xbt_new(s_smpi_mpi_request_t, 1); @@ -261,7 +261,7 @@ static MPI_Request build_request(void *buf, int count, MPI_Datatype datatype, in if((((flags & RECV) != 0) && ((flags & ACCUMULATE) !=0)) || (datatype->sizeof_substruct != 0)){ // This part handles the problem of non-contiguous memory old_buf = buf; - buf = count==0 ? NULL : xbt_malloc(count*smpi_datatype_size(datatype)); + buf = count==0 ? nullptr : xbt_malloc(count*smpi_datatype_size(datatype)); if ((datatype->sizeof_substruct != 0) && ((flags & SEND) != 0)) { subtype->serialize(old_buf, buf, count, datatype->substruct); } @@ -318,8 +318,8 @@ static void smpi_mpi_request_free_voidp(void* request) MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, PERSISTENT | SEND | PREPARED); return request; } @@ -327,8 +327,8 @@ MPI_Request smpi_mpi_send_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, PERSISTENT | SSEND | SEND | PREPARED); return request; } @@ -336,8 +336,8 @@ MPI_Request smpi_mpi_ssend_init(void *buf, int count, MPI_Datatype datatype, MPI_Request smpi_mpi_recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, PERSISTENT | RECV | PREPARED); return request; @@ -420,13 +420,13 @@ void smpi_mpi_start(MPI_Request request) void* buf = request->buf; if ( (request->flags & SSEND) == 0 && ( (request->flags & RMA) != 0 || static_cast(request->size) < xbt_cfg_get_int("smpi/send-is-detached-thresh") ) ) { - void *oldbuf = NULL; + void *oldbuf = nullptr; request->detached = 1; XBT_DEBUG("Send request %p is detached", request); request->refcount++; if(request->old_type->sizeof_substruct == 0){ oldbuf = request->buf; - if (!smpi_process_get_replaying() && oldbuf != NULL && request->size!=0){ + if (!smpi_process_get_replaying() && oldbuf != nullptr && request->size!=0){ if((smpi_privatize_global_variables != 0) && (static_cast(request->buf) >= smpi_start_data_exe) && (static_cast(request->buf) < smpi_start_data_exe + smpi_size_data_exe )){ @@ -543,12 +543,12 @@ void smpi_mpi_request_free(MPI_Request * request) MPI_Request smpi_rma_send_init(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, MPI_Op op) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ if(op==MPI_OP_NULL){ - request = build_request(buf==MPI_BOTTOM ? NULL : buf , count, datatype, src, dst, tag, + request = build_request(buf==MPI_BOTTOM ? nullptr : buf , count, datatype, src, dst, tag, comm, RMA | NON_PERSISTENT | ISEND | SEND | PREPARED); }else{ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, src, dst, tag, + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src, dst, tag, comm, RMA | NON_PERSISTENT | ISEND | SEND | PREPARED | ACCUMULATE); request->op = op; } @@ -558,12 +558,12 @@ MPI_Request smpi_rma_send_init(void *buf, int count, MPI_Datatype datatype, int MPI_Request smpi_rma_recv_init(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, MPI_Op op) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ if(op==MPI_OP_NULL){ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, src, dst, tag, + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src, dst, tag, comm, RMA | NON_PERSISTENT | RECV | PREPARED); }else{ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, src, dst, tag, + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src, dst, tag, comm, RMA | NON_PERSISTENT | RECV | PREPARED | ACCUMULATE); request->op = op; } @@ -572,16 +572,16 @@ MPI_Request smpi_rma_recv_init(void *buf, int count, MPI_Datatype datatype, int MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf , count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf , count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag,comm, PERSISTENT | ISEND | SEND | PREPARED); return request; } MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | ISEND | SEND); smpi_mpi_start(request); return request; @@ -589,8 +589,8 @@ MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, int dst, MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag,comm, NON_PERSISTENT | ISEND | SSEND | SEND); smpi_mpi_start(request); return request; @@ -598,8 +598,8 @@ MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, int dst MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, PERSISTENT | RECV | PREPARED); return request; @@ -607,8 +607,8 @@ MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, int src MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, src == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), src), smpi_process_index(), tag, comm, NON_PERSISTENT | RECV); smpi_mpi_start(request); @@ -617,32 +617,32 @@ MPI_Request smpi_mpi_irecv(void *buf, int count, MPI_Datatype datatype, int src, void smpi_mpi_recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI_Comm comm, MPI_Status * status) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); smpi_mpi_wait(&request, status); - request = NULL; + request = nullptr; } void smpi_mpi_send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | SEND); smpi_mpi_start(request); smpi_mpi_wait(&request, MPI_STATUS_IGNORE); - request = NULL; + request = nullptr; } void smpi_mpi_ssend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm) { - MPI_Request request = NULL; /* MC needs the comm to be set to NULL during the call */ - request = build_request(buf==MPI_BOTTOM ? NULL : buf, count, datatype, smpi_process_index(), + MPI_Request request = nullptr; /* MC needs the comm to be set to nullptr during the call */ + request = build_request(buf==MPI_BOTTOM ? nullptr : buf, count, datatype, smpi_process_index(), smpi_group_index(smpi_comm_group(comm), dst), tag, comm, NON_PERSISTENT | SSEND | SEND); smpi_mpi_start(request); smpi_mpi_wait(&request, MPI_STATUS_IGNORE); - request = NULL; + request = nullptr; } void smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype,int dst, int sendtag, @@ -721,7 +721,7 @@ static void finish_wait(MPI_Request * request, MPI_Status * status) TRACE_smpi_recv(rank, src_traced, rank); } - if(req->detached_sender!=NULL){ + if(req->detached_sender != nullptr){ //integrate pseudo-timing for buffering of small messages, do not bother to execute the simcall if 0 double sleeptime = smpi_or(req->real_size); @@ -729,11 +729,10 @@ static void finish_wait(MPI_Request * request, MPI_Status * status) simcall_process_sleep(sleeptime); XBT_DEBUG("receiving size of %zu : sleep %f ", req->real_size, sleeptime); } - smpi_mpi_request_free(&(req->detached_sender)); } if(req->flags & PERSISTENT) - req->action = NULL; + req->action = nullptr; req->flags |= FINISHED; smpi_mpi_request_free(request); @@ -754,7 +753,7 @@ int smpi_mpi_test(MPI_Request * request, MPI_Status * status) { smpi_empty_status(status); int flag = 1; if (((*request)->flags & PREPARED) == 0) { - if ((*request)->action != NULL) + if ((*request)->action != nullptr) flag = simcall_comm_test((*request)->action); if (flag) { finish_wait(request, status); @@ -777,7 +776,7 @@ int smpi_mpi_testany(int count, MPI_Request requests[], int *index, MPI_Status * int size = 0; *index = MPI_UNDEFINED; - comms = xbt_dynar_new(sizeof(smx_synchro_t), NULL); + comms = xbt_dynar_new(sizeof(smx_synchro_t), nullptr); map = xbt_new(int, count); for(i = 0; i < count; i++) { if ((requests[i] != MPI_REQUEST_NULL) && requests[i]->action && !(requests[i]->flags & PREPARED)) { @@ -850,7 +849,7 @@ void smpi_mpi_probe(int source, int tag, MPI_Comm comm, MPI_Status* status){ void smpi_mpi_iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* status){ - MPI_Request request = build_request(NULL, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : + MPI_Request request = build_request(nullptr, 0, MPI_CHAR, source == MPI_ANY_SOURCE ? MPI_ANY_SOURCE : smpi_group_index(smpi_comm_group(comm), source), smpi_comm_rank(comm), tag, comm, PERSISTENT | RECV); // to avoid deadlock, we have to sleep some time here, or the timer won't advance and we will only do iprobe simcalls @@ -905,7 +904,7 @@ void smpi_mpi_wait(MPI_Request * request, MPI_Status * status) return; } - if ((*request)->action != NULL) + if ((*request)->action != nullptr) // this is not a detached send simcall_comm_wait((*request)->action, -1.0); @@ -924,12 +923,12 @@ int smpi_mpi_waitany(int count, MPI_Request requests[], MPI_Status * status) if(count > 0) { // Wait for a request to complete - comms = xbt_dynar_new(sizeof(smx_synchro_t), NULL); + comms = xbt_dynar_new(sizeof(smx_synchro_t), nullptr); map = xbt_new(int, count); XBT_DEBUG("Wait for one of %d", count); for(i = 0; i < count; i++) { if (requests[i] != MPI_REQUEST_NULL && !(requests[i]->flags & PREPARED) && !(requests[i]->flags & FINISHED)) { - if (requests[i]->action != NULL) { + if (requests[i]->action != nullptr) { XBT_DEBUG("Waiting any %p ", requests[i]); xbt_dynar_push(comms, &requests[i]->action); map[size] = i; @@ -1349,7 +1348,7 @@ void smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datat } else { smpi_datatype_extent(datatype, &lb, &dataext); // Local copy from root - if (sendtmpbuf != NULL && recvbuf != NULL) + if (sendtmpbuf != nullptr && recvbuf != nullptr) smpi_datatype_copy(sendtmpbuf, count, datatype, recvbuf, count, datatype); // Receive buffers from senders requests = xbt_new(MPI_Request, size - 1); diff --git a/src/smpi/smpi_bench.cpp b/src/smpi/smpi_bench.cpp index 1e9eaed4ed..bbd79b3d97 100644 --- a/src/smpi/smpi_bench.cpp +++ b/src/smpi/smpi_bench.cpp @@ -71,14 +71,14 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, "Logging specific to SMPI (ben #define PTR_STRLEN (2 + 2 * sizeof(void*) + 1) -xbt_dict_t samples = NULL; /* Allocated on first use */ -xbt_dict_t calls = NULL; /* Allocated on first use */ +xbt_dict_t samples = nullptr; /* Allocated on first use */ +xbt_dict_t calls = nullptr; /* Allocated on first use */ double smpi_cpu_threshold; double smpi_running_power; int smpi_loaded_page = -1; -char* smpi_start_data_exe = NULL; +char* smpi_start_data_exe = nullptr; int smpi_size_data_exe = 0; bool smpi_privatize_global_variables; double smpi_total_benched_time = 0; @@ -168,7 +168,7 @@ static void* shm_map(int fd, size_t size, shared_data_key_type* data) { xbt_die("Could not truncate fd %d to %zu: %s", fd, size, strerror(errno)); } - mem = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + mem = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if(mem == MAP_FAILED) { xbt_die("Could not map fd %d: %s", fd, strerror(errno)); } @@ -387,11 +387,11 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr smpi_bench_end(); /* Take time from previous, unrelated computation into account */ smpi_process_set_sampling(1); - if (samples==NULL) + if (samples==nullptr) samples = xbt_dict_new_homogeneous(free); data = static_cast(xbt_dict_get_or_null(samples, loc)); - if (data==NULL) { + if (data==nullptr) { xbt_assert(threshold>0 || iters>0, "You should provide either a positive amount of iterations to bench, or a positive maximal stderr (or both)"); data = static_cast( xbt_new(local_data_t, 1)); @@ -402,7 +402,7 @@ void smpi_sample_1(int global, const char *file, int line, int iters, double thr data->threshold = threshold; data->benching = 1; // If we have no data, we need at least one data->mean = 0; - xbt_dict_set(samples, loc, data, NULL); + xbt_dict_set(samples, loc, data, nullptr); XBT_DEBUG("XXXXX First time ever on benched nest %s.",loc); } else { if (data->iters != iters || data->threshold != threshold) { @@ -564,8 +564,8 @@ int smpi_shared_known_call(const char* func, const char* input) xbt_ex_t ex; int known = 0; - if (calls==NULL) { - calls = xbt_dict_new_homogeneous(NULL); + if (calls==nullptr) { + calls = xbt_dict_new_homogeneous(nullptr); } TRY { xbt_dict_get(calls, loc); /* Succeed or throw */ @@ -586,8 +586,8 @@ void* smpi_shared_get_call(const char* func, const char* input) { char* loc = bprintf("%s:%s", func, input); void* data; - if(calls==NULL) { - calls = xbt_dict_new_homogeneous(NULL); + if(calls==nullptr) { + calls = xbt_dict_new_homogeneous(nullptr); } data = xbt_dict_get(calls, loc); xbt_free(loc); @@ -598,9 +598,9 @@ void* smpi_shared_set_call(const char* func, const char* input, void* data) { char* loc = bprintf("%s:%s", func, input); if(calls==0) { - calls = xbt_dict_new_homogeneous(NULL); + calls = xbt_dict_new_homogeneous(nullptr); } - xbt_dict_set(calls, loc, data, NULL); + xbt_dict_set(calls, loc, data, nullptr); xbt_free(loc); return data; } @@ -670,7 +670,7 @@ void smpi_initialize_global_memory_segments(){ for (int i=0; i< smpi_process_count(); i++){ //create SIMIX_process_count() mappings of this size with the same data inside - void *address = NULL; + void *address = nullptr; char path[] = "/dev/shm/my-buffer-XXXXXX"; int status; @@ -704,7 +704,7 @@ Ask the Internet about tutorials on how to increase the files limit such as: htt xbt_die("Impossible to set the size of the temporary file for memory mapping"); /* Ask for a free region */ - address = mmap (NULL, smpi_size_data_exe, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, 0); + address = mmap (nullptr, smpi_size_data_exe, PROT_READ | PROT_WRITE, MAP_SHARED, file_descriptor, 0); if (address == MAP_FAILED) xbt_die("Couldn't find a free region for memory mapping"); diff --git a/src/smpi/smpi_coll.cpp b/src/smpi/smpi_coll.cpp index 6d71088681..a8bcf997a4 100644 --- a/src/smpi/smpi_coll.cpp +++ b/src/smpi/smpi_coll.cpp @@ -18,7 +18,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_coll, smpi, "Logging specific to SMPI (coll s_mpi_coll_description_t mpi_coll_gather_description[] = { {"default", "gather default collective", reinterpret_cast(&smpi_mpi_gather)}, - COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {NULL, NULL, NULL} /* this array must be NULL terminated */ + COLL_GATHERS(COLL_DESCRIPTION, COLL_COMMA), {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; @@ -27,7 +27,7 @@ s_mpi_coll_description_t mpi_coll_allgather_description[] = { "allgather default collective", reinterpret_cast(&smpi_mpi_allgather)}, COLL_ALLGATHERS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_allgatherv_description[] = { @@ -35,7 +35,7 @@ s_mpi_coll_description_t mpi_coll_allgatherv_description[] = { "allgatherv default collective", reinterpret_cast(&smpi_mpi_allgatherv)}, COLL_ALLGATHERVS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_allreduce_description[] = { @@ -43,7 +43,7 @@ s_mpi_coll_description_t mpi_coll_allreduce_description[] = { "allreduce default collective", reinterpret_cast(&smpi_mpi_allreduce)}, COLL_ALLREDUCES(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_reduce_scatter_description[] = { @@ -51,7 +51,7 @@ s_mpi_coll_description_t mpi_coll_reduce_scatter_description[] = { "reduce_scatter default collective", reinterpret_cast(&smpi_mpi_reduce_scatter)}, COLL_REDUCE_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_scatter_description[] = { @@ -59,7 +59,7 @@ s_mpi_coll_description_t mpi_coll_scatter_description[] = { "scatter default collective", reinterpret_cast(&smpi_mpi_scatter)}, COLL_SCATTERS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_barrier_description[] = { @@ -67,7 +67,7 @@ s_mpi_coll_description_t mpi_coll_barrier_description[] = { "barrier default collective", reinterpret_cast(&smpi_mpi_barrier)}, COLL_BARRIERS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_alltoall_description[] = { {"default", @@ -80,7 +80,7 @@ COLL_ALLTOALLS(COLL_DESCRIPTION, COLL_COMMA), {"basic_linear", "Alltoall basic linear (SG) collective", reinterpret_cast(&smpi_coll_tuned_alltoall_basic_linear)}, - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_alltoallv_description[] = { @@ -88,7 +88,7 @@ s_mpi_coll_description_t mpi_coll_alltoallv_description[] = { "Ompi alltoallv default collective", reinterpret_cast(&smpi_coll_basic_alltoallv)}, COLL_ALLTOALLVS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_bcast_description[] = { @@ -96,7 +96,7 @@ s_mpi_coll_description_t mpi_coll_bcast_description[] = { "bcast default collective ", reinterpret_cast(&smpi_mpi_bcast)}, COLL_BCASTS(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; s_mpi_coll_description_t mpi_coll_reduce_description[] = { @@ -104,7 +104,7 @@ s_mpi_coll_description_t mpi_coll_reduce_description[] = { "reduce default collective", reinterpret_cast(&smpi_mpi_reduce)}, COLL_REDUCES(COLL_DESCRIPTION, COLL_COMMA), - {NULL, NULL, NULL} /* this array must be NULL terminated */ + {nullptr, nullptr, nullptr} /* this array must be nullptr terminated */ }; @@ -122,9 +122,9 @@ void coll_help(const char *category, s_mpi_coll_description_t * table) int find_coll_description(s_mpi_coll_description_t * table, char *name, const char *desc) { - char *name_list = NULL; + char *name_list = nullptr; int selector_on=0; - if (name==NULL || name[0] == '\0') { + if (name==nullptr || name[0] == '\0') { //no argument provided, use active selector's algorithm name=static_cast(xbt_cfg_get_string("smpi/coll-selector")); selector_on=1; diff --git a/src/smpi/smpi_comm.cpp b/src/smpi/smpi_comm.cpp index 3db4a9ab82..c13a486cc8 100644 --- a/src/smpi/smpi_comm.cpp +++ b/src/smpi/smpi_comm.cpp @@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)"); -xbt_dict_t smpi_comm_keyvals = NULL; +xbt_dict_t smpi_comm_keyvals = nullptr; int comm_keyval_id = 0;//avoid collisions /* Support for cartesian topology was added, but there are 2 other types of topology, graph et dist graph. In order to @@ -69,10 +69,10 @@ MPI_Comm smpi_comm_new(MPI_Group group, MPI_Topology topo) comm->intra_comm = MPI_COMM_NULL; comm->leaders_comm = MPI_COMM_NULL; comm->is_uniform=1; - comm->non_uniform_map = NULL; - comm->leaders_map = NULL; + comm->non_uniform_map = nullptr; + comm->leaders_map = nullptr; comm->is_blocked=0; - comm->attributes=NULL; + comm->attributes=nullptr; return comm; } @@ -92,9 +92,9 @@ int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){ (*newcomm) = smpi_comm_new(cp, smpi_comm_topo(comm)); int ret = MPI_SUCCESS; - if(comm->attributes !=NULL){ + if(comm->attributes !=nullptr){ (*newcomm)->attributes=xbt_dict_new(); - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; int *key; int flag; void* value_in; @@ -102,15 +102,15 @@ int smpi_comm_dup(MPI_Comm comm, MPI_Comm* newcomm){ xbt_dict_foreach(comm->attributes, cursor, key, value_in){ smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(key), sizeof(int))); - if(elem!=NULL && elem->copy_fn!=MPI_NULL_COPY_FN){ - ret = elem->copy_fn(comm, *key, NULL, value_in, &value_out, &flag ); + if(elem!=nullptr && elem->copy_fn!=MPI_NULL_COPY_FN){ + ret = elem->copy_fn(comm, *key, nullptr, value_in, &value_out, &flag ); if(ret!=MPI_SUCCESS){ smpi_comm_destroy(*newcomm); *newcomm=MPI_COMM_NULL; return ret; } if(flag) - xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast(key), sizeof(int),value_out, NULL); + xbt_dict_set_ext((*newcomm)->attributes, reinterpret_cast(key), sizeof(int),value_out, nullptr); } } } @@ -127,7 +127,7 @@ MPI_Group smpi_comm_group(MPI_Comm comm) MPI_Topology smpi_comm_topo(MPI_Comm comm) { if (comm != MPI_COMM_NULL) return comm->topo; - return NULL; + return nullptr; } int smpi_comm_size(MPI_Comm comm) @@ -215,8 +215,8 @@ MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) MPI_Group* group_snd; MPI_Request* requests; - group_root = NULL; - group_out = NULL; + group_root = nullptr; + group_out = nullptr; group = smpi_comm_group(comm); rank = smpi_comm_rank(comm); size = smpi_comm_size(comm); @@ -227,7 +227,7 @@ MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) if(rank == 0) { recvbuf = xbt_new(int, 2 * size); } else { - recvbuf = NULL; + recvbuf = nullptr; } smpi_mpi_gather(sendbuf, 2, MPI_INT, recvbuf, 2, MPI_INT, 0, comm); xbt_free(sendbuf); @@ -284,9 +284,9 @@ MPI_Comm smpi_comm_split(MPI_Comm comm, int color, int key) } else { if(color != MPI_UNDEFINED) { smpi_mpi_recv(&group_out, 1, MPI_PTR, 0, system_tag, comm, MPI_STATUS_IGNORE); - } /* otherwise, exit with group_out == NULL */ + } /* otherwise, exit with group_out == nullptr */ } - return group_out!=NULL ? smpi_comm_new(group_out, NULL) : MPI_COMM_NULL; + return group_out!=nullptr ? smpi_comm_new(group_out, nullptr) : MPI_COMM_NULL; } void smpi_comm_use(MPI_Comm comm){ @@ -297,15 +297,15 @@ void smpi_comm_use(MPI_Comm comm){ } void smpi_comm_cleanup_attributes(MPI_Comm comm){ - if(comm->attributes !=NULL){ - xbt_dict_cursor_t cursor = NULL; + if(comm->attributes !=nullptr){ + xbt_dict_cursor_t cursor = nullptr; int* key; void * value; int flag; xbt_dict_foreach(comm->attributes, cursor, key, value){ smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null(smpi_comm_keyvals, reinterpret_cast(key))); - if(elem!=NULL && elem->delete_fn!=NULL) + if(elem!=nullptr && elem->delete_fn!=nullptr) elem->delete_fn(comm, *key, value, &flag); } xbt_dict_free(&comm->attributes); @@ -317,9 +317,9 @@ void smpi_comm_cleanup_smp(MPI_Comm comm){ smpi_comm_unuse(comm->intra_comm); if(comm->leaders_comm != MPI_COMM_NULL) smpi_comm_unuse(comm->leaders_comm); - if(comm->non_uniform_map !=NULL) + if(comm->non_uniform_map !=nullptr) xbt_free(comm->non_uniform_map); - if(comm->leaders_map !=NULL) + if(comm->leaders_map !=nullptr) xbt_free(comm->leaders_map); } @@ -369,7 +369,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ int intra_comm_size = 0; int i =0; int min_index=INT_MAX;//the minimum index will be the leader - smx_process_t process = NULL; + smx_process_t process = nullptr; xbt_swag_foreach(process, process_list) { int index = SIMIX_process_get_PID(process) -1; @@ -384,7 +384,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ XBT_DEBUG("number of processes deployed on my node : %d", intra_comm_size); MPI_Group group_intra = smpi_group_new(intra_comm_size); i=0; - process = NULL; + process = nullptr; xbt_swag_foreach(process, process_list) { int index = SIMIX_process_get_PID(process) -1; if(smpi_group_rank(smpi_comm_group(comm), index)!=MPI_UNDEFINED){ @@ -393,7 +393,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ } } - MPI_Comm comm_intra = smpi_comm_new(group_intra, NULL); + MPI_Comm comm_intra = smpi_comm_new(group_intra, nullptr); leader=min_index; int * leaders_map= static_cast(xbt_malloc0(sizeof(int)*comm_size)); @@ -408,7 +408,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ smpi_switch_data_segment(smpi_process_index()); } - if(comm->leaders_map==NULL){ + if(comm->leaders_map==nullptr){ comm->leaders_map= leaders_map; }else{ xbt_free(leaders_map); @@ -436,7 +436,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ //create leader_communicator for (i=0; i< leader_group_size;i++) smpi_group_set_mapping(leaders_group, leader_list[i], i); - leader_comm = smpi_comm_new(leaders_group, NULL); + leader_comm = smpi_comm_new(leaders_group, nullptr); smpi_comm_set_leaders_comm(comm, leader_comm); smpi_comm_set_intra_comm(comm, comm_intra); @@ -446,7 +446,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ smpi_group_set_mapping(leaders_group, leader_list[i], i); if(smpi_comm_get_leaders_comm(comm)==MPI_COMM_NULL){ - leader_comm = smpi_comm_new(leaders_group, NULL); + leader_comm = smpi_comm_new(leaders_group, nullptr); smpi_comm_set_leaders_comm(comm, leader_comm); }else{ leader_comm=smpi_comm_get_leaders_comm(comm); @@ -512,7 +512,7 @@ void smpi_comm_init_smp(MPI_Comm comm){ int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; if(elem->delete_fn!=MPI_NULL_DELETE_FN){ void * value; @@ -523,7 +523,7 @@ int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ return ret; } } - if(comm->attributes==NULL) + if(comm->attributes==nullptr) return MPI_ERR_ARG; xbt_dict_remove_ext(comm->attributes, reinterpret_cast(&keyval), sizeof(int)); @@ -533,10 +533,10 @@ int smpi_comm_attr_delete(MPI_Comm comm, int keyval){ int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){ smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; xbt_ex_t ex; - if(comm->attributes==NULL){ + if(comm->attributes==nullptr){ *flag=0; return MPI_SUCCESS; } @@ -552,11 +552,11 @@ int smpi_comm_attr_get(MPI_Comm comm, int keyval, void* attr_value, int* flag){ } int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ - if(smpi_comm_keyvals==NULL) + if(smpi_comm_keyvals==nullptr) smpi_comm_keyvals = xbt_dict_new(); smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; int flag; void* value; @@ -566,16 +566,16 @@ int smpi_comm_attr_put(MPI_Comm comm, int keyval, void* attr_value){ if(ret!=MPI_SUCCESS) return ret; } - if(comm->attributes==NULL) + if(comm->attributes==nullptr) comm->attributes=xbt_dict_new(); - xbt_dict_set_ext(comm->attributes, reinterpret_cast(&keyval), sizeof(int), attr_value, NULL); + xbt_dict_set_ext(comm->attributes, reinterpret_cast(&keyval), sizeof(int), attr_value, nullptr); return MPI_SUCCESS; } int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delete_attr_function* delete_fn, int* keyval, void* extra_state){ - if(smpi_comm_keyvals==NULL) + if(smpi_comm_keyvals==nullptr) smpi_comm_keyvals = xbt_dict_new(); smpi_comm_key_elem value = static_cast(xbt_new0(s_smpi_mpi_comm_key_elem_t,1)); @@ -584,7 +584,7 @@ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delet value->delete_fn=delete_fn; *keyval = comm_keyval_id; - xbt_dict_set_ext(smpi_comm_keyvals, reinterpret_cast(keyval), sizeof(int),static_cast(value), NULL); + xbt_dict_set_ext(smpi_comm_keyvals, reinterpret_cast(keyval), sizeof(int),static_cast(value), nullptr); comm_keyval_id++; return MPI_SUCCESS; } @@ -592,7 +592,7 @@ int smpi_comm_keyval_create(MPI_Comm_copy_attr_function* copy_fn, MPI_Comm_delet int smpi_comm_keyval_free(int* keyval){ smpi_comm_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_comm_keyvals, reinterpret_cast(keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; xbt_dict_remove_ext(smpi_comm_keyvals, reinterpret_cast(keyval), sizeof(int)); xbt_free(elem); diff --git a/src/smpi/smpi_deployment.cpp b/src/smpi/smpi_deployment.cpp index e910160f03..d841df18c3 100644 --- a/src/smpi/smpi_deployment.cpp +++ b/src/smpi/smpi_deployment.cpp @@ -10,7 +10,7 @@ #include "xbt/log.h" #include "xbt/dict.h" -static xbt_dict_t smpi_instances = NULL; +static xbt_dict_t smpi_instances = nullptr; extern int process_count; extern int* index_to_process_data; @@ -46,21 +46,21 @@ void SMPI_app_instance_register(const char *name, xbt_main_func_t code, int num_ process_count+=num_processes; - if(smpi_instances==NULL){ + if(smpi_instances==nullptr){ smpi_instances = xbt_dict_new_homogeneous(xbt_free_f); } - xbt_dict_set(smpi_instances, name, (void*)instance, NULL); + xbt_dict_set(smpi_instances, name, (void*)instance, nullptr); return; } //get the index of the process in the process_data array void smpi_deployment_register_process(const char* instance_id, int rank, int index,MPI_Comm** comm, xbt_bar_t* bar){ - if(smpi_instances==NULL){//no instance registered, we probably used smpirun. + if(smpi_instances==nullptr){//no instance registered, we probably used smpirun. index_to_process_data[index]=index; - *bar = NULL; - *comm = NULL; + *bar = nullptr; + *comm = nullptr; return; } @@ -70,7 +70,7 @@ void smpi_deployment_register_process(const char* instance_id, int rank, int ind if(instance->comm_world == MPI_COMM_NULL){ MPI_Group group = smpi_group_new(instance->size); - instance->comm_world = smpi_comm_new(group, NULL); + instance->comm_world = smpi_comm_new(group, nullptr); } instance->present_processes++; index_to_process_data[index]=instance->index+rank; @@ -81,9 +81,9 @@ void smpi_deployment_register_process(const char* instance_id, int rank, int ind } void smpi_deployment_cleanup_instances(){ - xbt_dict_cursor_t cursor = NULL; - s_smpi_mpi_instance_t* instance = NULL; - char *name = NULL; + xbt_dict_cursor_t cursor = nullptr; + s_smpi_mpi_instance_t* instance = nullptr; + char *name = nullptr; xbt_dict_foreach(smpi_instances, cursor, name, instance) { if(instance->comm_world!=MPI_COMM_NULL) while (smpi_group_unuse(smpi_comm_group(instance->comm_world)) > 0); diff --git a/src/smpi/smpi_f77.cpp b/src/smpi/smpi_f77.cpp index 72188356ee..8786829f4c 100644 --- a/src/smpi/smpi_f77.cpp +++ b/src/smpi/smpi_f77.cpp @@ -10,13 +10,13 @@ #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; @@ -58,14 +58,14 @@ static char* get_key_id(char* key, int id) { } 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__) @@ -104,7 +104,7 @@ static void smpi_init_fortran_types(){ 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); @@ -123,7 +123,7 @@ static void smpi_init_fortran_types(){ 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; } @@ -139,10 +139,10 @@ MPI_Comm smpi_comm_f2c(int comm) { 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(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; } @@ -151,7 +151,7 @@ MPI_Comm smpi_comm_f2c(int comm) { 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; } @@ -160,7 +160,7 @@ MPI_Group smpi_group_f2c(int group) { 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(xbt_dict_get_or_null(group_lookup, get_key(key, group))); } else { @@ -176,7 +176,7 @@ static void free_group(int group) { 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; } @@ -198,7 +198,7 @@ static void free_request(int request) { 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; } @@ -217,7 +217,7 @@ static void free_datatype(int datatype) { 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; } @@ -236,7 +236,7 @@ static void free_op(int op) { 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; } @@ -255,7 +255,7 @@ static void free_win(int win) { 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; } @@ -273,7 +273,7 @@ static void free_info(int info) { void mpi_init_(int* ierr) { smpi_init_fortran_types(); - *ierr = MPI_Init(NULL, NULL); + *ierr = MPI_Init(nullptr, nullptr); running_processes++; } @@ -842,7 +842,7 @@ void mpi_finalized_ (int * flag, int* ierr){ 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++; } @@ -1729,7 +1729,7 @@ void mpi_comm_accept_ ( char *port_name, int* info, int* root, int* comm, int*ne 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(info), *root, smpi_comm_f2c(*comm), &tmp, + *ierr = MPI_Comm_spawn( command, nullptr, *maxprocs, *reinterpret_cast(info), *root, smpi_comm_f2c(*comm), &tmp, array_of_errcodes); if(*ierr == MPI_SUCCESS) { *intercomm = smpi_comm_c2f(tmp); diff --git a/src/smpi/smpi_global.cpp b/src/smpi/smpi_global.cpp index 1a008f954b..c0f324bab1 100644 --- a/src/smpi/smpi_global.cpp +++ b/src/smpi/smpi_global.cpp @@ -52,16 +52,16 @@ typedef struct s_smpi_process_data { smpi_trace_call_location_t* trace_call_loc; } s_smpi_process_data_t; -static smpi_process_data_t *process_data = NULL; +static smpi_process_data_t *process_data = nullptr; int process_count = 0; int smpi_universe_size = 0; -int* index_to_process_data = NULL; +int* index_to_process_data = nullptr; extern double smpi_total_benched_time; xbt_os_timer_t global_timer; MPI_Comm MPI_COMM_WORLD = MPI_COMM_UNINITIALIZED; -MPI_Errhandler *MPI_ERRORS_RETURN = NULL; -MPI_Errhandler *MPI_ERRORS_ARE_FATAL = NULL; -MPI_Errhandler *MPI_ERRHANDLER_NULL = NULL; +MPI_Errhandler *MPI_ERRORS_RETURN = nullptr; +MPI_Errhandler *MPI_ERRORS_ARE_FATAL = nullptr; +MPI_Errhandler *MPI_ERRHANDLER_NULL = nullptr; #define MAILBOX_NAME_MAXLEN (5 + sizeof(int) * 2 + 1) @@ -83,14 +83,14 @@ void smpi_process_init(int *argc, char ***argv) smpi_process_data_t data; smx_process_t proc; - if (argc != NULL && argv != NULL) { + if (argc != nullptr && argv != nullptr) { proc = SIMIX_process_self(); SIMIX_process_set_cleanup_function(proc, MSG_process_cleanup_from_SIMIX); char* instance_id = (*argv)[1]; int rank = xbt_str_parse_int((*argv)[2], "Invalid rank: %s"); index = smpi_process_index_of_smx_process(proc); - if(index_to_process_data == NULL){ + if(index_to_process_data == nullptr){ index_to_process_data=static_cast(xbt_malloc(SIMIX_process_count()*sizeof(int))); } @@ -106,7 +106,7 @@ void smpi_process_init(int *argc, char ***argv) smpi_deployment_register_process(instance_id, rank, index, &temp_comm_world, &temp_bar); data = smpi_process_remote_data(index); data->comm_world = temp_comm_world; - if(temp_bar != NULL) + if(temp_bar != nullptr) data->finalization_barrier = temp_bar; data->index = index; data->instance_id = instance_id; @@ -118,8 +118,8 @@ void smpi_process_init(int *argc, char ***argv) if (*argc > 3) { free((*argv)[1]); memmove(&(*argv)[0], &(*argv)[2], sizeof(char *) * (*argc - 2)); - (*argv)[(*argc) - 1] = NULL; - (*argv)[(*argc) - 2] = NULL; + (*argv)[(*argc) - 1] = nullptr; + (*argv)[(*argc) - 2] = nullptr; } (*argc)-=2; data->argc = argc; @@ -129,7 +129,7 @@ void smpi_process_init(int *argc, char ***argv) XBT_DEBUG("<%d> New process in the game: %p", index, proc); } xbt_assert(smpi_process_data(), - "smpi_process_data() returned NULL. You probably gave a NULL parameter to MPI_Init. Although it's required by " + "smpi_process_data() returned nullptr. You probably gave a nullptr parameter to MPI_Init. Although it's required by " "MPI-2, this is currently not supported by SMPI."); } @@ -168,7 +168,7 @@ int smpi_process_finalized() /** @brief Check if a process is initialized */ int smpi_process_initialized() { - if (index_to_process_data == NULL){ + if (index_to_process_data == nullptr){ return false; } else{ int index = smpi_process_index(); @@ -249,14 +249,14 @@ int smpi_process_index() { smpi_process_data_t data = smpi_process_data(); //return -1 if not initialized - return data != NULL ? data->index : MPI_UNDEFINED; + return data != nullptr ? data->index : MPI_UNDEFINED; } MPI_Comm smpi_process_comm_world() { smpi_process_data_t data = smpi_process_data(); //return MPI_COMM_NULL if not initialized - return data != NULL ? *data->comm_world : MPI_COMM_NULL; + return data != nullptr ? *data->comm_world : MPI_COMM_NULL; } smx_mailbox_t smpi_process_mailbox() @@ -318,7 +318,7 @@ MPI_Comm smpi_process_comm_self() smpi_process_data_t data = smpi_process_data(); if(data->comm_self==MPI_COMM_NULL){ MPI_Group group = smpi_group_new(1); - data->comm_self = smpi_comm_new(group, NULL); + data->comm_self = smpi_comm_new(group, nullptr); smpi_group_set_mapping(group, smpi_process_index(), 0); } @@ -385,7 +385,7 @@ void smpi_comm_copy_buffer_callback(smx_synchro_t synchro, void *buff, size_t bu xbt_free(buff); //It seems that the request is used after the call there this should be free somewhere else but where??? //xbt_free(comm->comm.src_data);// inside SMPI the request is kept inside the user data and should be free - comm->src_buff = NULL; + comm->src_buff = nullptr; } if(tmpbuff!=buff)xbt_free(tmpbuff); @@ -410,7 +410,7 @@ static void smpi_check_options(){ } int smpi_enabled() { - return process_data != NULL; + return process_data != nullptr; } void smpi_global_init() @@ -454,8 +454,8 @@ void smpi_global_init() process_data = xbt_new0(smpi_process_data_t, process_count); for (i = 0; i < process_count; i++) { process_data[i] = xbt_new(s_smpi_process_data_t, 1); - process_data[i]->argc = NULL; - process_data[i]->argv = NULL; + process_data[i]->argc = nullptr; + process_data[i]->argv = nullptr; process_data[i]->mailbox = simcall_mbox_create(get_mailbox_name(name, i)); process_data[i]->mailbox_small = simcall_mbox_create(get_mailbox_name_small(name, i)); process_data[i]->mailboxes_mutex = xbt_mutex_init(); @@ -464,10 +464,10 @@ void smpi_global_init() MC_ignore_heap(process_data[i]->timer, xbt_os_timer_size()); process_data[i]->comm_self = MPI_COMM_NULL; process_data[i]->comm_intra = MPI_COMM_NULL; - process_data[i]->comm_world = NULL; + process_data[i]->comm_world = nullptr; process_data[i]->state = SMPI_UNINITIALIZED; process_data[i]->sampling = 0; - process_data[i]->finalization_barrier = NULL; + process_data[i]->finalization_barrier = nullptr; process_data[i]->return_value = 0; if (xbt_cfg_get_boolean("smpi/trace-call-location")) { @@ -478,7 +478,7 @@ void smpi_global_init() //if not, we let MPI_COMM_NULL, and the comm world will be private to each mpi instance if(smpirun){ group = smpi_group_new(process_count); - MPI_COMM_WORLD = smpi_comm_new(group, NULL); + MPI_COMM_WORLD = smpi_comm_new(group, nullptr); MPI_Attr_put(MPI_COMM_WORLD, MPI_UNIVERSE_SIZE, reinterpret_cast(process_count)); xbt_bar_t bar=xbt_barrier_init(process_count); @@ -516,12 +516,12 @@ void smpi_global_destroy() xbt_free(process_data[i]); } xbt_free(process_data); - process_data = NULL; + process_data = nullptr; if (MPI_COMM_WORLD != MPI_COMM_UNINITIALIZED){ smpi_comm_cleanup_smp(MPI_COMM_WORLD); smpi_comm_cleanup_attributes(MPI_COMM_WORLD); - if(smpi_coll_cleanup_callback!=NULL) + if(smpi_coll_cleanup_callback!=nullptr) smpi_coll_cleanup_callback(); xbt_free(MPI_COMM_WORLD); } @@ -645,7 +645,7 @@ static void smpi_init_options(){ mpi_coll_barrier_fun = reinterpret_cast (mpi_coll_barrier_description[barrier_id].coll); - smpi_coll_cleanup_callback=NULL; + smpi_coll_cleanup_callback=nullptr; smpi_cpu_threshold = xbt_cfg_get_double("smpi/cpu-threshold"); smpi_running_power = xbt_cfg_get_double("smpi/running-power"); smpi_privatize_global_variables = xbt_cfg_get_boolean("smpi/privatize-global-variables"); @@ -657,7 +657,7 @@ int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[]) { srand(SMPI_RAND_SEED); - if (getenv("SMPI_PRETEND_CC") != NULL) { + if (getenv("SMPI_PRETEND_CC") != nullptr) { /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the * configuration tools */ return 0; diff --git a/src/smpi/smpi_group.cpp b/src/smpi/smpi_group.cpp index 119b8bba68..fe817c51d2 100644 --- a/src/smpi/smpi_group.cpp +++ b/src/smpi/smpi_group.cpp @@ -17,8 +17,8 @@ typedef struct s_smpi_mpi_group { static s_smpi_mpi_group_t mpi_MPI_GROUP_EMPTY = { 0, /* size */ - NULL, /* rank_to_index_map */ - NULL, /* index_to_rank_map */ + nullptr, /* rank_to_index_map */ + nullptr, /* index_to_rank_map */ 1, /* refcount: start > 0 so that this group never gets freed */ }; @@ -46,7 +46,7 @@ MPI_Group smpi_group_copy(MPI_Group origin) MPI_Group group=origin; char *key; char *ptr_rank; - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; int i; if(origin != MPI_GROUP_NULL @@ -64,7 +64,7 @@ MPI_Group smpi_group_copy(MPI_Group origin) xbt_dict_foreach(origin->index_to_rank_map, cursor, key, ptr_rank) { int * cp = static_cast(xbt_malloc(sizeof(int))); *cp=*reinterpret_cast(ptr_rank); - xbt_dict_set(group->index_to_rank_map, key, cp, NULL); + xbt_dict_set(group->index_to_rank_map, key, cp, nullptr); } } @@ -90,7 +90,7 @@ void smpi_group_set_mapping(MPI_Group group, int index, int rank) *val_rank = rank; char * key = bprintf("%d", index); - xbt_dict_set(group->index_to_rank_map, key, val_rank, NULL); + xbt_dict_set(group->index_to_rank_map, key, val_rank, nullptr); xbt_free(key); } } @@ -108,12 +108,12 @@ int smpi_group_index(MPI_Group group, int rank) int smpi_group_rank(MPI_Group group, int index) { - int * ptr_rank = NULL; + int * ptr_rank = nullptr; char * key = bprintf("%d", index); ptr_rank = static_cast(xbt_dict_get_or_null(group->index_to_rank_map, key)); xbt_free(key); - if (ptr_rank==NULL) + if (ptr_rank==nullptr) return MPI_UNDEFINED; return *ptr_rank; } diff --git a/src/smpi/smpi_mpi_dt.cpp b/src/smpi/smpi_mpi_dt.cpp index 607c1e6555..4d53ee274d 100644 --- a/src/smpi/smpi_mpi_dt.cpp +++ b/src/smpi/smpi_mpi_dt.cpp @@ -17,7 +17,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi_dt, smpi, "Logging specific to SMPI (datatype)"); -xbt_dict_t smpi_type_keyvals = NULL; +xbt_dict_t smpi_type_keyvals = nullptr; int type_keyval_id=0;//avoid collisions #define CREATE_MPI_DATATYPE(name, type) \ @@ -28,8 +28,8 @@ int type_keyval_id=0;//avoid collisions 0, /* lb */ \ sizeof(type), /* ub = lb + size */ \ DT_FLAG_BASIC, /* flags */ \ - NULL, /* attributes */ \ - NULL, /* pointer on extended struct*/ \ + nullptr, /* attributes */ \ + nullptr, /* pointer on extended struct*/ \ 0 /* in_use counter */ \ }; \ const MPI_Datatype name = &mpi_##name; @@ -42,8 +42,8 @@ const MPI_Datatype name = &mpi_##name; 0, /* lb */ \ 0, /* ub = lb + size */ \ DT_FLAG_BASIC, /* flags */ \ - NULL, /* attributes */ \ - NULL, /* pointer on extended struct*/ \ + nullptr, /* attributes */ \ + nullptr, /* pointer on extended struct*/ \ 0 /* in_use counter */ \ }; \ const MPI_Datatype name = &mpi_##name; @@ -184,9 +184,9 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) } if(datatype->name) (*new_t)->name = xbt_strdup(datatype->name); - if(datatype->attributes !=NULL){ + if(datatype->attributes !=nullptr){ (*new_t)->attributes=xbt_dict_new(); - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; int *key; int flag; void* value_in; @@ -194,8 +194,8 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) xbt_dict_foreach(datatype->attributes, cursor, key, value_in){ smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(key), sizeof(int))); - if(elem != NULL && elem->copy_fn!=MPI_NULL_COPY_FN){ - ret = elem->copy_fn(datatype, *key, NULL, value_in, &value_out, &flag ); + if(elem != nullptr && elem->copy_fn!=MPI_NULL_COPY_FN){ + ret = elem->copy_fn(datatype, *key, nullptr, value_in, &value_out, &flag ); if(ret!=MPI_SUCCESS){ smpi_datatype_unuse(*new_t); *new_t=MPI_DATATYPE_NULL; @@ -203,7 +203,7 @@ int smpi_datatype_dup(MPI_Datatype datatype, MPI_Datatype* new_t) return ret; } if(flag) - xbt_dict_set_ext((*new_t)->attributes, reinterpret_cast(key), sizeof(int),value_out, NULL); + xbt_dict_set_ext((*new_t)->attributes, reinterpret_cast(key), sizeof(int),value_out, nullptr); } } } @@ -235,7 +235,7 @@ void smpi_datatype_get_name(MPI_Datatype datatype, char* name, int* length){ } void smpi_datatype_set_name(MPI_Datatype datatype, char* name){ - if(datatype->name!=NULL && (datatype->flags & DT_FLAG_PREDEFINED) == 0) + if(datatype->name!=nullptr && (datatype->flags & DT_FLAG_PREDEFINED) == 0) xbt_free(datatype->name); datatype->name = xbt_strdup(name); } @@ -369,7 +369,7 @@ s_smpi_mpi_vector_t* smpi_datatype_vector_create( int block_stride, int block_le void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int sizeof_substruct, void *struct_type, int flags){ MPI_Datatype new_t= xbt_new(s_smpi_mpi_datatype_t,1); - new_t->name = NULL; + new_t->name = nullptr; new_t->size = size; new_t->sizeof_substruct = size>0? sizeof_substruct:0; new_t->lb = lb; @@ -377,7 +377,7 @@ void smpi_datatype_create(MPI_Datatype* new_type, int size,int lb, int ub, int s new_t->flags = flags; new_t->substruct = struct_type; new_t->in_use=1; - new_t->attributes=NULL; + new_t->attributes=nullptr; *new_type = new_t; #if HAVE_MC @@ -398,15 +398,15 @@ void smpi_datatype_free(MPI_Datatype* type){ return; } - if((*type)->attributes !=NULL){ - xbt_dict_cursor_t cursor = NULL; + if((*type)->attributes !=nullptr){ + xbt_dict_cursor_t cursor = nullptr; int* key; void * value; int flag; xbt_dict_foreach((*type)->attributes, cursor, key, value){ smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(key), sizeof(int))); - if(elem!=NULL && elem->delete_fn!=NULL) + if(elem!=nullptr && elem->delete_fn!=nullptr) elem->delete_fn(*type,*key, value, &flag); } xbt_dict_free(&(*type)->attributes); @@ -499,7 +499,7 @@ void use_contiguous(MPI_Datatype* d){ s_smpi_mpi_contiguous_t* smpi_datatype_contiguous_create( MPI_Aint lb, int block_count, MPI_Datatype old_type, int size_oldtype){ if(block_count==0) - return NULL; + return nullptr; s_smpi_mpi_contiguous_t *new_t= xbt_new(s_smpi_mpi_contiguous_t,1); new_t->base.serialize = &serialize_contiguous; new_t->base.unserialize = &unserialize_contiguous; @@ -551,7 +551,7 @@ int smpi_datatype_vector(int count, int blocklen, int stride, MPI_Datatype old_t }else{ /* in this situation the data are contignous thus it's not required to serialize and unserialize it*/ smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type), 0, ((count -1) * stride + blocklen)* - smpi_datatype_size(old_type), 0, NULL, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS); + smpi_datatype_size(old_type), 0, nullptr, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS); retval=MPI_SUCCESS; } return retval; @@ -676,7 +676,7 @@ int smpi_datatype_hvector(int count, int blocklen, MPI_Aint stride, MPI_Datatype retval=MPI_SUCCESS; }else{ smpi_datatype_create(new_type, count * blocklen * smpi_datatype_size(old_type),0,count * blocklen * - smpi_datatype_size(old_type), 0, NULL, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS); + smpi_datatype_size(old_type), 0, nullptr, DT_FLAG_VECTOR|DT_FLAG_CONTIGUOUS); retval=MPI_SUCCESS; } return retval; @@ -1567,7 +1567,7 @@ void smpi_op_apply(MPI_Op op, const void *invec, void *inoutvec, int *len, MPI_D int smpi_type_attr_delete(MPI_Datatype type, int keyval){ smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; if(elem->delete_fn!=MPI_NULL_DELETE_FN){ void * value; @@ -1578,7 +1578,7 @@ int smpi_type_attr_delete(MPI_Datatype type, int keyval){ return ret; } } - if(type->attributes==NULL) + if(type->attributes==nullptr) return MPI_ERR_ARG; xbt_dict_remove_ext(type->attributes, reinterpret_cast(&keyval), sizeof(int)); @@ -1588,10 +1588,10 @@ int smpi_type_attr_delete(MPI_Datatype type, int keyval){ int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* flag){ smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; xbt_ex_t ex; - if(type->attributes==NULL){ + if(type->attributes==nullptr){ *flag=0; return MPI_SUCCESS; } @@ -1607,11 +1607,11 @@ int smpi_type_attr_get(MPI_Datatype type, int keyval, void* attr_value, int* fla } int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){ - if(smpi_type_keyvals==NULL) + if(smpi_type_keyvals==nullptr) smpi_type_keyvals = xbt_dict_new(); smpi_type_key_elem elem = static_cast(xbt_dict_get_or_null_ext(smpi_type_keyvals, reinterpret_cast(&keyval), sizeof(int))); - if(elem==NULL) + if(elem==nullptr) return MPI_ERR_ARG; int flag; void* value; @@ -1621,16 +1621,16 @@ int smpi_type_attr_put(MPI_Datatype type, int keyval, void* attr_value){ if(ret!=MPI_SUCCESS) return ret; } - if(type->attributes==NULL) + if(type->attributes==nullptr) type->attributes=xbt_dict_new(); - xbt_dict_set_ext(type->attributes, reinterpret_cast(&keyval), sizeof(int), attr_value, NULL); + xbt_dict_set_ext(type->attributes, reinterpret_cast(&keyval), sizeof(int), attr_value, nullptr); return MPI_SUCCESS; } int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval, void* extra_state){ - if(smpi_type_keyvals==NULL) + if(smpi_type_keyvals==nullptr) smpi_type_keyvals = xbt_dict_new(); smpi_type_key_elem value = (smpi_type_key_elem) xbt_new0(s_smpi_mpi_type_key_elem_t,1); @@ -1639,7 +1639,7 @@ int smpi_type_keyval_create(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delet value->delete_fn=delete_fn; *keyval = type_keyval_id; - xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast(keyval), sizeof(int),reinterpret_cast(value), NULL); + xbt_dict_set_ext(smpi_type_keyvals,reinterpret_cast(keyval), sizeof(int),reinterpret_cast(value), nullptr); type_keyval_id++; return MPI_SUCCESS; } diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index 78b73c6a02..6a56ecc2e5 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -85,7 +85,7 @@ int PMPI_Get_library_version (char *version,int *len){ int PMPI_Init_thread(int *argc, char ***argv, int required, int *provided) { - if (provided != NULL) { + if (provided != nullptr) { *provided = MPI_THREAD_SINGLE; } return MPI_Init(argc, argv); @@ -95,7 +95,7 @@ int PMPI_Query_thread(int *provided) { int retval = 0; - if (provided == NULL) { + if (provided == nullptr) { retval = MPI_ERR_ARG; } else { *provided = MPI_THREAD_SINGLE; @@ -108,7 +108,7 @@ int PMPI_Is_thread_main(int *flag) { int retval = 0; - if (flag == NULL) { + if (flag == nullptr) { retval = MPI_ERR_ARG; } else { *flag = smpi_process_index() == 0; @@ -141,7 +141,7 @@ int PMPI_Address(void *location, MPI_Aint * address) { int retval = 0; - if (address==NULL) { + if (address==nullptr) { retval = MPI_ERR_ARG; } else { *address = reinterpret_cast(location); @@ -174,7 +174,7 @@ int PMPI_Type_size(MPI_Datatype datatype, int *size) if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (size == NULL) { + } else if (size == nullptr) { retval = MPI_ERR_ARG; } else { *size = static_cast(smpi_datatype_size(datatype)); @@ -189,7 +189,7 @@ int PMPI_Type_get_extent(MPI_Datatype datatype, MPI_Aint * lb, MPI_Aint * extent if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (lb == NULL || extent == NULL) { + } else if (lb == nullptr || extent == nullptr) { retval = MPI_ERR_ARG; } else { retval = smpi_datatype_extent(datatype, lb, extent); @@ -208,7 +208,7 @@ int PMPI_Type_extent(MPI_Datatype datatype, MPI_Aint * extent) if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (extent == NULL) { + } else if (extent == nullptr) { retval = MPI_ERR_ARG; } else { *extent = smpi_datatype_get_extent(datatype); @@ -223,7 +223,7 @@ int PMPI_Type_lb(MPI_Datatype datatype, MPI_Aint * disp) if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (disp == NULL) { + } else if (disp == nullptr) { retval = MPI_ERR_ARG; } else { *disp = smpi_datatype_lb(datatype); @@ -238,7 +238,7 @@ int PMPI_Type_ub(MPI_Datatype datatype, MPI_Aint * disp) if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (disp == NULL) { + } else if (disp == nullptr) { retval = MPI_ERR_ARG; } else { *disp = smpi_datatype_ub(datatype); @@ -262,7 +262,7 @@ int PMPI_Op_create(MPI_User_function * function, int commute, MPI_Op * op) { int retval = 0; - if (function == NULL || op == NULL) { + if (function == nullptr || op == nullptr) { retval = MPI_ERR_ARG; } else { *op = smpi_op_new(function, (commute!=0)); @@ -275,7 +275,7 @@ int PMPI_Op_free(MPI_Op * op) { int retval = 0; - if (op == NULL) { + if (op == nullptr) { retval = MPI_ERR_ARG; } else if (*op == MPI_OP_NULL) { retval = MPI_ERR_OP; @@ -291,7 +291,7 @@ int PMPI_Group_free(MPI_Group * group) { int retval = 0; - if (group == NULL) { + if (group == nullptr) { retval = MPI_ERR_ARG; } else { smpi_group_destroy(*group); @@ -307,7 +307,7 @@ int PMPI_Group_size(MPI_Group group, int *size) if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (size == NULL) { + } else if (size == nullptr) { retval = MPI_ERR_ARG; } else { *size = smpi_group_size(group); @@ -322,7 +322,7 @@ int PMPI_Group_rank(MPI_Group group, int *rank) if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (rank == NULL) { + } else if (rank == nullptr) { retval = MPI_ERR_ARG; } else { *rank = smpi_group_rank(group, smpi_process_index()); @@ -356,7 +356,7 @@ int PMPI_Group_compare(MPI_Group group1, MPI_Group group2, int *result) if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (result == NULL) { + } else if (result == nullptr) { retval = MPI_ERR_ARG; } else { *result = smpi_group_compare(group1, group2); @@ -371,7 +371,7 @@ int PMPI_Group_union(MPI_Group group1, MPI_Group group2, MPI_Group * newgroup) if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { size = smpi_group_size(group1); @@ -408,7 +408,7 @@ int PMPI_Group_intersection(MPI_Group group1, MPI_Group group2, MPI_Group * newg if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { size = smpi_group_size(group2); @@ -444,7 +444,7 @@ int PMPI_Group_difference(MPI_Group group1, MPI_Group group2, MPI_Group * newgro if (group1 == MPI_GROUP_NULL || group2 == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { size = smpi_group_size(group1); @@ -479,7 +479,7 @@ int PMPI_Group_incl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { retval = smpi_group_incl(group, n, ranks, newgroup); @@ -493,7 +493,7 @@ int PMPI_Group_excl(MPI_Group group, int n, int *ranks, MPI_Group * newgroup) if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { if (n == 0) { @@ -536,7 +536,7 @@ int PMPI_Group_range_incl(MPI_Group group, int n, int ranges[][3], MPI_Group * n if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { if (n == 0) { @@ -596,7 +596,7 @@ int PMPI_Group_range_excl(MPI_Group group, int n, int ranges[][3], MPI_Group * n if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newgroup == NULL) { + } else if (newgroup == nullptr) { retval = MPI_ERR_ARG; } else { if (n == 0) { @@ -673,7 +673,7 @@ int PMPI_Comm_rank(MPI_Comm comm, int *rank) int retval = 0; if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (rank == NULL) { + } else if (rank == nullptr) { retval = MPI_ERR_ARG; } else { *rank = smpi_comm_rank(comm); @@ -687,7 +687,7 @@ int PMPI_Comm_size(MPI_Comm comm, int *size) int retval = 0; if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (size == NULL) { + } else if (size == nullptr) { retval = MPI_ERR_ARG; } else { *size = smpi_comm_size(comm); @@ -702,7 +702,7 @@ int PMPI_Comm_get_name (MPI_Comm comm, char* name, int* len) if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (name == NULL || len == NULL) { + } else if (name == nullptr || len == nullptr) { retval = MPI_ERR_ARG; } else { smpi_comm_get_name(comm, name, len); @@ -717,7 +717,7 @@ int PMPI_Comm_group(MPI_Comm comm, MPI_Group * group) if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (group == NULL) { + } else if (group == nullptr) { retval = MPI_ERR_ARG; } else { *group = smpi_comm_group(comm); @@ -735,7 +735,7 @@ int PMPI_Comm_compare(MPI_Comm comm1, MPI_Comm comm2, int *result) if (comm1 == MPI_COMM_NULL || comm2 == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (result == NULL) { + } else if (result == nullptr) { retval = MPI_ERR_ARG; } else { if (comm1 == comm2) { /* Same communicators means same groups */ @@ -757,7 +757,7 @@ int PMPI_Comm_dup(MPI_Comm comm, MPI_Comm * newcomm) if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (newcomm == NULL) { + } else if (newcomm == nullptr) { retval = MPI_ERR_ARG; } else { retval = smpi_comm_dup(comm, newcomm); @@ -773,14 +773,14 @@ int PMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm * newcomm) retval = MPI_ERR_COMM; } else if (group == MPI_GROUP_NULL) { retval = MPI_ERR_GROUP; - } else if (newcomm == NULL) { + } else if (newcomm == nullptr) { retval = MPI_ERR_ARG; } else if(smpi_group_rank(group,smpi_process_index())==MPI_UNDEFINED){ *newcomm= MPI_COMM_NULL; retval = MPI_SUCCESS; }else{ smpi_group_use(group); - *newcomm = smpi_comm_new(group, NULL); + *newcomm = smpi_comm_new(group, nullptr); retval = MPI_SUCCESS; } return retval; @@ -790,7 +790,7 @@ int PMPI_Comm_free(MPI_Comm * comm) { int retval = 0; - if (comm == NULL) { + if (comm == nullptr) { retval = MPI_ERR_ARG; } else if (*comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -807,7 +807,7 @@ int PMPI_Comm_disconnect(MPI_Comm * comm) /* TODO: wait until all communication in comm are done */ int retval = 0; - if (comm == NULL) { + if (comm == nullptr) { retval = MPI_ERR_ARG; } else if (*comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -824,7 +824,7 @@ int PMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm* comm_out) int retval = 0; smpi_bench_end(); - if (comm_out == NULL) { + if (comm_out == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -842,7 +842,7 @@ int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag int retval = 0; smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -855,7 +855,7 @@ int PMPI_Send_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag retval = MPI_SUCCESS; } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request != NULL) + if (retval != MPI_SUCCESS && request != nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -865,7 +865,7 @@ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag int retval = 0; smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -878,7 +878,7 @@ int PMPI_Recv_init(void *buf, int count, MPI_Datatype datatype, int src, int tag retval = MPI_SUCCESS; } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request != NULL) + if (retval != MPI_SUCCESS && request != nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -888,7 +888,7 @@ int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int ta int retval = 0; smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -901,7 +901,7 @@ int PMPI_Ssend_init(void* buf, int count, MPI_Datatype datatype, int dst, int ta retval = MPI_SUCCESS; } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request != NULL) + if (retval != MPI_SUCCESS && request != nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -911,7 +911,7 @@ int PMPI_Start(MPI_Request * request) int retval = 0; smpi_bench_end(); - if (request == NULL || *request == MPI_REQUEST_NULL) { + if (request == nullptr || *request == MPI_REQUEST_NULL) { retval = MPI_ERR_REQUEST; } else { smpi_mpi_start(*request); @@ -926,7 +926,7 @@ int PMPI_Startall(int count, MPI_Request * requests) int retval; int i = 0; smpi_bench_end(); - if (requests == NULL) { + if (requests == nullptr) { retval = MPI_ERR_ARG; } else { retval = MPI_SUCCESS; @@ -964,7 +964,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -973,7 +973,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP retval = MPI_SUCCESS; } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){ retval = MPI_ERR_RANK; - } else if ((count < 0) || (buf==NULL && count > 0)) { + } else if ((count < 0) || (buf==nullptr && count > 0)) { retval = MPI_ERR_COUNT; } else if (!is_datatype_valid(datatype)) { retval = MPI_ERR_TYPE; @@ -1004,7 +1004,7 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MP } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request != NULL) + if (retval != MPI_SUCCESS && request != nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -1015,7 +1015,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP int retval = 0; smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -1024,7 +1024,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP retval = MPI_SUCCESS; } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){ retval = MPI_ERR_RANK; - } else if ((count < 0) || (buf==NULL && count > 0)) { + } else if ((count < 0) || (buf==nullptr && count > 0)) { retval = MPI_ERR_COUNT; } else if (!is_datatype_valid(datatype)) { retval = MPI_ERR_TYPE; @@ -1055,7 +1055,7 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MP } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request!=NULL) + if (retval != MPI_SUCCESS && request!=nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -1065,7 +1065,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M int retval = 0; smpi_bench_end(); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -1074,7 +1074,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M retval = MPI_SUCCESS; } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){ retval = MPI_ERR_RANK; - } else if ((count < 0)|| (buf==NULL && count > 0)) { + } else if ((count < 0)|| (buf==nullptr && count > 0)) { retval = MPI_ERR_COUNT; } else if (!is_datatype_valid(datatype)) { retval = MPI_ERR_TYPE; @@ -1105,7 +1105,7 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, M } smpi_bench_begin(); - if (retval != MPI_SUCCESS && request!=NULL) + if (retval != MPI_SUCCESS && request!=nullptr) *request = MPI_REQUEST_NULL; return retval; } @@ -1123,7 +1123,7 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, MPI retval = MPI_SUCCESS; } else if (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0)){ retval = MPI_ERR_RANK; - } else if ((count < 0) || (buf==NULL && count > 0)) { + } else if ((count < 0) || (buf==nullptr && count > 0)) { retval = MPI_ERR_COUNT; } else if (!is_datatype_valid(datatype)) { retval = MPI_ERR_TYPE; @@ -1219,7 +1219,7 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP retval = MPI_SUCCESS; } else if (dst >= smpi_group_size(smpi_comm_group(comm)) || dst <0){ retval = MPI_ERR_RANK; - } else if ((count < 0) || (buf==NULL && count > 0)) { + } else if ((count < 0) || (buf==nullptr && count > 0)) { retval = MPI_ERR_COUNT; } else if (!is_datatype_valid(datatype)){ retval = MPI_ERR_TYPE; @@ -1272,7 +1272,7 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dst, (src!=MPI_ANY_SOURCE && (src >= smpi_group_size(smpi_comm_group(comm)) || src <0))){ retval = MPI_ERR_RANK; } else if ((sendcount < 0 || recvcount<0) || - (sendbuf==NULL && sendcount > 0) || (recvbuf==NULL && recvcount>0)) { + (sendbuf==nullptr && sendcount > 0) || (recvbuf==nullptr && recvcount>0)) { retval = MPI_ERR_COUNT; } else if((sendtag<0 && sendtag != MPI_ANY_TAG)||(recvtag<0 && recvtag != MPI_ANY_TAG)){ retval = MPI_ERR_TAG; @@ -1338,14 +1338,14 @@ int PMPI_Test(MPI_Request * request, int *flag, MPI_Status * status) { int retval = 0; smpi_bench_end(); - if (request == NULL || flag == NULL) { + if (request == nullptr || flag == nullptr) { retval = MPI_ERR_ARG; } else if (*request == MPI_REQUEST_NULL) { *flag= true; smpi_empty_status(status); retval = MPI_SUCCESS; } else { - int rank = (request!=NULL && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1; + int rank = (request!=nullptr && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1; instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type = TRACING_TEST; @@ -1365,7 +1365,7 @@ int PMPI_Testany(int count, MPI_Request requests[], int *index, int *flag, MPI_S int retval = 0; smpi_bench_end(); - if (index == NULL || flag == NULL) { + if (index == nullptr || flag == nullptr) { retval = MPI_ERR_ARG; } else { *flag = smpi_mpi_testany(count, requests, index, status); @@ -1380,7 +1380,7 @@ int PMPI_Testall(int count, MPI_Request* requests, int* flag, MPI_Status* status int retval = 0; smpi_bench_end(); - if (flag == NULL) { + if (flag == nullptr) { retval = MPI_ERR_ARG; } else { *flag = smpi_mpi_testall(count, requests, statuses); @@ -1394,7 +1394,7 @@ int PMPI_Probe(int source, int tag, MPI_Comm comm, MPI_Status* status) { int retval = 0; smpi_bench_end(); - if (status == NULL) { + if (status == nullptr) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -1414,7 +1414,7 @@ int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* statu int retval = 0; smpi_bench_end(); - if ((flag == NULL) || (status == NULL)) { + if ((flag == nullptr) || (status == nullptr)) { retval = MPI_ERR_ARG; } else if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; @@ -1439,13 +1439,13 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) smpi_empty_status(status); - if (request == NULL) { + if (request == nullptr) { retval = MPI_ERR_ARG; } else if (*request == MPI_REQUEST_NULL) { retval = MPI_SUCCESS; } else { - int rank = (request!=NULL && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1; + int rank = (request!=nullptr && (*request)->comm != MPI_COMM_NULL) ? smpi_process_index() : -1; int src_traced = (*request)->src; int dst_traced = (*request)->dst; @@ -1475,14 +1475,14 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * status) { - if (index == NULL) + if (index == nullptr) return MPI_ERR_ARG; smpi_bench_end(); //save requests information for tracing int i; - int *srcs = NULL, *dsts = NULL, *recvs = NULL; - MPI_Comm* comms = NULL; + int *srcs = nullptr, *dsts = nullptr, *recvs = nullptr; + MPI_Comm* comms = nullptr; if(count>0){ srcs = xbt_new0(int, count); dsts = xbt_new0(int, count); @@ -1589,7 +1589,7 @@ int PMPI_Waitsome(int incount, MPI_Request requests[], int *outcount, int *indic int retval = 0; smpi_bench_end(); - if (outcount == NULL) { + if (outcount == nullptr) { retval = MPI_ERR_ARG; } else { *outcount = smpi_mpi_waitsome(incount, requests, indices, status); @@ -1604,7 +1604,7 @@ int PMPI_Testsome(int incount, MPI_Request requests[], int* outcount, int* indic int retval = 0; smpi_bench_end(); - if (outcount == NULL) { + if (outcount == nullptr) { retval = MPI_ERR_ARG; } else { *outcount = smpi_mpi_testsome(incount, requests, indices, status); @@ -1740,7 +1740,7 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, void *recv retval = MPI_ERR_TYPE; } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){ retval = MPI_ERR_COUNT; - } else if (recvcounts == NULL || displs == NULL) { + } else if (recvcounts == nullptr || displs == nullptr) { retval = MPI_ERR_ARG; } else { char* sendtmpbuf = static_cast(sendbuf); @@ -1845,7 +1845,7 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, retval = MPI_ERR_TYPE; } else if (( sendbuf != MPI_IN_PLACE) && (sendcount <0)){ retval = MPI_ERR_COUNT; - } else if (recvcounts == NULL || displs == NULL) { + } else if (recvcounts == nullptr || displs == nullptr) { retval = MPI_ERR_ARG; } else { @@ -1898,7 +1898,7 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, || ((recvbuf !=MPI_IN_PLACE) && (!is_datatype_valid(recvtype)))){ retval = MPI_ERR_TYPE; } else if ((sendbuf == recvbuf) || - ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == NULL))){ + ((smpi_comm_rank(comm)==root) && sendcount>0 && (sendbuf == nullptr))){ retval = MPI_ERR_BUFFER; }else { @@ -1942,7 +1942,7 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, if (comm == MPI_COMM_NULL) { retval = MPI_ERR_COMM; - } else if (sendcounts == NULL || displs == NULL) { + } else if (sendcounts == nullptr || displs == nullptr) { retval = MPI_ERR_ARG; } else if (((smpi_comm_rank(comm)==root) && (sendtype == MPI_DATATYPE_NULL)) || ((recvbuf !=MPI_IN_PLACE) && (recvtype == MPI_DATATYPE_NULL))) { @@ -2158,7 +2158,7 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, MPI_Datat retval = MPI_ERR_TYPE; } else if (op == MPI_OP_NULL) { retval = MPI_ERR_OP; - } else if (recvcounts == NULL) { + } else if (recvcounts == nullptr) { retval = MPI_ERR_ARG; } else { int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; @@ -2287,7 +2287,7 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps,MPI_Datatype s retval = MPI_ERR_COMM; } else if (sendtype == MPI_DATATYPE_NULL || recvtype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (sendcounts == NULL || senddisps == NULL || recvcounts == NULL || recvdisps == NULL) { + } else if (sendcounts == nullptr || senddisps == nullptr || recvcounts == nullptr || recvdisps == nullptr) { retval = MPI_ERR_ARG; } else { int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; @@ -2345,7 +2345,7 @@ int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count) int retval = MPI_SUCCESS; size_t size; - if (status == NULL || count == NULL) { + if (status == nullptr || count == nullptr) { retval = MPI_ERR_ARG; } else if (!is_datatype_valid(datatype)) { retval = MPI_ERR_TYPE; @@ -2378,7 +2378,7 @@ int PMPI_Type_contiguous(int count, MPI_Datatype old_type, MPI_Datatype* new_typ int PMPI_Type_commit(MPI_Datatype* datatype) { int retval = 0; - if (datatype == NULL || *datatype == MPI_DATATYPE_NULL) { + if (datatype == nullptr || *datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; } else { smpi_datatype_commit(datatype); @@ -2523,15 +2523,15 @@ int PMPI_Initialized(int* flag) { return MPI_SUCCESS; } -/* The topo part of MPI_COMM_WORLD should always be NULL. When other topologies will be implemented, not only should we - * check if the topology is NULL, but we should check if it is the good topology type (so we have to add a +/* The topo part of MPI_COMM_WORLD should always be nullptr. When other topologies will be implemented, not only should we + * check if the topology is nullptr, but we should check if it is the good topology type (so we have to add a * MPIR_Topo_Type field, and replace the MPI_Topology field by an union)*/ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int reorder, MPI_Comm* comm_cart) { int retval = 0; if (comm_old == MPI_COMM_NULL){ retval = MPI_ERR_COMM; - } else if (ndims < 0 || (ndims > 0 && (dims == NULL || periodic == NULL)) || comm_cart == NULL) { + } else if (ndims < 0 || (ndims > 0 && (dims == nullptr || periodic == nullptr)) || comm_cart == nullptr) { retval = MPI_ERR_ARG; } else{ retval = smpi_mpi_cart_create(comm_old, ndims, dims, periodic, reorder, comm_cart); @@ -2540,27 +2540,27 @@ int PMPI_Cart_create(MPI_Comm comm_old, int ndims, int* dims, int* periodic, int } int PMPI_Cart_rank(MPI_Comm comm, int* coords, int* rank) { - if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) { + if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } - if (coords == NULL) { + if (coords == nullptr) { return MPI_ERR_ARG; } return smpi_mpi_cart_rank(comm, coords, rank); } int PMPI_Cart_shift(MPI_Comm comm, int direction, int displ, int* source, int* dest) { - if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) { + if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } - if (source == NULL || dest == NULL || direction < 0 ) { + if (source == nullptr || dest == nullptr || direction < 0 ) { return MPI_ERR_ARG; } return smpi_mpi_cart_shift(comm, direction, displ, source, dest); } int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) { - if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) { + if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } if (rank < 0 || rank >= smpi_comm_size(comm)) { @@ -2569,34 +2569,34 @@ int PMPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) { if (maxdims <= 0) { return MPI_ERR_ARG; } - if(coords == NULL) { + if(coords == nullptr) { return MPI_ERR_ARG; } return smpi_mpi_cart_coords(comm, rank, maxdims, coords); } int PMPI_Cart_get(MPI_Comm comm, int maxdims, int* dims, int* periods, int* coords) { - if(comm == NULL || smpi_comm_topo(comm) == NULL) { + if(comm == nullptr || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } - if(maxdims <= 0 || dims == NULL || periods == NULL || coords == NULL) { + if(maxdims <= 0 || dims == nullptr || periods == nullptr || coords == nullptr) { return MPI_ERR_ARG; } return smpi_mpi_cart_get(comm, maxdims, dims, periods, coords); } int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) { - if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) { + if (comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } - if (ndims == NULL) { + if (ndims == nullptr) { return MPI_ERR_ARG; } return smpi_mpi_cartdim_get(comm, ndims); } int PMPI_Dims_create(int nnodes, int ndims, int* dims) { - if(dims == NULL) { + if(dims == nullptr) { return MPI_ERR_ARG; } if (ndims < 1 || nnodes < 1) { @@ -2607,10 +2607,10 @@ int PMPI_Dims_create(int nnodes, int ndims, int* dims) { } int PMPI_Cart_sub(MPI_Comm comm, int* remain_dims, MPI_Comm* comm_new) { - if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == NULL) { + if(comm == MPI_COMM_NULL || smpi_comm_topo(comm) == nullptr) { return MPI_ERR_TOPOLOGY; } - if (comm_new == NULL) { + if (comm_new == nullptr) { return MPI_ERR_ARG; } return smpi_mpi_cart_sub(comm, remain_dims, comm_new); @@ -2636,7 +2636,7 @@ int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MP smpi_bench_end(); if (comm == MPI_COMM_NULL) { retval= MPI_ERR_COMM; - }else if ((base == NULL && size != 0) || disp_unit <= 0 || size < 0 ){ + }else if ((base == nullptr && size != 0) || disp_unit <= 0 || size < 0 ){ retval= MPI_ERR_OTHER; }else{ *win = smpi_mpi_win_create( base, size, disp_unit, info, comm); @@ -2649,7 +2649,7 @@ int PMPI_Win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info info, MP int PMPI_Win_free( MPI_Win* win){ int retval = 0; smpi_bench_end(); - if (win == NULL || *win == MPI_WIN_NULL) { + if (win == nullptr || *win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; }else{ retval=smpi_mpi_win_free(win); @@ -2663,7 +2663,7 @@ int PMPI_Win_set_name(MPI_Win win, char * name) int retval = 0; if (win == MPI_WIN_NULL) { retval = MPI_ERR_TYPE; - } else if (name == NULL) { + } else if (name == nullptr) { retval = MPI_ERR_ARG; } else { smpi_mpi_win_set_name(win, name); @@ -2678,7 +2678,7 @@ int PMPI_Win_get_name(MPI_Win win, char * name, int* len) if (win == MPI_WIN_NULL) { retval = MPI_ERR_WIN; - } else if (name == NULL) { + } else if (name == nullptr) { retval = MPI_ERR_ARG; } else { smpi_mpi_win_get_name(win, name, len); @@ -2705,7 +2705,7 @@ int PMPI_Win_fence( int assert, MPI_Win win){ retval = MPI_ERR_WIN; } else { int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, NULL); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, nullptr); retval = smpi_mpi_win_fence(assert, win); TRACE_smpi_collective_out(rank, -1, __FUNCTION__); } @@ -2726,7 +2726,7 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if (target_disp <0){ retval = MPI_ERR_ARG; } else if ((origin_count < 0 || target_count < 0) || - (origin_addr==NULL && origin_count > 0)){ + (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; } else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) { retval = MPI_ERR_TYPE; @@ -2735,7 +2735,7 @@ int PMPI_Get( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, MPI_Group group; smpi_mpi_win_get_group(win, &group); int src_traced = smpi_group_index(group, target_rank); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, NULL); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, nullptr); retval = smpi_mpi_get( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, win); @@ -2759,7 +2759,7 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, } else if (target_disp <0){ retval = MPI_ERR_ARG; } else if ((origin_count < 0 || target_count < 0) || - (origin_addr==NULL && origin_count > 0)){ + (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; } else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) { retval = MPI_ERR_TYPE; @@ -2768,7 +2768,7 @@ int PMPI_Put( void *origin_addr, int origin_count, MPI_Datatype origin_datatype, MPI_Group group; smpi_mpi_win_get_group(win, &group); int dst_traced = smpi_group_index(group, target_rank); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, NULL); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, nullptr); TRACE_smpi_send(rank, rank, dst_traced, origin_count*smpi_datatype_size(origin_datatype)); retval = smpi_mpi_put( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, @@ -2793,7 +2793,7 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da } else if (target_disp <0){ retval = MPI_ERR_ARG; } else if ((origin_count < 0 || target_count < 0) || - (origin_addr==NULL && origin_count > 0)){ + (origin_addr==nullptr && origin_count > 0)){ retval = MPI_ERR_COUNT; } else if ((!is_datatype_valid(origin_datatype)) || (!is_datatype_valid(target_datatype))) { @@ -2805,7 +2805,7 @@ int PMPI_Accumulate( void *origin_addr, int origin_count, MPI_Datatype origin_da MPI_Group group; smpi_mpi_win_get_group(win, &group); int src_traced = smpi_group_index(group, target_rank); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, NULL); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, nullptr); retval = smpi_mpi_accumulate( origin_addr, origin_count, origin_datatype, target_rank, target_disp, target_count, target_datatype, op, win); @@ -2826,7 +2826,7 @@ int PMPI_Win_post(MPI_Group group, int assert, MPI_Win win){ } else { int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, NULL); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, nullptr); retval = smpi_mpi_win_post(group,assert,win); TRACE_smpi_collective_out(rank, -1, __FUNCTION__); } @@ -2844,7 +2844,7 @@ int PMPI_Win_start(MPI_Group group, int assert, MPI_Win win){ } else { int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, NULL); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, nullptr); retval = smpi_mpi_win_start(group,assert,win); TRACE_smpi_collective_out(rank, -1, __FUNCTION__); } @@ -2860,7 +2860,7 @@ int PMPI_Win_complete(MPI_Win win){ } else { int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, NULL); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, nullptr); retval = smpi_mpi_win_complete(win); @@ -2878,7 +2878,7 @@ int PMPI_Win_wait(MPI_Win win){ } else { int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, NULL); + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, nullptr); retval = smpi_mpi_win_wait(win); @@ -2890,7 +2890,7 @@ int PMPI_Win_wait(MPI_Win win){ int PMPI_Alloc_mem(MPI_Aint size, MPI_Info info, void *baseptr){ void *ptr = xbt_malloc(size); - if(ptr==NULL) + if(ptr==nullptr) return MPI_ERR_NO_MEM; else { *static_cast(baseptr) = ptr; @@ -2908,7 +2908,7 @@ int PMPI_Type_set_name(MPI_Datatype datatype, char * name) int retval = 0; if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (name == NULL) { + } else if (name == nullptr) { retval = MPI_ERR_ARG; } else { smpi_datatype_set_name(datatype, name); @@ -2923,7 +2923,7 @@ int PMPI_Type_get_name(MPI_Datatype datatype, char * name, int* len) if (datatype == MPI_DATATYPE_NULL) { retval = MPI_ERR_TYPE; - } else if (name == NULL) { + } else if (name == nullptr) { retval = MPI_ERR_ARG; } else { smpi_datatype_get_name(datatype, name, len); @@ -3115,24 +3115,24 @@ int PMPI_Type_free_keyval(int* keyval) { } int PMPI_Info_create( MPI_Info *info){ - if (info == NULL) + if (info == nullptr) return MPI_ERR_ARG; *info = xbt_new(s_smpi_mpi_info_t, 1); - (*info)->info_dict= xbt_dict_new_homogeneous(NULL); + (*info)->info_dict= xbt_dict_new_homogeneous(nullptr); (*info)->refcount=1; return MPI_SUCCESS; } int PMPI_Info_set( MPI_Info info, char *key, char *value){ - if (info == NULL || key == NULL || value == NULL) + if (info == nullptr || key == nullptr || value == nullptr) return MPI_ERR_ARG; - xbt_dict_set(info->info_dict, key, (void*)value, NULL); + xbt_dict_set(info->info_dict, key, (void*)value, nullptr); return MPI_SUCCESS; } int PMPI_Info_free( MPI_Info *info){ - if (info == NULL || *info==NULL) + if (info == nullptr || *info==nullptr) return MPI_ERR_ARG; (*info)->refcount--; if((*info)->refcount==0){ @@ -3145,9 +3145,9 @@ int PMPI_Info_free( MPI_Info *info){ int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){ *flag=false; - if (info == NULL || key == NULL || valuelen <0) + if (info == nullptr || key == nullptr || valuelen <0) return MPI_ERR_ARG; - if (value == NULL) + if (value == nullptr) return MPI_ERR_INFO_VALUE; char* tmpvalue=static_cast(xbt_dict_get_or_null(info->info_dict, key)); if(tmpvalue){ @@ -3159,23 +3159,23 @@ int PMPI_Info_get(MPI_Info info,char *key,int valuelen, char *value, int *flag){ } int PMPI_Info_dup(MPI_Info info, MPI_Info *newinfo){ - if (info == NULL || newinfo==NULL) + if (info == nullptr || newinfo==nullptr) return MPI_ERR_ARG; *newinfo = xbt_new(s_smpi_mpi_info_t, 1); - (*newinfo)->info_dict= xbt_dict_new_homogeneous(NULL); + (*newinfo)->info_dict= xbt_dict_new_homogeneous(nullptr); (*newinfo)->refcount=1; - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; int *key; void* data; xbt_dict_foreach(info->info_dict,cursor,key,data){ - xbt_dict_set((*newinfo)->info_dict, reinterpret_cast(key), data, NULL); + xbt_dict_set((*newinfo)->info_dict, reinterpret_cast(key), data, nullptr); } return MPI_SUCCESS; } int PMPI_Info_delete(MPI_Info info, char *key){ xbt_ex_t e; - if (info == NULL || key==NULL) + if (info == nullptr || key==nullptr) return MPI_ERR_ARG; TRY { xbt_dict_remove(info->info_dict, key); @@ -3187,17 +3187,17 @@ int PMPI_Info_delete(MPI_Info info, char *key){ } int PMPI_Info_get_nkeys( MPI_Info info, int *nkeys){ - if (info == NULL || nkeys==NULL) + if (info == nullptr || nkeys==nullptr) return MPI_ERR_ARG; *nkeys=xbt_dict_size(info->info_dict); return MPI_SUCCESS; } int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){ - if (info == NULL || key==NULL || n<0 || n> MPI_MAX_INFO_KEY) + if (info == nullptr || key==nullptr || n<0 || n> MPI_MAX_INFO_KEY) return MPI_ERR_ARG; - xbt_dict_cursor_t cursor = NULL; + xbt_dict_cursor_t cursor = nullptr; char *keyn; void* data; int num=0; @@ -3214,7 +3214,7 @@ int PMPI_Info_get_nthkey( MPI_Info info, int n, char *key){ int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){ *flag=false; - if (info == NULL || key == NULL || valuelen==NULL) + if (info == nullptr || key == nullptr || valuelen==nullptr) return MPI_ERR_ARG; char* tmpvalue=(char*)xbt_dict_get_or_null(info->info_dict, key); if(tmpvalue){ @@ -3225,7 +3225,7 @@ int PMPI_Info_get_valuelen( MPI_Info info, char *key, int *valuelen, int *flag){ } int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outcount, MPI_Datatype type, MPI_Comm comm) { - if(incount<0 || outcount < 0 || inbuf==NULL || outbuf==NULL) + if(incount<0 || outcount < 0 || inbuf==nullptr || outbuf==nullptr) return MPI_ERR_ARG; if(!is_datatype_valid(type)) return MPI_ERR_TYPE; @@ -3235,7 +3235,7 @@ int PMPI_Unpack(void* inbuf, int incount, int* position, void* outbuf, int outco } int PMPI_Pack(void* inbuf, int incount, MPI_Datatype type, void* outbuf, int outcount, int* position, MPI_Comm comm) { - if(incount<0 || outcount < 0|| inbuf==NULL || outbuf==NULL) + if(incount<0 || outcount < 0|| inbuf==nullptr || outbuf==nullptr) return MPI_ERR_ARG; if(!is_datatype_valid(type)) return MPI_ERR_TYPE; diff --git a/src/smpi/smpi_replay.cpp b/src/smpi/smpi_replay.cpp index 3929b82947..08e9998dad 100644 --- a/src/smpi/smpi_replay.cpp +++ b/src/smpi/smpi_replay.cpp @@ -15,15 +15,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_replay,smpi,"Trace Replay with SMPI"); int communicator_size = 0; static int active_processes = 0; -xbt_dict_t reqq = NULL; +xbt_dict_t reqq = nullptr; MPI_Datatype MPI_DEFAULT_TYPE; MPI_Datatype MPI_CURRENT_TYPE; static int sendbuffer_size=0; -char* sendbuffer=NULL; +char* sendbuffer=nullptr; static int recvbuffer_size=0; -char* recvbuffer=NULL; +char* recvbuffer=nullptr; static void log_timed_action (const char *const *action, double clock){ if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ @@ -124,7 +124,7 @@ const char* encode_datatype(MPI_Datatype datatype, int* known) { //default type for output is set to MPI_BYTE // MPI_DEFAULT_TYPE is not set for output, use directly MPI_BYTE - if(known!=NULL) + if(known!=nullptr) *known=1; if (datatype==MPI_BYTE){ return ""; @@ -142,7 +142,7 @@ const char* encode_datatype(MPI_Datatype datatype, int* known) if(datatype==MPI_FLOAT) return "5"; //tell that the datatype is not handled by replay, and that its size should be measured and replayed as size*MPI_BYTE - if(known!=NULL) + if(known!=nullptr) *known=0; // default - not implemented. // do not warn here as we pass in this function even for other trace formats @@ -151,7 +151,7 @@ const char* encode_datatype(MPI_Datatype datatype, int* known) #define CHECK_ACTION_PARAMS(action, mandatory, optional) {\ int i=0;\ - while(action[i]!=NULL)\ + while(action[i]!=nullptr)\ i++;\ if(isend_size = size; extra->src = rank; extra->dst = dst_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); if (!TRACE_smpi_view_internals()) { TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE)); } - smpi_mpi_send(NULL, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD); + smpi_mpi_send(nullptr, size, MPI_CURRENT_TYPE, to , 0, MPI_COMM_WORLD); log_timed_action (action, clock); @@ -277,13 +277,13 @@ static void action_Isend(const char *const *action) extra->send_size = size; extra->src = rank; extra->dst = dst_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); if (!TRACE_smpi_view_internals()) { TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE)); } - request = smpi_mpi_isend(NULL, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD); + request = smpi_mpi_isend(nullptr, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD); TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__); request->send = 1; @@ -313,7 +313,7 @@ static void action_recv(const char *const *action) { extra->send_size = size; extra->src = src_traced; extra->dst = rank; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); //unknow size from the receiver pov @@ -322,7 +322,7 @@ static void action_recv(const char *const *action) { size=status.count; } - smpi_mpi_recv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status); + smpi_mpi_recv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status); TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); if (!TRACE_smpi_view_internals()) { @@ -352,7 +352,7 @@ static void action_Irecv(const char *const *action) extra->send_size = size; extra->src = src_traced; extra->dst = rank; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); MPI_Status status; //unknow size from the receiver pov @@ -361,7 +361,7 @@ static void action_Irecv(const char *const *action) size=status.count; } - request = smpi_mpi_irecv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD); + request = smpi_mpi_irecv(nullptr, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD); TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__); request->recv = 1; @@ -381,7 +381,7 @@ static void action_test(const char *const *action){ //if request is null here, this may mean that a previous test has succeeded //Different times in traced application and replayed version may lead to this //In this case, ignore the extra calls. - if(request!=NULL){ + if(request!=nullptr){ int rank = smpi_process_index(); instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1); extra->type=TRACING_TEST; @@ -390,7 +390,7 @@ static void action_test(const char *const *action){ flag = smpi_mpi_test(&request, &status); XBT_DEBUG("MPI_Test result: %d", flag); - /* push back request in dynar to be caught by a subsequent wait. if the test did succeed, the request is now NULL.*/ + /* push back request in dynar to be caught by a subsequent wait. if the test did succeed, the request is now nullptr.*/ xbt_dynar_push_as(get_reqq_self(),MPI_Request, request); TRACE_smpi_testing_out(rank); @@ -409,7 +409,7 @@ static void action_wait(const char *const *action){ xbt_str_join_array(action," ")); request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request); - if (request==NULL){ + if (request==nullptr){ /* Assume that the trace is well formed, meaning the comm might have been caught by a MPI_test. Then just return.*/ return; } @@ -449,9 +449,9 @@ static void action_waitall(const char *const *action){ xbt_dynar_foreach(get_reqq_self(),i,requests[i]); //save information from requests - xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), NULL); - xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), NULL); - xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), NULL); + xbt_dynar_t srcs = xbt_dynar_new(sizeof(int), nullptr); + xbt_dynar_t dsts = xbt_dynar_new(sizeof(int), nullptr); + xbt_dynar_t recvs = xbt_dynar_new(sizeof(int), nullptr); for (i = 0; static_cast(i) < count_requests; i++) { if(requests[i]){ int *asrc = xbt_new(int, 1); @@ -537,7 +537,7 @@ static void action_bcast(const char *const *action) extra->type = TRACING_BCAST; extra->send_size = size; extra->root = root_traced; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra); void *sendbuf = smpi_get_tmp_sendbuffer(size* smpi_datatype_size(MPI_CURRENT_TYPE)); @@ -569,7 +569,7 @@ static void action_reduce(const char *const *action) extra->type = TRACING_REDUCE; extra->send_size = comm_size; extra->comp_size = comp_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); extra->root = root_traced; TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); @@ -599,7 +599,7 @@ static void action_allReduce(const char *const *action) { extra->type = TRACING_ALLREDUCE; extra->send_size = comm_size; extra->comp_size = comp_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); void *recvbuf = smpi_get_tmp_sendbuffer(comm_size* smpi_datatype_size(MPI_CURRENT_TYPE)); @@ -637,8 +637,8 @@ static void action_allToAll(const char *const *action) { extra->type = TRACING_ALLTOALL; extra->send_size = send_size; extra->recv_size = recv_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); @@ -673,7 +673,7 @@ static void action_gather(const char *const *action) { MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE; } void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); - void *recv = NULL; + void *recv = nullptr; int root=0; if(action[4]) root=atoi(action[4]); @@ -687,8 +687,8 @@ static void action_gather(const char *const *action) { extra->send_size = send_size; extra->recv_size = recv_size; extra->root = root; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); TRACE_smpi_collective_in(smpi_process_index(), root, __FUNCTION__, extra); @@ -727,7 +727,7 @@ static void action_gatherv(const char *const *action) { MPI_CURRENT_TYPE2=MPI_DEFAULT_TYPE; } void *send = smpi_get_tmp_sendbuffer(send_size* smpi_datatype_size(MPI_CURRENT_TYPE)); - void *recv = NULL; + void *recv = nullptr; for(i=0;irecvcounts[i] = recvcounts[i]; extra->root = root; extra->num_processes = comm_size; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); TRACE_smpi_collective_in(smpi_process_index(), root, __FUNCTION__, extra); @@ -797,7 +797,7 @@ static void action_reducescatter(const char *const *action) { extra->recvcounts= xbt_new(int, comm_size); for(i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); extra->comp_size = comp_size; extra->num_processes = comm_size; @@ -846,8 +846,8 @@ static void action_allgather(const char *const *action) { extra->type = TRACING_ALLGATHER; extra->send_size = sendcount; extra->recv_size= recvcount; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); extra->num_processes = smpi_comm_size(MPI_COMM_WORLD); TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); @@ -900,8 +900,8 @@ static void action_allgatherv(const char *const *action) { extra->recvcounts= xbt_new(int, comm_size); for(i=0; i< comm_size; i++)//copy data to avoid bad free extra->recvcounts[i] = recvcounts[i]; - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); extra->num_processes = comm_size; TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); @@ -968,8 +968,8 @@ static void action_allToAllv(const char *const *action) { extra->recv_size += recvcounts[i]; extra->recvcounts[i] = recvcounts[i]; } - extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL); - extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, NULL); + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, nullptr); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2, nullptr); TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); @@ -1070,7 +1070,7 @@ void smpi_replay_run(int *argc, char***argv){ xbt_free(sendbuffer); xbt_free(recvbuffer); xbt_dict_free(&reqq); //not need, data have been freed ??? - reqq = NULL; + reqq = nullptr; } instr_extra_data extra_fin = xbt_new0(s_instr_extra_data_t,1); diff --git a/src/smpi/smpi_rma.cpp b/src/smpi/smpi_rma.cpp index d4c51f4e91..039676f095 100644 --- a/src/smpi/smpi_rma.cpp +++ b/src/smpi/smpi_rma.cpp @@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_rma, smpi, "Logging specific to SMPI (RMA o #define RMA_TAG -1234 -xbt_bar_t creation_bar = NULL; +xbt_bar_t creation_bar = nullptr; typedef struct s_smpi_mpi_win{ void* base; @@ -45,10 +45,10 @@ MPI_Win smpi_mpi_win_create( void *base, MPI_Aint size, int disp_unit, MPI_Info if(info!=MPI_INFO_NULL) info->refcount++; win->comm = comm; - win->name = NULL; + win->name = nullptr; win->opened = 0; win->group = MPI_GROUP_NULL; - win->requests = xbt_dynar_new(sizeof(MPI_Request), NULL); + win->requests = xbt_dynar_new(sizeof(MPI_Request), nullptr); win->connected_wins = xbt_new0(MPI_Win, comm_size); win->connected_wins[rank] = win; @@ -70,7 +70,7 @@ int smpi_mpi_win_free( MPI_Win* win){ xbt_barrier_wait((*win)->bar); xbt_dynar_free(&(*win)->requests); xbt_free((*win)->connected_wins); - if ((*win)->name != NULL){ + if ((*win)->name != nullptr){ xbt_free((*win)->name); } if((*win)->info!=MPI_INFO_NULL){ @@ -87,9 +87,9 @@ int smpi_mpi_win_free( MPI_Win* win){ } void smpi_mpi_win_get_name(MPI_Win win, char* name, int* length){ - if(win->name==NULL){ + if(win->name==nullptr){ *length=0; - name=NULL; + name=nullptr; return; } *length = strlen(win->name); @@ -124,7 +124,7 @@ int smpi_mpi_win_fence( int assert, MPI_Win win){ } MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqs)); - win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); + win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); @@ -264,7 +264,7 @@ int smpi_mpi_win_start(MPI_Group group, int assert, MPI_Win win){ while(j!=size){ int src=smpi_group_index(group,j); if(src!=smpi_process_index()){ - reqs[i]=smpi_irecv_init(NULL, 0, MPI_CHAR, src,RMA_TAG+4, MPI_COMM_WORLD); + reqs[i]=smpi_irecv_init(nullptr, 0, MPI_CHAR, src,RMA_TAG+4, MPI_COMM_WORLD); i++; } j++; @@ -291,7 +291,7 @@ int smpi_mpi_win_post(MPI_Group group, int assert, MPI_Win win){ while(j!=size){ int dst=smpi_group_index(group,j); if(dst!=smpi_process_index()){ - reqs[i]=smpi_mpi_send_init(NULL, 0, MPI_CHAR, dst, RMA_TAG+4, MPI_COMM_WORLD); + reqs[i]=smpi_mpi_send_init(nullptr, 0, MPI_CHAR, dst, RMA_TAG+4, MPI_COMM_WORLD); i++; } j++; @@ -322,7 +322,7 @@ int smpi_mpi_win_complete(MPI_Win win){ while(j!=size){ int dst=smpi_group_index(win->group,j); if(dst!=smpi_process_index()){ - reqs[i]=smpi_mpi_send_init(NULL, 0, MPI_CHAR, dst, RMA_TAG+5, MPI_COMM_WORLD); + reqs[i]=smpi_mpi_send_init(nullptr, 0, MPI_CHAR, dst, RMA_TAG+5, MPI_COMM_WORLD); i++; } j++; @@ -352,7 +352,7 @@ int smpi_mpi_win_complete(MPI_Win win){ } MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqqs)); - win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); + win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); smpi_group_unuse(win->group); @@ -370,7 +370,7 @@ int smpi_mpi_win_wait(MPI_Win win){ while(j!=size){ int src=smpi_group_index(win->group,j); if(src!=smpi_process_index()){ - reqs[i]=smpi_irecv_init(NULL, 0, MPI_CHAR, src,RMA_TAG+5, MPI_COMM_WORLD); + reqs[i]=smpi_irecv_init(nullptr, 0, MPI_CHAR, src,RMA_TAG+5, MPI_COMM_WORLD); i++; } j++; @@ -398,7 +398,7 @@ int smpi_mpi_win_wait(MPI_Win win){ } MPI_Request* treqs = static_cast(xbt_dynar_to_array(reqqs)); - win->requests=xbt_dynar_new(sizeof(MPI_Request), NULL); + win->requests=xbt_dynar_new(sizeof(MPI_Request), nullptr); smpi_mpi_waitall(size,treqs,MPI_STATUSES_IGNORE); xbt_free(treqs); smpi_group_unuse(win->group); diff --git a/src/smpi/smpi_topo.cpp b/src/smpi/smpi_topo.cpp index bdcd9b65f0..9ede66128d 100644 --- a/src/smpi/smpi_topo.cpp +++ b/src/smpi/smpi_topo.cpp @@ -45,7 +45,7 @@ typedef struct s_smpi_mpi_topology { } s_smpi_mpi_topology_t; void smpi_topo_destroy(MPI_Topology topo) { - if(topo == NULL) { + if(topo == nullptr) { return; } switch (topo->kind) { @@ -158,9 +158,9 @@ int smpi_mpi_cart_create(MPI_Comm comm_old, int ndims, int dims[], int periods[] int smpi_mpi_cart_sub(MPI_Comm comm, const int remain_dims[], MPI_Comm *newcomm) { MPI_Topology oldTopo = smpi_comm_topo(comm); int oldNDims = oldTopo->topo.cart->ndims; - int i, j = 0, newNDims, *newDims = NULL, *newPeriodic = NULL; + int i, j = 0, newNDims, *newDims = nullptr, *newPeriodic = nullptr; - if (remain_dims == NULL && oldNDims != 0) { + if (remain_dims == nullptr && oldNDims != 0) { return MPI_ERR_ARG; } newNDims = 0; @@ -423,7 +423,7 @@ assignnodes(int ndim, int nfactor, int *pfacts, int **pdims) /* Allocate and initialize the bins */ bins = (int *) malloc((unsigned) ndim * sizeof(int)); - if (NULL == bins) { + if (nullptr == bins) { return MPI_ERR_NO_MEM; } *pdims = bins; @@ -476,7 +476,7 @@ static int getfactors(int num, int *nfactors, int **factors) { if(num < 2) { (*nfactors) = 0; - (*factors) = NULL; + (*factors) = nullptr; return MPI_SUCCESS; } /* Allocate the array of prime factors which cannot exceed log_2(num) entries */ -- 2.20.1