From: Arnaud Giersch Date: Thu, 11 Jul 2019 21:34:36 +0000 (+0200) Subject: Useless casts. X-Git-Tag: v3.24~300 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/385f6d5ce3f2aff9707045601b32a66b017d7bed Useless casts. --- diff --git a/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp b/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp index a1e5f86581..27ecdda0f0 100644 --- a/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp +++ b/examples/s4u/plugin-hostload/s4u-plugin-hostload.cpp @@ -35,9 +35,8 @@ static void execute_load_test() "far: %.2E, average load as reported by the HostLoad plugin: %.5f (should be %.5f)", simgrid::s4u::Engine::get_clock() - start, host->get_speed(), speed, sg_host_get_computed_flops(host), sg_host_get_avg_load(host), - static_cast(200E6) / - (10.5 * speed * host->get_core_count() + - (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->get_speed() * host->get_core_count())); + 200E6 / (10.5 * speed * host->get_core_count() + + (simgrid::s4u::Engine::get_clock() - start - 0.5) * host->get_speed() * host->get_core_count())); // ========= Change power peak ========= int pstate = 1; diff --git a/src/bindings/java/jmsg_comm.cpp b/src/bindings/java/jmsg_comm.cpp index 2781ac319d..7de0a980b1 100644 --- a/src/bindings/java/jmsg_comm.cpp +++ b/src/bindings/java/jmsg_comm.cpp @@ -109,7 +109,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitCompletion(JNIEnv *env, job } msg_error_t status; - status = MSG_comm_wait(comm,static_cast(timeout)); + status = MSG_comm_wait(comm, timeout); env->SetBooleanField(jcomm, jcomm_field_Comm_finished, JNI_TRUE); if (status == MSG_OK) { jcomm_bind_task(env,jcomm); @@ -145,7 +145,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Comm_waitAll(JNIEnv *env, jclass cls if (not comms) return; - MSG_comm_waitall(comms, count, static_cast(timeout)); + MSG_comm_waitall(comms, count, timeout); delete[] comms; } JNIEXPORT int JNICALL Java_org_simgrid_msg_Comm_waitAny(JNIEnv *env, jclass cls, jobjectArray jcomms) diff --git a/src/bindings/java/jmsg_task.cpp b/src/bindings/java/jmsg_task.cpp index ede08bb0de..5c28035e4f 100644 --- a/src/bindings/java/jmsg_task.cpp +++ b/src/bindings/java/jmsg_task.cpp @@ -61,7 +61,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_create(JNIEnv * env, jobject jt if (jname) name = env->GetStringUTFChars(jname, 0); - msg_task_t task = MSG_task_create(name, static_cast(jflopsAmount), static_cast(jbytesAmount), jtask); + msg_task_t task = MSG_task_create(name, jflopsAmount, jbytesAmount, jtask); if (jname) env->ReleaseStringUTFChars(jname, name); @@ -73,7 +73,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_parallelCreate(JNIEnv * env, jo jobjectArray jhosts, jdoubleArray jcomputeDurations_arg, jdoubleArray jmessageSizes_arg) { - int host_count = static_cast(env->GetArrayLength(jhosts)); + int host_count = env->GetArrayLength(jhosts); jdouble* jcomputeDurations = env->GetDoubleArrayElements(jcomputeDurations_arg, 0); msg_host_t* hosts = new msg_host_t[host_count]; @@ -234,7 +234,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setPriority(JNIEnv * env, jobje jxbt_throw_notbound(env, "task", jtask); return; } - MSG_task_set_priority(task, static_cast(priority)); + MSG_task_set_priority(task, priority); } JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jobject jtask, jdouble computationAmount) @@ -245,7 +245,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setFlopsAmount (JNIEnv *env, jo jxbt_throw_notbound(env, "task", jtask); return; } - MSG_task_set_flops_amount(task, static_cast(computationAmount)); + MSG_task_set_flops_amount(task, computationAmount); } JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jobject jtask, jdouble dataSize) @@ -257,7 +257,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_setBytesAmount (JNIEnv *env, jo return; } env->SetDoubleField(jtask, jtask_field_Task_messageSize, dataSize); - MSG_task_set_bytes_amount(task, static_cast(dataSize)); + MSG_task_set_bytes_amount(task, dataSize); } JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobject jtask, jstring jalias, @@ -273,8 +273,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask)); const char* alias = env->GetStringUTFChars(jalias, 0); - msg_error_t res = - MSG_task_send_with_timeout_bounded(task, alias, static_cast(jtimeout), static_cast(maxrate)); + msg_error_t res = MSG_task_send_with_timeout_bounded(task, alias, jtimeout, maxrate); env->ReleaseStringUTFChars(jalias, alias); if (res != MSG_OK) @@ -340,8 +339,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_receiveBounded(JNIEnv* env, msg_task_t task = nullptr; const char *alias = env->GetStringUTFChars(jalias, 0); - msg_error_t res = MSG_task_receive_ext_bounded(&task, alias, static_cast(jtimeout), /*host*/ nullptr, - static_cast(rate)); + msg_error_t res = MSG_task_receive_ext_bounded(&task, alias, jtimeout, /*host*/ nullptr, rate); if (env->ExceptionOccurred()) return nullptr; if (res != MSG_OK) { @@ -377,7 +375,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_irecvBounded(JNIEnv * env, j } const char* mailbox = env->GetStringUTFChars(jmailbox, 0); - msg_comm_t comm = MSG_task_irecv_bounded(task, mailbox, static_cast(rate)); + msg_comm_t comm = MSG_task_irecv_bounded(task, mailbox, rate); env->ReleaseStringUTFChars(jmailbox, mailbox); env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm)); @@ -517,7 +515,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsendBounded(JNIEnv * env, jobj /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */ MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask)); - MSG_task_dsend_bounded(task, alias, msg_task_cancel_on_failed_dsend,static_cast(maxrate)); + MSG_task_dsend_bounded(task, alias, msg_task_cancel_on_failed_dsend, maxrate); env->ReleaseStringUTFChars(jalias, alias); } diff --git a/src/plugins/host_dvfs.cpp b/src/plugins/host_dvfs.cpp index d94c836dda..02905091f7 100644 --- a/src/plugins/host_dvfs.cpp +++ b/src/plugins/host_dvfs.cpp @@ -336,9 +336,8 @@ public: { double computed_flops = sg_host_get_computed_flops(get_host()) - comp_counter; double target_time = (simgrid::s4u::Engine::get_clock() - start_time); - target_time = - target_time * - static_cast(99.0 / 100.0); // FIXME We account for t_copy arbitrarily with 1% -- this needs to be fixed + target_time = target_time * 99.0 / 100.0; // FIXME We account for t_copy arbitrarily with 1% + // -- this needs to be fixed bool is_initialized = rates[task_id][best_pstate] != 0; rates[task_id][best_pstate] = computed_flops / comp_timer; diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index fb960ad4ca..d85f0139f8 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -311,7 +311,7 @@ double HostEnergy::get_current_watts_value(double cpu_load) * (maxCpuLoad is by definition 1) */ int coreCount = host_->get_core_count(); - double coreReciprocal = static_cast(1) / static_cast(coreCount); + double coreReciprocal = 1.0 / coreCount; if (coreCount > 1) power_slope = (max_power - min_power) / (1 - coreReciprocal); else diff --git a/src/plugins/host_load.cpp b/src/plugins/host_load.cpp index 45b89e76fd..f3f7e3c3d8 100644 --- a/src/plugins/host_load.cpp +++ b/src/plugins/host_load.cpp @@ -145,7 +145,7 @@ void HostLoad::update() double HostLoad::get_current_load() { // We don't need to call update() here because it is called every time an action terminates or starts - return current_flops_ / static_cast(host_->get_speed() * host_->get_core_count()); + return current_flops_ / (host_->get_speed() * host_->get_core_count()); } /* diff --git a/src/smpi/bindings/smpi_pmpi_file.cpp b/src/smpi/bindings/smpi_pmpi_file.cpp index df39eaeaff..068bbbf1d6 100644 --- a/src/smpi/bindings/smpi_pmpi_file.cpp +++ b/src/smpi/bindings/smpi_pmpi_file.cpp @@ -97,7 +97,7 @@ int PMPI_File_read(MPI_File fh, void *buf, int count,MPI_Datatype datatype, MPI_ PASS_ZEROCOUNT(count) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", count * datatype->size())); int ret = simgrid::smpi::File::read(fh, buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -114,7 +114,8 @@ int PMPI_File_read_shared(MPI_File fh, void *buf, int count,MPI_Datatype datatyp PASS_ZEROCOUNT(count) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_shared", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - read_shared", count * datatype->size())); int ret = simgrid::smpi::File::read_shared(fh, buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -132,7 +133,7 @@ int PMPI_File_write(MPI_File fh, const void *buf, int count,MPI_Datatype datatyp PASS_ZEROCOUNT(count) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", count * datatype->size())); int ret = simgrid::smpi::File::write(fh, const_cast(buf), count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -150,7 +151,8 @@ int PMPI_File_write_shared(MPI_File fh, const void *buf, int count,MPI_Datatype PASS_ZEROCOUNT(count) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_shared", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - write_shared", count * datatype->size())); int ret = simgrid::smpi::File::write_shared(fh, buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -166,7 +168,7 @@ int PMPI_File_read_all(MPI_File fh, void *buf, int count,MPI_Datatype datatype, CHECK_FLAGS(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_all", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_all", count * datatype->size())); int ret = fh->op_all(buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -182,7 +184,8 @@ int PMPI_File_read_ordered(MPI_File fh, void *buf, int count,MPI_Datatype dataty CHECK_FLAGS(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_ordered", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - read_ordered", count * datatype->size())); int ret = simgrid::smpi::File::read_ordered(fh, buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -199,7 +202,7 @@ int PMPI_File_write_all(MPI_File fh, const void *buf, int count,MPI_Datatype dat CHECK_RDONLY(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_all", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_all", count * datatype->size())); int ret = fh->op_all(const_cast(buf), count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -216,7 +219,8 @@ int PMPI_File_write_ordered(MPI_File fh, const void *buf, int count,MPI_Datatype CHECK_RDONLY(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_ordered", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - write_ordered", count * datatype->size())); int ret = simgrid::smpi::File::write_ordered(fh, buf, count, datatype, status); TRACE_smpi_comm_out(rank_traced); smpi_bench_begin(); @@ -234,7 +238,7 @@ int PMPI_File_read_at(MPI_File fh, MPI_Offset offset, void *buf, int count,MPI_D PASS_ZEROCOUNT(count); smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read", count * datatype->size())); int ret = fh->seek(offset,MPI_SEEK_SET); if(ret!=MPI_SUCCESS) return ret; @@ -254,7 +258,8 @@ int PMPI_File_read_at_all(MPI_File fh, MPI_Offset offset, void *buf, int count,M CHECK_FLAGS(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - read_at_all", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - read_at_all", count * datatype->size())); int ret = fh->seek(offset,MPI_SEEK_SET); if(ret!=MPI_SUCCESS) return ret; @@ -276,7 +281,7 @@ int PMPI_File_write_at(MPI_File fh, MPI_Offset offset, const void *buf, int coun PASS_ZEROCOUNT(count); smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write", count * datatype->size())); int ret = fh->seek(offset,MPI_SEEK_SET); if(ret!=MPI_SUCCESS) return ret; @@ -297,7 +302,8 @@ int PMPI_File_write_at_all(MPI_File fh, MPI_Offset offset, const void *buf, int CHECK_RDONLY(fh) smpi_bench_end(); int rank_traced = simgrid::s4u::this_actor::get_pid(); - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("IO - write_at_all", static_cast(count*datatype->size()))); + TRACE_smpi_comm_in(rank_traced, __func__, + new simgrid::instr::CpuTIData("IO - write_at_all", count * datatype->size())); int ret = fh->seek(offset,MPI_SEEK_SET); if(ret!=MPI_SUCCESS) return ret; diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 0c1f5b4073..d89bddec70 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -702,7 +702,7 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta } int rank_traced = simgrid::s4u::this_actor::get_pid(); // FIXME: In PMPI_Wait, we check if the comm is null? - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("waitAny", static_cast(count))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("waitAny", count)); *index = simgrid::smpi::Request::waitany(count, requests, status); @@ -733,7 +733,7 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]) } int rank_traced = simgrid::s4u::this_actor::get_pid(); // FIXME: In PMPI_Wait, we check if the comm is null? - TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("waitall", static_cast(count))); + TRACE_smpi_comm_in(rank_traced, __func__, new simgrid::instr::CpuTIData("waitall", count)); int retval = simgrid::smpi::Request::waitall(count, requests, status); diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index a10ac85fc9..efecf03056 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -188,14 +188,14 @@ unsigned int smpi_sleep(unsigned int secs) { if (not smpi_process()) return sleep(secs); - return private_sleep(static_cast(secs)); + return private_sleep(secs); } int smpi_usleep(useconds_t usecs) { if (not smpi_process()) return usleep(usecs); - return static_cast(private_sleep(static_cast(usecs) / 1000000.0)); + return static_cast(private_sleep(usecs / 1000000.0)); } #if _POSIX_TIMERS > 0 @@ -203,7 +203,7 @@ int smpi_nanosleep(const struct timespec* tp, struct timespec* t) { if (not smpi_process()) return nanosleep(tp,t); - return static_cast(private_sleep(static_cast(tp->tv_sec + tp->tv_nsec / 1000000000.0))); + return static_cast(private_sleep(tp->tv_sec + tp->tv_nsec / 1000000000.0)); } #endif @@ -416,7 +416,7 @@ void smpi_sample_3(int global, const char *file, int line) double period = xbt_os_timer_elapsed(smpi_process()->timer()); data.sum += period; data.sum_pow2 += period * period; - double n = static_cast(data.count); + double n = data.count; data.mean = data.sum / n; data.relstderr = sqrt((data.sum_pow2 / n - data.mean * data.mean) / n) / data.mean; diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 66cc73017b..1e62ea1cf4 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -113,7 +113,7 @@ NetworkIBModel::NetworkIBModel() : NetworkSmpiModel() void NetworkIBModel::computeIBfactors(IBNode* root) { - double num_comm_out = static_cast(root->ActiveCommsUp.size()); + double num_comm_out = root->ActiveCommsUp.size(); double max_penalty_out = 0.0; // first, compute all outbound penalties to get their max for (std::vector::iterator it = root->ActiveCommsUp.begin(); it != root->ActiveCommsUp.end(); ++it) { diff --git a/teshsuite/s4u/storage_client_server/storage_client_server.cpp b/teshsuite/s4u/storage_client_server/storage_client_server.cpp index f5fb17f9ad..8beb1e2ba3 100644 --- a/teshsuite/s4u/storage_client_server/storage_client_server.cpp +++ b/teshsuite/s4u/storage_client_server/storage_client_server.cpp @@ -53,7 +53,7 @@ static void hsm_put(const std::string& remote_host, const std::string& src, cons XBT_INFO("%s sends %llu to %s", simgrid::s4u::this_actor::get_cname(), read_size, remote_host.c_str()); std::string* payload = new std::string(simgrid::xbt::string_printf("%s %llu", dest.c_str(), read_size)); simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(remote_host); - mailbox->put(payload, static_cast(read_size)); + mailbox->put(payload, read_size); simgrid::s4u::this_actor::sleep_for(.4); }