From: Martin Quinson Date: Mon, 3 Jul 2017 23:58:04 +0000 (+0200) Subject: finish removing simix.h from C files, and avoid the use of Ptr when not needed X-Git-Tag: v3_17~487 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/041733d27687138580274a397bb287da01c48b4c finish removing simix.h from C files, and avoid the use of Ptr when not needed --- diff --git a/examples/msg/actions-comm/actions-comm.c b/examples/msg/actions-comm/actions-comm.c index 20b499059f..2c487dbede 100644 --- a/examples/msg/actions-comm/actions-comm.c +++ b/examples/msg/actions-comm/actions-comm.c @@ -1,10 +1,9 @@ -/* Copyright (c) 2009-2016. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/msg.h" -#include "simgrid/simix.h" /* semaphores for the barrier */ +#include #include XBT_LOG_NEW_DEFAULT_CATEGORY(actions, "Messages specific for this msg example"); diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 3776800807..8545b57a45 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -1,11 +1,10 @@ -/* Copyright (c) 2004-2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2004-2017. 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. */ -#ifndef SG_PLATF_TYPES_H -#define SG_PLATF_TYPES_H +#ifndef SIMGRID_TYPES_H +#define SIMGRID_TYPES_H #ifdef __cplusplus @@ -15,6 +14,10 @@ namespace simgrid { namespace kernel { +namespace context { +class Context; +class ContextFactory; +} namespace activity { class ActivityImpl; using ActivityImplPtr = boost::intrusive_ptr; @@ -31,7 +34,10 @@ namespace activity { using RawImplPtr = boost::intrusive_ptr; class SleepImpl; using SleepImplPtr = boost::intrusive_ptr; + + class MailboxImpl; } + namespace routing { class NetPoint; } @@ -40,6 +46,8 @@ namespace simix { class ActorImpl; using ActorImplPtr = boost::intrusive_ptr; class Host; + + class MutexImpl; } namespace surf { class Resource; @@ -66,6 +74,11 @@ typedef simgrid::kernel::routing::NetPoint routing_NetPoint; typedef simgrid::surf::Resource surf_Resource; typedef simgrid::trace_mgr::trace tmgr_Trace; +typedef simgrid::kernel::context::Context* smx_context_t; +typedef simgrid::simix::ActorImpl* smx_actor_t; +typedef simgrid::simix::MutexImpl* smx_mutex_t; +typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; + #else typedef struct s4u_Actor s4u_Actor; @@ -79,6 +92,11 @@ typedef struct routing_NetPoint routing_NetPoint; typedef struct surf_Resource surf_Resource; typedef struct Trace tmgr_Trace; +typedef struct s_smx_context* smx_context_t; +typedef struct s_smx_actor* smx_actor_t; +typedef struct s_smx_mutex* smx_mutex_t; +typedef struct s_smx_mailbox* smx_mailbox_t; + #endif typedef s4u_NetZone* sg_netzone_t; @@ -127,4 +145,4 @@ typedef long long sg_offset_t; typedef unsigned long aid_t; -#endif +#endif /* SIMGRID_TYPES_H */ diff --git a/include/simgrid/msg.h b/include/simgrid/msg.h index 057b20cbca..00ea2fb19e 100644 --- a/include/simgrid/msg.h +++ b/include/simgrid/msg.h @@ -7,10 +7,16 @@ #ifndef MSG_H #define MSG_H +#include "simgrid/datatypes.h" #include "simgrid/forward.h" -#include "simgrid/simix.h" +#include "simgrid/host.h" + +#include "xbt/base.h" +#include "xbt/dict.h" +#include "xbt/dynar.h" #ifdef __cplusplus +#include "simgrid/simix.h" namespace simgrid { namespace msg { class Comm; @@ -386,8 +392,9 @@ XBT_PUBLIC(msg_error_t) MSG_task_receive_bounded(msg_task_t * task, const char * XBT_PUBLIC(msg_comm_t) MSG_task_isend(msg_task_t task, const char *alias); XBT_PUBLIC(msg_comm_t) MSG_task_isend_bounded(msg_task_t task, const char *alias, double maxrate); -XBT_PUBLIC(msg_comm_t) MSG_task_isend_with_matching(msg_task_t task, const char *alias, - int (*match_fun)(void*,void*, smx_activity_t), void *match_data); +XBT_PUBLIC(msg_comm_t) +MSG_task_isend_with_matching(msg_task_t task, const char* alias, int (*match_fun)(void*, void*, void*), + void* match_data); XBT_PUBLIC(void) MSG_task_dsend(msg_task_t task, const char *alias, void_f_pvoid_t cleanup); XBT_PUBLIC(void) MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate); diff --git a/include/simgrid/s4u/Comm.hpp b/include/simgrid/s4u/Comm.hpp index 4adecc0ac0..d409c0b073 100644 --- a/include/simgrid/s4u/Comm.hpp +++ b/include/simgrid/s4u/Comm.hpp @@ -104,7 +104,7 @@ private: /* FIXME: expose these elements in the API */ int detached_ = 0; - int (*matchFunction_)(void*, void*, smx_activity_t) = nullptr; + int (*matchFunction_)(void*, void*, simgrid::kernel::activity::CommImpl*) = nullptr; void (*cleanFunction_)(void*) = nullptr; void (*copyDataFunction_)(smx_activity_t, void*, size_t) = nullptr; diff --git a/include/simgrid/simix.h b/include/simgrid/simix.h index 152fcccbb4..45d1ab2867 100644 --- a/include/simgrid/simix.h +++ b/include/simgrid/simix.h @@ -11,38 +11,6 @@ #include "xbt/ex.h" #include "xbt/parmap.h" -#ifdef __cplusplus - -namespace simgrid { -namespace kernel { -namespace context { - class Context; - class ContextFactory; - } - namespace activity { - class MailboxImpl; - } - } - - namespace simix { - - class MutexImpl; -} -} - -typedef simgrid::kernel::context::Context* smx_context_t; -typedef simgrid::simix::ActorImpl* smx_actor_t; -typedef simgrid::simix::MutexImpl* smx_mutex_t; -typedef simgrid::kernel::activity::MailboxImpl* smx_mailbox_t; - -#else - -typedef struct s_smx_context *smx_context_t; -typedef struct s_smx_actor *smx_actor_t; -typedef struct s_smx_mutex *smx_mutex_t; -typedef struct s_smx_mailbox *smx_mailbox_t; - -#endif /* ******************************** Host ************************************ */ /** @brief Host datatype @@ -269,36 +237,30 @@ SG_END_DECL() /************************** Comunication simcalls *****************************/ -XBT_PUBLIC(void) simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, - double rate, void *src_buff, - size_t src_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double timeout); - -XBT_PUBLIC(smx_activity_t) simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, - double task_size, - double rate, void *src_buff, - size_t src_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*clean_fun)(void *), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, int detached); - -XBT_PUBLIC(void) simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, - size_t * dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double timeout, double rate); - -XBT_PUBLIC(smx_activity_t) simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, - size_t * dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double rate); - -XBT_PUBLIC(smx_activity_t) simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, - int (*match_fun)(void *, void *, smx_activity_t), void *data); +XBT_PUBLIC(void) +simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, + size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double timeout); + +XBT_PUBLIC(smx_activity_t) +simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, + size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*clean_fun)(void*), void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, + int detached); + +XBT_PUBLIC(void) +simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double timeout, double rate); + +XBT_PUBLIC(smx_activity_t) +simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double rate); + +XBT_PUBLIC(smx_activity_t) +simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data); XBT_PUBLIC(void) simcall_comm_cancel(smx_activity_t comm); /* FIXME: waitany is going to be a vararg function, and should take a timeout */ diff --git a/src/include/mc/mc.h b/src/include/mc/mc.h index 0834db9516..23f056f48e 100644 --- a/src/include/mc/mc.h +++ b/src/include/mc/mc.h @@ -6,8 +6,8 @@ #ifndef MC_MC_H #define MC_MC_H +#include #include /* our public interface (and definition of SIMGRID_HAVE_MC) */ -#include /* Maximum size of the application heap. * diff --git a/src/kernel/activity/CommImpl.hpp b/src/kernel/activity/CommImpl.hpp index bbf350c10e..fb60e05189 100644 --- a/src/kernel/activity/CommImpl.hpp +++ b/src/kernel/activity/CommImpl.hpp @@ -39,9 +39,10 @@ public: bool detached = false; /* If detached or not */ void (*clean_fun)(void*) = nullptr; /* Function to clean the detached src_buf if something goes wrong */ - int (*match_fun)(void*, void*, smx_activity_t) = nullptr; /* Filter function used by the other side. It is used when - looking if a given communication matches my needs. For that, myself must match the - expectations of the other side, too. See */ + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*) = + nullptr; /* Filter function used by the other side. It is used when +looking if a given communication matches my needs. For that, myself must match the +expectations of the other side, too. See */ void (*copy_data_fun)(smx_activity_t, void*, size_t) = nullptr; /* Surf action data */ diff --git a/src/msg/msg_gos.cpp b/src/msg/msg_gos.cpp index d0127d7961..bb023aae53 100644 --- a/src/msg/msg_gos.cpp +++ b/src/msg/msg_gos.cpp @@ -297,9 +297,9 @@ msg_error_t MSG_task_receive_ext_bounded(msg_task_t * task, const char *alias, d } /* Internal function used to factorize code between MSG_task_isend_with_matching() and MSG_task_dsend(). */ -static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias, - int (*match_fun)(void*,void*, smx_activity_t), - void *match_data, void_f_pvoid_t cleanup, int detached) +static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char* alias, + int (*match_fun)(void*, void*, void*), void* match_data, + void_f_pvoid_t cleanup, int detached) { simdata_task_t t_simdata = nullptr; msg_process_t myself = MSG_process_self(); @@ -315,8 +315,9 @@ static inline msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *al msg_global->sent_msg++; /* Send it by calling SIMIX network layer */ - smx_activity_t act = simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, - task, sizeof(void *), match_fun, cleanup, nullptr, match_data,detached); + smx_activity_t act = + simcall_comm_isend(myself->getImpl(), mailbox->getImpl(), t_simdata->bytes_amount, t_simdata->rate, task, + sizeof(void*), (simix_match_func_t)match_fun, cleanup, nullptr, match_data, detached); t_simdata->comm = boost::static_pointer_cast(act); msg_comm_t comm = nullptr; @@ -377,8 +378,8 @@ msg_comm_t MSG_task_isend_bounded(msg_task_t task, const char *alias, double max * \param match_data user provided data passed to match_fun * \return the msg_comm_t communication created */ -msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias, - int (*match_fun)(void*, void*, smx_activity_t), void *match_data) +msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char* alias, int (*match_fun)(void*, void*, void*), + void* match_data) { return MSG_task_isend_internal(task, alias, match_fun, match_data, nullptr, 0); } diff --git a/src/simix/libsmx.cpp b/src/simix/libsmx.cpp index 96cd223368..cbb5bbb2e7 100644 --- a/src/simix/libsmx.cpp +++ b/src/simix/libsmx.cpp @@ -355,11 +355,9 @@ e_smx_state_t simcall_process_sleep(double duration) /** * \ingroup simix_comm_management */ -void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, - void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), void *data, - double timeout) +void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, + size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double timeout) { /* checking for infinite values */ xbt_assert(std::isfinite(task_size), "task_size is not finite!"); @@ -385,13 +383,11 @@ void simcall_comm_send(smx_actor_t sender, smx_mailbox_t mbox, double task_size, /** * \ingroup simix_comm_management */ -smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, - void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*clean_fun)(void *), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, - int detached) +smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, + size_t src_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*clean_fun)(void*), void (*copy_data_fun)(smx_activity_t, void*, size_t), + void* data, int detached) { /* checking for infinite values */ xbt_assert(std::isfinite(task_size), "task_size is not finite!"); @@ -407,10 +403,9 @@ smx_activity_t simcall_comm_isend(smx_actor_t sender, smx_mailbox_t mbox, double /** * \ingroup simix_comm_management */ -void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t * dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double timeout, double rate) +void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double timeout, double rate) { xbt_assert(std::isfinite(timeout), "timeout is not finite!"); xbt_assert(mbox, "No rendez-vous point defined for recv"); @@ -431,10 +426,9 @@ void simcall_comm_recv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, /** * \ingroup simix_comm_management */ -smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double rate) +smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, double rate) { xbt_assert(mbox, "No rendez-vous point defined for irecv"); @@ -446,7 +440,7 @@ smx_activity_t simcall_comm_irecv(smx_actor_t receiver, smx_mailbox_t mbox, void * \ingroup simix_comm_management */ smx_activity_t simcall_comm_iprobe(smx_mailbox_t mbox, int type, int src, int tag, - int (*match_fun)(void *, void *, smx_activity_t), void *data) + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* data) { xbt_assert(mbox, "No rendez-vous point defined for iprobe"); diff --git a/src/simix/popping_private.h b/src/simix/popping_private.h index 698a3a52b1..160e55efc4 100644 --- a/src/simix/popping_private.h +++ b/src/simix/popping_private.h @@ -22,7 +22,7 @@ XBT_PUBLIC_DATA(const char*) simcall_names[]; /* Name of each simcall */ #include "popping_enum.h" /* Definition of e_smx_simcall_t, with one value per simcall */ -typedef int (*simix_match_func_t)(void *, void *, smx_activity_t); +typedef int (*simix_match_func_t)(void*, void*, simgrid::kernel::activity::CommImpl*); typedef void (*simix_copy_data_func_t)(smx_activity_t, void*, size_t); typedef void (*simix_clean_func_t)(void *); typedef void (*FPtr)(void); // Hide the ugliness diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index d4a4781530..2dcabbc1de 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -35,8 +35,8 @@ static void SIMIX_comm_start(simgrid::kernel::activity::CommImplPtr synchro); */ static simgrid::kernel::activity::CommImplPtr _find_matching_comm(boost::circular_buffer_space_optimized* deque, e_smx_comm_type_t type, - int (*match_fun)(void*, void*, smx_activity_t), void* this_user_data, smx_activity_t my_synchro, - bool remove_matching) + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), void* this_user_data, + simgrid::kernel::activity::CommImplPtr my_synchro, bool remove_matching) { void* other_user_data = nullptr; @@ -49,8 +49,8 @@ _find_matching_comm(boost::circular_buffer_space_optimized* dequ } else if (comm->type == SIMIX_COMM_RECEIVE) { other_user_data = comm->dst_data; } - if (comm->type == type && (match_fun == nullptr || match_fun(this_user_data, other_user_data, comm)) && - (not comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro))) { + if (comm->type == type && (match_fun == nullptr || match_fun(this_user_data, other_user_data, comm.get())) && + (not comm->match_fun || comm->match_fun(other_user_data, this_user_data, my_synchro.get()))) { XBT_DEBUG("Found a matching communication synchro %p", comm.get()); if (remove_matching) deque->erase(it); @@ -71,25 +71,24 @@ _find_matching_comm(boost::circular_buffer_space_optimized* dequ /******************************************************************************/ /* Communication synchros */ /******************************************************************************/ -XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, - double task_size, double rate, - void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *,smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double timeout){ +XBT_PRIVATE void simcall_HANDLER_comm_send(smx_simcall_t simcall, smx_actor_t src, smx_mailbox_t mbox, double task_size, + double rate, void* src_buff, size_t src_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, + double timeout) +{ smx_activity_t comm = simcall_HANDLER_comm_isend(simcall, src, mbox, task_size, rate, src_buff, src_buff_size, match_fun, nullptr, copy_data_fun, data, 0); SIMCALL_SET_MC_VALUE(simcall, 0); simcall_HANDLER_comm_wait(simcall, comm, timeout); } -XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx_actor_t src_proc, smx_mailbox_t mbox, - double task_size, double rate, - void *src_buff, size_t src_buff_size, - int (*match_fun)(void *, void *,smx_activity_t), - void (*clean_fun)(void *), // used to free the synchro in case of problem after a detached send - void (*copy_data_fun)(smx_activity_t, void*, size_t),// used to copy data if not default one - void *data, int detached) +XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend( + smx_simcall_t simcall, smx_actor_t src_proc, smx_mailbox_t mbox, double task_size, double rate, void* src_buff, + size_t src_buff_size, int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*clean_fun)(void*), // used to free the synchro in case of problem after a detached send + void (*copy_data_fun)(smx_activity_t, void*, size_t), // used to copy data if not default one + void* data, int detached) { XBT_DEBUG("send from mailbox %p", mbox); @@ -154,10 +153,10 @@ XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_isend(smx_simcall_t simcall, smx } XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, - void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double timeout, double rate) + void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, + double timeout, double rate) { smx_activity_t comm = SIMIX_comm_irecv(receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); SIMCALL_SET_MC_VALUE(simcall, 0); @@ -165,18 +164,19 @@ XBT_PRIVATE void simcall_HANDLER_comm_recv(smx_simcall_t simcall, smx_actor_t re } XBT_PRIVATE smx_activity_t simcall_HANDLER_comm_irecv(smx_simcall_t simcall, smx_actor_t receiver, smx_mailbox_t mbox, - void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double rate) + void* dst_buff, size_t* dst_buff_size, + simix_match_func_t match_fun, + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, + double rate) { return SIMIX_comm_irecv(receiver, mbox, dst_buff, dst_buff_size, match_fun, copy_data_fun, data, rate); } -smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), // used to copy data if not default one - void *data, double rate) +smx_activity_t +SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void* dst_buff, size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), // used to copy data if not default one + void* data, double rate) { simgrid::kernel::activity::CommImplPtr this_synchro = simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl(SIMIX_COMM_RECEIVE)); @@ -247,15 +247,14 @@ smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void * return other_comm; } -smx_activity_t simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t mbox, - int type, int src, int tag, - int (*match_fun)(void *, void *, smx_activity_t), - void *data){ +smx_activity_t simcall_HANDLER_comm_iprobe(smx_simcall_t simcall, smx_mailbox_t mbox, int type, int src, int tag, + simix_match_func_t match_fun, void* data) +{ return SIMIX_comm_iprobe(simcall->issuer, mbox, type, src, tag, match_fun, data); } -smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int type, int src, - int tag, int (*match_fun)(void *, void *, smx_activity_t), void *data) +smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int type, int src, int tag, + simix_match_func_t match_fun, void* data) { XBT_DEBUG("iprobe from %p %p", mbox, &mbox->comm_queue); simgrid::kernel::activity::CommImplPtr this_comm; diff --git a/src/simix/smx_network_private.h b/src/simix/smx_network_private.h index c3a0c3444a..80924c330e 100644 --- a/src/simix/smx_network_private.h +++ b/src/simix/smx_network_private.h @@ -10,12 +10,12 @@ #include "src/kernel/activity/MailboxImpl.hpp" #include "src/simix/ActorImpl.hpp" -XBT_PRIVATE smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, - void *dst_buff, size_t *dst_buff_size, - int (*match_fun)(void *, void *, smx_activity_t), - void (*copy_data_fun)(smx_activity_t, void*, size_t), - void *data, double rate); -XBT_PRIVATE smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int type, int src, - int tag, int (*match_fun)(void *, void *, smx_activity_t), void *data); +XBT_PRIVATE smx_activity_t SIMIX_comm_irecv(smx_actor_t dst_proc, smx_mailbox_t mbox, void* dst_buff, + size_t* dst_buff_size, + int (*match_fun)(void*, void*, simgrid::kernel::activity::CommImpl*), + void (*copy_data_fun)(smx_activity_t, void*, size_t), void* data, + double rate); +XBT_PRIVATE smx_activity_t SIMIX_comm_iprobe(smx_actor_t dst_proc, smx_mailbox_t mbox, int type, int src, int tag, + simix_match_func_t match_fun, void* data); #endif diff --git a/src/smpi/smpi_request.cpp b/src/smpi/smpi_request.cpp index 3547243007..7080784645 100644 --- a/src/smpi/smpi_request.cpp +++ b/src/smpi/smpi_request.cpp @@ -117,7 +117,8 @@ void Request::unref(MPI_Request* request) } } -int Request::match_recv(void* a, void* b, smx_activity_t ignored) { +int Request::match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored) +{ MPI_Request ref = static_cast(a); MPI_Request req = static_cast(b); XBT_DEBUG("Trying to match a recv of src %d against %d, tag %d against %d",ref->src_,req->src_, ref->tag_, req->tag_); @@ -140,7 +141,8 @@ int Request::match_recv(void* a, void* b, smx_activity_t ignored) { }else return 0; } -int Request::match_send(void* a, void* b,smx_activity_t ignored) { +int Request::match_send(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored) +{ MPI_Request ref = static_cast(a); MPI_Request req = static_cast(b); XBT_DEBUG("Trying to match a send of src %d against %d, tag %d against %d",ref->src_,req->src_, ref->tag_, req->tag_); diff --git a/src/smpi/smpi_request.hpp b/src/smpi/smpi_request.hpp index 96d1cf8a9a..535ebab307 100644 --- a/src/smpi/smpi_request.hpp +++ b/src/smpi/smpi_request.hpp @@ -88,8 +88,8 @@ class Request : public F2C { static int waitall(int count, MPI_Request requests[], MPI_Status status[]); static int waitsome(int incount, MPI_Request requests[], int *indices, MPI_Status status[]); - static int match_send(void* a, void* b,smx_activity_t ignored); - static int match_recv(void* a, void* b,smx_activity_t ignored); + static int match_send(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored); + static int match_recv(void* a, void* b, simgrid::kernel::activity::CommImpl* ignored); int add_f(); static void free_f(int id); diff --git a/src/xbt/xbt_os_synchro.c b/src/xbt/xbt_os_synchro.cpp similarity index 65% rename from src/xbt/xbt_os_synchro.c rename to src/xbt/xbt_os_synchro.cpp index 1a7adda2fb..748faa20c7 100644 --- a/src/xbt/xbt_os_synchro.c +++ b/src/xbt/xbt_os_synchro.cpp @@ -9,63 +9,63 @@ #include "xbt/ex.h" #include "xbt/synchro.h" -#include "simgrid/simix.h" /* used implementation */ +#include "simgrid/simix.h" /* used implementation */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_sync, xbt, "Synchronization mechanism"); /****** mutex related functions ******/ xbt_mutex_t xbt_mutex_init(void) { - return (xbt_mutex_t) simcall_mutex_init(); + return (xbt_mutex_t)simcall_mutex_init(); } void xbt_mutex_acquire(xbt_mutex_t mutex) { - simcall_mutex_lock((smx_mutex_t) mutex); + simcall_mutex_lock((smx_mutex_t)mutex); } int xbt_mutex_try_acquire(xbt_mutex_t mutex) { - return simcall_mutex_trylock((smx_mutex_t) mutex); + return simcall_mutex_trylock((smx_mutex_t)mutex); } void xbt_mutex_release(xbt_mutex_t mutex) { - simcall_mutex_unlock((smx_mutex_t) mutex); + simcall_mutex_unlock((smx_mutex_t)mutex); } void xbt_mutex_destroy(xbt_mutex_t mutex) { - SIMIX_mutex_unref((smx_mutex_t) mutex); + SIMIX_mutex_unref((smx_mutex_t)mutex); } /***** condition related functions *****/ xbt_cond_t xbt_cond_init(void) { - return (xbt_cond_t) simcall_cond_init(); + return (xbt_cond_t)simcall_cond_init(); } void xbt_cond_wait(xbt_cond_t cond, xbt_mutex_t mutex) { - simcall_cond_wait((smx_cond_t) cond, (smx_mutex_t) mutex); + simcall_cond_wait((smx_cond_t)cond, (smx_mutex_t)mutex); } void xbt_cond_timedwait(xbt_cond_t cond, xbt_mutex_t mutex, double delay) { - simcall_cond_wait_timeout((smx_cond_t) cond, (smx_mutex_t) mutex, delay); + simcall_cond_wait_timeout((smx_cond_t)cond, (smx_mutex_t)mutex, delay); } void xbt_cond_signal(xbt_cond_t cond) { - simcall_cond_signal((smx_cond_t) cond); + simcall_cond_signal((smx_cond_t)cond); } void xbt_cond_broadcast(xbt_cond_t cond) { - simcall_cond_broadcast((smx_cond_t) cond); + simcall_cond_broadcast((smx_cond_t)cond); } void xbt_cond_destroy(xbt_cond_t cond) { - SIMIX_cond_unref((smx_cond_t) cond); + SIMIX_cond_unref((smx_cond_t)cond); } diff --git a/teshsuite/simix/CMakeLists.txt b/teshsuite/simix/CMakeLists.txt index 0149d4f201..c4669759b6 100644 --- a/teshsuite/simix/CMakeLists.txt +++ b/teshsuite/simix/CMakeLists.txt @@ -1,12 +1,4 @@ -foreach(x check_defaults stack_overflow) - add_executable (${x} ${x}/${x}.c) - target_link_libraries(${x} simgrid) - set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) - - set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c) -endforeach() - -foreach(x generic_simcalls) +foreach(x check_defaults generic_simcalls stack_overflow) add_executable (${x} ${x}/${x}.cpp) target_link_libraries(${x} simgrid) set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x}) diff --git a/teshsuite/simix/check_defaults/check_defaults.c b/teshsuite/simix/check_defaults/check_defaults.cpp similarity index 94% rename from teshsuite/simix/check_defaults/check_defaults.c rename to teshsuite/simix/check_defaults/check_defaults.cpp index bf009d1e7b..581dd6ab87 100644 --- a/teshsuite/simix/check_defaults/check_defaults.c +++ b/teshsuite/simix/check_defaults/check_defaults.cpp @@ -9,7 +9,7 @@ #include "simgrid/simix.h" #include "xbt/log.h" -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { xbt_log_control_set("root.fmt:[%c/%p]%e%m%n"); xbt_log_control_set("simix_context.threshold:verbose"); diff --git a/teshsuite/simix/stack_overflow/stack_overflow.c b/teshsuite/simix/stack_overflow/stack_overflow.cpp similarity index 94% rename from teshsuite/simix/stack_overflow/stack_overflow.c rename to teshsuite/simix/stack_overflow/stack_overflow.cpp index 5c7f74cf6d..551b5a0bee 100644 --- a/teshsuite/simix/stack_overflow/stack_overflow.c +++ b/teshsuite/simix/stack_overflow/stack_overflow.cpp @@ -26,7 +26,7 @@ static unsigned collatz(unsigned c0, unsigned n) return x; } -static int master(int argc, char *argv[]) +static int master(int argc, char* argv[]) { XBT_INFO("Launching our nice bugged recursive function..."); unsigned i = 1; @@ -38,7 +38,7 @@ static int master(int argc, char *argv[]) return 0; } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { SIMIX_global_init(&argc, argv); diff --git a/teshsuite/xbt/parmap_bench/parmap_bench.c b/teshsuite/xbt/parmap_bench/parmap_bench.c index 16505df21e..3944546a5b 100644 --- a/teshsuite/xbt/parmap_bench/parmap_bench.c +++ b/teshsuite/xbt/parmap_bench/parmap_bench.c @@ -1,17 +1,16 @@ -/* Copyright (c) 2012-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ +#include "simgrid/msg.h" +#include "src/internal_config.h" /* HAVE_FUTEX_H */ +#include "xbt/xbt_os_time.h" #include #include #include #include #include -#include "src/internal_config.h" /* HAVE_FUTEX_H */ -#include "simgrid/simix.h" -#include "xbt/xbt_os_time.h" #define MODES_DEFAULT 0x7 #define TIMEOUT 10.0 @@ -162,7 +161,7 @@ int main(int argc, char *argv[]) int nthreads; unsigned modes = MODES_DEFAULT; - SIMIX_global_init(&argc, argv); + MSG_init(&argc, argv); if (argc != 2 && argc != 3) { fprintf(stderr, "Usage: %s nthreads [modes]\n" diff --git a/teshsuite/xbt/parmap_test/parmap_test.c b/teshsuite/xbt/parmap_test/parmap_test.c index e2d5faf310..b520b5d8c5 100644 --- a/teshsuite/xbt/parmap_test/parmap_test.c +++ b/teshsuite/xbt/parmap_test/parmap_test.c @@ -1,16 +1,15 @@ /* parmap_test -- test parmap */ -/* Copyright (c) 2007-2010, 2013-2014. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2017. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ -#include "simgrid/simix.h" +#include "simgrid/msg.h" +#include "src/internal_config.h" #include "xbt.h" #include "xbt/ex.h" #include "xbt/xbt_os_time.h" -#include "src/internal_config.h" XBT_LOG_NEW_DEFAULT_CATEGORY(parmap_test, "Test for parmap"); @@ -115,7 +114,7 @@ static int test_parmap_extended(e_xbt_parmap_mode_t mode) int main(int argc, char** argv) { int status = 0; - SIMIX_global_init(&argc, argv); + MSG_init(&argc, argv); XBT_INFO("Basic testing posix"); status += test_parmap_basic(XBT_PARMAP_POSIX); diff --git a/tools/cmake/DefinePackages.cmake b/tools/cmake/DefinePackages.cmake index 4c2e631cb8..f4d5b0f7cf 100644 --- a/tools/cmake/DefinePackages.cmake +++ b/tools/cmake/DefinePackages.cmake @@ -277,7 +277,7 @@ set(XBT_SRC src/xbt/xbt_log_layout_simple.c src/xbt/xbt_main.cpp src/xbt/xbt_os_file.c - src/xbt/xbt_os_synchro.c + src/xbt/xbt_os_synchro.cpp src/xbt/xbt_os_time.c src/xbt/xbt_replay.cpp src/xbt/xbt_str.cpp