From: Martin Quinson Date: Sun, 8 May 2016 19:44:43 +0000 (+0200) Subject: SIMIX_comm_get_remains() -> simgrid::simix::Comm::remains() X-Git-Tag: v3_14~1257 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4ce3fe4a9e76bb35438bd25d0f4f24bd05255840 SIMIX_comm_get_remains() -> simgrid::simix::Comm::remains() + kill that getter simcall, there is no need --- diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 85503b3709..0cfad7fddc 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -398,7 +398,6 @@ XBT_PUBLIC(int) simcall_comm_test(smx_synchro_t comm); XBT_PUBLIC(int) simcall_comm_testany(xbt_dynar_t comms); /* Getters and setters */ -XBT_PUBLIC(double) simcall_comm_get_remains(smx_synchro_t comm); XBT_PUBLIC(void *) simcall_comm_get_src_data(smx_synchro_t comm); XBT_PUBLIC(void *) simcall_comm_get_dst_data(smx_synchro_t comm); XBT_PUBLIC(smx_process_t) simcall_comm_get_src_proc(smx_synchro_t comm); diff --git a/src/msg/msg_task.cpp b/src/msg/msg_task.cpp index 783715c3aa..33a386ed0e 100644 --- a/src/msg/msg_task.cpp +++ b/src/msg/msg_task.cpp @@ -287,9 +287,8 @@ void MSG_task_set_bytes_amount(msg_task_t task, double data_size) */ double MSG_task_get_remaining_communication(msg_task_t task) { - xbt_assert((task != NULL) && (task->simdata != NULL), "Invalid parameter"); XBT_DEBUG("calling simcall_communication_get_remains(%p)", task->simdata->comm); - return simcall_comm_get_remains(task->simdata->comm); + return task->simdata->comm->remains(); } /** \ingroup m_task_management diff --git a/src/simix/SynchroComm.cpp b/src/simix/SynchroComm.cpp index 8d3b6e8081..74f8492059 100644 --- a/src/simix/SynchroComm.cpp +++ b/src/simix/SynchroComm.cpp @@ -49,3 +49,22 @@ void simgrid::simix::Comm::cancel() { surf_comm->cancel(); } } + +/** @brief get the amount remaining from the communication */ +double simgrid::simix::Comm::remains() { + switch (state) { + + case SIMIX_RUNNING: + return surf_comm->getRemains(); + break; + + case SIMIX_WAITING: + case SIMIX_READY: + return 0; /*FIXME: check what should be returned */ + break; + + default: + return 0; /*FIXME: is this correct? */ + break; + } +} diff --git a/src/simix/SynchroComm.hpp b/src/simix/SynchroComm.hpp index 2a2f6615d2..bdcc41e6a2 100644 --- a/src/simix/SynchroComm.hpp +++ b/src/simix/SynchroComm.hpp @@ -25,6 +25,7 @@ namespace simix { void suspend(); void resume(); void cancel(); + double remains(); e_smx_comm_type_t type; /* Type of the communication (SIMIX_COMM_SEND or SIMIX_COMM_RECEIVE) */ smx_mailbox_t mbox = nullptr; /* Rendez-vous where the comm is queued */ diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 883d2c7f97..f15f002165 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -888,15 +888,6 @@ int simcall_comm_test(smx_synchro_t comm) return simcall_BODY_comm_test(comm); } -/** - * \ingroup simix_comm_management - * - */ -double simcall_comm_get_remains(smx_synchro_t comm) -{ - return simcall_BODY_comm_get_remains(comm); -} - /** * \ingroup simix_comm_management * diff --git a/src/simix/popping_accessors.h b/src/simix/popping_accessors.h index e336da996c..c694b14a63 100644 --- a/src/simix/popping_accessors.h +++ b/src/simix/popping_accessors.h @@ -823,19 +823,6 @@ static inline void simcall_comm_testany__set__result(smx_simcall_t simcall, int simcall->result.i = result; } -static inline smx_synchro_t simcall_comm_get_remains__get__comm(smx_simcall_t simcall) { - return (smx_synchro_t) simcall->args[0].dp; -} -static inline void simcall_comm_get_remains__set__comm(smx_simcall_t simcall, void* arg) { - simcall->args[0].dp = arg; -} -static inline double simcall_comm_get_remains__get__result(smx_simcall_t simcall){ - return simcall->result.d; -} -static inline void simcall_comm_get_remains__set__result(smx_simcall_t simcall, double result){ - simcall->result.d = result; -} - static inline smx_synchro_t simcall_comm_get_src_data__get__comm(smx_simcall_t simcall) { return (smx_synchro_t) simcall->args[0].dp; } diff --git a/src/simix/popping_bodies.cpp b/src/simix/popping_bodies.cpp index b7d5be4088..4c1e438c3e 100644 --- a/src/simix/popping_bodies.cpp +++ b/src/simix/popping_bodies.cpp @@ -947,27 +947,6 @@ inline static int simcall_BODY_comm_testany(xbt_dynar_t comms) { return (int) self->simcall.result.i; } -inline static double simcall_BODY_comm_get_remains(smx_synchro_t comm) { - smx_process_t self = SIMIX_process_self(); - - /* Go to that function to follow the code flow through the simcall barrier */ - if (0) SIMIX_comm_get_remains(comm); - /* end of the guide intended to the poor programmer wanting to go from MSG to Surf */ - - self->simcall.call = SIMCALL_COMM_GET_REMAINS; - memset(&self->simcall.result, 0, sizeof(self->simcall.result)); - memset(self->simcall.args, 0, sizeof(self->simcall.args)); - self->simcall.args[0].dp = (void*) comm; - if (self != simix_global->maestro_process) { - XBT_DEBUG("Yield process '%s' on simcall %s (%d)", self->name, - SIMIX_simcall_name(self->simcall.call), (int)self->simcall.call); - SIMIX_process_yield(self); - } else { - SIMIX_simcall_handle(&self->simcall, 0); - } - return (double) self->simcall.result.d; - } - inline static void* simcall_BODY_comm_get_src_data(smx_synchro_t comm) { smx_process_t self = SIMIX_process_self(); diff --git a/src/simix/popping_enum.h b/src/simix/popping_enum.h index 3ad74e6647..fca277b8a1 100644 --- a/src/simix/popping_enum.h +++ b/src/simix/popping_enum.h @@ -59,7 +59,6 @@ typedef enum { SIMCALL_COMM_WAIT, SIMCALL_COMM_TEST, SIMCALL_COMM_TESTANY, - SIMCALL_COMM_GET_REMAINS, SIMCALL_COMM_GET_SRC_DATA, SIMCALL_COMM_GET_DST_DATA, SIMCALL_COMM_GET_SRC_PROC, diff --git a/src/simix/popping_generated.cpp b/src/simix/popping_generated.cpp index c5803664a6..5e9e1e09c5 100644 --- a/src/simix/popping_generated.cpp +++ b/src/simix/popping_generated.cpp @@ -64,7 +64,6 @@ const char* simcall_names[] = { "SIMCALL_COMM_WAIT", "SIMCALL_COMM_TEST", "SIMCALL_COMM_TESTANY", - "SIMCALL_COMM_GET_REMAINS", "SIMCALL_COMM_GET_SRC_DATA", "SIMCALL_COMM_GET_DST_DATA", "SIMCALL_COMM_GET_SRC_PROC", @@ -309,11 +308,6 @@ case SIMCALL_COMM_TESTANY: simcall_HANDLER_comm_testany(simcall , (xbt_dynar_t) simcall->args[0].dp); break; -case SIMCALL_COMM_GET_REMAINS: - simcall->result.d = SIMIX_comm_get_remains((smx_synchro_t) simcall->args[0].dp); - SIMIX_simcall_answer(simcall); - break; - case SIMCALL_COMM_GET_SRC_DATA: simcall->result.dp = SIMIX_comm_get_src_data((smx_synchro_t) simcall->args[0].dp); SIMIX_simcall_answer(simcall); diff --git a/src/simix/simcalls.in b/src/simix/simcalls.in index e75dd4eb23..8e2315cbf7 100644 --- a/src/simix/simcalls.in +++ b/src/simix/simcalls.in @@ -1,4 +1,4 @@ -# Copyright (c) 2014. The SimGrid Team. All rights reserved. +# Copyright (c) 2014-2016. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -92,7 +92,6 @@ Blck H comm_waitany (int) (comms, void*, xbt_dynar_t) Blck H comm_wait (void) (comm, void*, smx_synchro_t) (timeout, double) Blck H comm_test (int) (comm, void*, smx_synchro_t) Blck H comm_testany (int) (comms, void*, xbt_dynar_t) -Func - comm_get_remains (double) (comm, void*, smx_synchro_t) Func - comm_get_src_data (void*) (comm, void*, smx_synchro_t) Func - comm_get_dst_data (void*) (comm, void*, smx_synchro_t) Func - comm_get_src_proc (void*, smx_process_t) (comm, void*, smx_synchro_t) diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index ff2dd372bc..9272704bb6 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -361,7 +361,7 @@ smx_synchro_t SIMIX_comm_irecv(smx_process_t dst_proc, smx_mailbox_t mbox, void } else { simgrid::simix::Comm *other_comm = static_cast(other_synchro); - if(other_comm->surf_comm && SIMIX_comm_get_remains(other_comm)==0.0) { + if(other_comm->surf_comm && other_comm->remains()==0.0) { XBT_DEBUG("comm %p has been already sent, and is finished, destroy it",other_comm); other_comm->state = SIMIX_DONE; other_comm->type = SIMIX_COMM_DONE; @@ -814,35 +814,6 @@ void SIMIX_post_comm(smx_synchro_t synchro) /************* synchro Getters **************/ -/** - * \brief get the amount remaining from the communication - * \param synchro The communication - */ -double SIMIX_comm_get_remains(smx_synchro_t synchro) -{ - if(!synchro) - return 0; - simgrid::simix::Comm *comm = static_cast(synchro); - - double remains; - switch (synchro->state) { - - case SIMIX_RUNNING: - remains = comm->surf_comm->getRemains(); - break; - - case SIMIX_WAITING: - case SIMIX_READY: - remains = 0; /*FIXME: check what should be returned */ - break; - - default: - remains = 0; /*FIXME: is this correct? */ - break; - } - return remains; -} - /** * \brief Return the user data associated to the sender of the communication * \param synchro The communication diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index a215ff2e01..8e54a8a725 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -39,7 +39,6 @@ XBT_PRIVATE void SIMIX_comm_destroy_internal_actions(smx_synchro_t synchro); XBT_PRIVATE smx_synchro_t SIMIX_comm_iprobe(smx_process_t dst_proc, smx_mailbox_t mbox, int type, int src, int tag, int (*match_fun)(void *, void *, smx_synchro_t), void *data); XBT_PRIVATE void SIMIX_post_comm(smx_synchro_t synchro); -XBT_PRIVATE double SIMIX_comm_get_remains(smx_synchro_t synchro); XBT_PRIVATE smx_process_t SIMIX_comm_get_src_proc(smx_synchro_t synchro); XBT_PRIVATE smx_process_t SIMIX_comm_get_dst_proc(smx_synchro_t synchro);