namespace simgrid::kernel::activity {
+unsigned CommImpl::next_id_ = 0;
+
std::function<void(CommImpl*, void*, size_t)> CommImpl::copy_data_callback_ = [](kernel::activity::CommImpl* comm,
void* buff, size_t buff_size) {
xbt_assert((buff_size == sizeof(void*)), "Cannot copy %zu bytes: must be sizeof(void*)", buff_size);
s4u::Host* to_ = nullptr; /* Otherwise, computed at start() time from the actors */
CommImplType type_ = CommImplType::SEND; /* Type of the communication (SEND or RECEIVE) */
+ static unsigned next_id_; // Next ID to be given (for MC)
+ const unsigned id_ = ++next_id_; // ID of this comm (for MC) -- 0 as an ID denotes "invalid/unknown comm"
+
public:
CommImpl() = default;
double get_rate() const { return rate_; }
MailboxImpl* get_mailbox() const { return mbox_; }
- long get_mailbox_id() const { return mbox_id_; }
+ unsigned get_mailbox_id() const { return mbox_id_; }
+ unsigned get_id() const { return id_; }
bool is_detached() const { return detached_; }
bool is_assigned() const { return (to_ != nullptr && from_ != nullptr); }
{
if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
stream << " " << (short)mc::Transition::Type::COMM_TEST;
- stream << ' ' << (uintptr_t)comm;
+ stream << ' ' << comm->get_id();
stream << ' ' << (comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1);
stream << ' ' << (comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1);
stream << ' ' << comm->get_mailbox_id();
if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
- return "CommTest(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
+ return "CommTest(comm_id:" + std::to_string(comm->get_id()) +
" src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
" dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
" mbox:" + std::to_string(comm->get_mailbox_id()) + " srcbuf:" + src_buff_id + " dstbuf:" + dst_buff_id +
{
if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
stream << (short)mc::Transition::Type::COMM_WAIT << ' ';
- stream << timeout << ' ' << (uintptr_t)comm;
+ stream << timeout << ' ' << comm->get_id();
stream << ' ' << (comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1);
stream << ' ' << (comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1);
if (const auto* comm = dynamic_cast<activity::CommImpl const*>(act)) {
const std::string src_buff_id = ptr_to_id<unsigned char>(comm->src_buff_);
const std::string dst_buff_id = ptr_to_id<unsigned char>(comm->dst_buff_);
- return "CommWait(comm_id:" + ptr_to_id<activity::CommImpl const>(comm) +
+ return "CommWait(comm_id:" + std::to_string(comm->get_id()) +
" src:" + std::to_string(comm->src_actor_ != nullptr ? comm->src_actor_->get_pid() : -1) +
" dst:" + std::to_string(comm->dst_actor_ != nullptr ? comm->dst_actor_->get_pid() : -1) +
" mbox:" + (comm->get_mailbox() == nullptr ? "-" : comm->get_mailbox()->get_name()) +
{
/* Note that the comm_ is 0 until after the execution of the simcall */
stream << (short)mc::Transition::Type::COMM_ASYNC_SEND << ' ';
- stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' ' << src_buff_size_ << ' '
- << tag_;
+ stream << (comm_ ? comm_->get_id() : 0) << ' ' << mbox_->get_id() << ' ' << (uintptr_t)src_buff_ << ' '
+ << src_buff_size_ << ' ' << tag_;
XBT_DEBUG("SendObserver comm:%p mbox:%u buff:%p size:%zu tag:%d", comm_, mbox_->get_id(), src_buff_, src_buff_size_,
tag_);
}
std::string CommIsendSimcall::to_string() const
{
- return "CommAsyncSend(comm_id: " + std::to_string((uintptr_t)comm_) + " mbox:" + std::to_string(mbox_->get_id()) +
+ return "CommAsyncSend(comm_id: " + std::to_string(comm_->get_id()) + " mbox:" + std::to_string(mbox_->get_id()) +
" srcbuf:" + ptr_to_id<unsigned char>(src_buff_) + " bufsize:" + std::to_string(src_buff_size_) +
" tag: " + std::to_string(tag_) + ")";
}
{
/* Note that the comm_ is 0 until after the execution of the simcall */
stream << (short)mc::Transition::Type::COMM_ASYNC_RECV << ' ';
- stream << (uintptr_t)comm_ << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_ << ' ' << tag_;
+ stream << (comm_ ? comm_->get_id() : 0) << ' ' << mbox_->get_id() << ' ' << (uintptr_t)dst_buff_ << ' ' << tag_;
XBT_DEBUG("RecvObserver comm:%p mbox:%u buff:%p tag:%d", comm_, mbox_->get_id(), dst_buff_, tag_);
}
std::string CommIrecvSimcall::to_string() const
{
- return "CommAsyncRecv(comm_id: " + ptr_to_id<activity::CommImpl const>(comm_) +
- " mbox:" + std::to_string(mbox_->get_id()) + " dstbuf:" + ptr_to_id<unsigned char>(dst_buff_) +
- " tag: " + std::to_string(tag_) + ")";
+ return "CommAsyncRecv(comm_id: " + std::to_string(comm_->get_id()) + " mbox:" + std::to_string(mbox_->get_id()) +
+ " dstbuf:" + ptr_to_id<unsigned char>(dst_buff_) + " tag: " + std::to_string(tag_) + ")";
}
} // namespace simgrid::kernel::actor
});
xbt_assert(issuer != C.end(),
"Invariant violation! A (supposedly) enabled `CommWait` transition "
- "waiting on communication %lu should not be enabled: the receive/send "
+ "waiting on communication %u should not be enabled: the receive/send "
"transition which generated the communication is not an action taken "
"to reach state(C) (the state of the configuration), which should "
"be an impossibility if `%s` is enabled. Please report this as "
});
xbt_assert(issuer != C.end(),
"An enabled `CommTest` transition (%s) is testing a communication"
- "%lu not created by a receive/send "
+ "%u not created by a receive/send "
"transition. SimGrid cannot currently handle test actions "
"under which a test is performed on a communication that was "
"not directly created by a receive/send operation of the same actor.",
namespace simgrid::mc {
-CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, uintptr_t comm_,
- aid_t sender_, aid_t receiver_, unsigned mbox_, uintptr_t sbuff_,
- uintptr_t rbuff_, size_t size_)
+CommWaitTransition::CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_,
+ aid_t receiver_, unsigned mbox_, uintptr_t sbuff_, uintptr_t rbuff_,
+ size_t size_)
: Transition(Type::COMM_WAIT, issuer, times_considered)
, timeout_(timeout_)
, comm_(comm_)
+ , mbox_(mbox_)
, sender_(sender_)
, receiver_(receiver_)
- , mbox_(mbox_)
, sbuff_(sbuff_)
, rbuff_(rbuff_)
, size_(size_)
: Transition(Type::COMM_WAIT, issuer, times_considered)
{
xbt_assert(stream >> timeout_ >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_);
- XBT_DEBUG("CommWaitTransition %s comm:%" PRIxPTR ", sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR
- " rbuff:%" PRIxPTR " size:%zu",
+ XBT_DEBUG("CommWaitTransition %s comm:%u, sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR " rbuff:%" PRIxPTR
+ " size:%zu",
(timeout_ ? "timeout" : "no-timeout"), comm_, sender_, receiver_, mbox_, sbuff_, rbuff_, size_);
}
std::string CommWaitTransition::to_string(bool verbose) const
return false; // Comm transitions are INDEP with non-comm transitions
}
-CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, uintptr_t comm_, aid_t sender_,
+CommTestTransition::CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_,
aid_t receiver_, unsigned mbox_, uintptr_t sbuff_, uintptr_t rbuff_,
size_t size_)
: Transition(Type::COMM_TEST, issuer, times_considered)
, comm_(comm_)
+ , mbox_(mbox_)
, sender_(sender_)
, receiver_(receiver_)
- , mbox_(mbox_)
, sbuff_(sbuff_)
, rbuff_(rbuff_)
, size_(size_)
: Transition(Type::COMM_TEST, issuer, times_considered)
{
xbt_assert(stream >> comm_ >> sender_ >> receiver_ >> mbox_ >> sbuff_ >> rbuff_ >> size_);
- XBT_DEBUG("CommTestTransition comm:%" PRIxPTR ", sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR " rbuff:%" PRIxPTR
+ XBT_DEBUG("CommTestTransition comm:%u, sender:%ld receiver:%ld mbox:%u sbuff:%" PRIxPTR " rbuff:%" PRIxPTR
" size:%zu",
comm_, sender_, receiver_, mbox_, sbuff_, rbuff_, size_);
}
return false; // Comm transitions are INDEP with non-comm transitions
}
-CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_,
+CommRecvTransition::CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_,
uintptr_t rbuff_, int tag_)
: Transition(Type::COMM_ASYNC_RECV, issuer, times_considered)
, comm_(comm_)
return false; // Comm transitions are INDEP with non-comm transitions
}
-CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_,
+CommSendTransition::CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_,
uintptr_t sbuff_, size_t size_, int tag_)
: Transition(Type::COMM_ASYNC_SEND, issuer, times_considered)
, comm_(comm_)
: Transition(Type::COMM_ASYNC_SEND, issuer, times_considered)
{
xbt_assert(stream >> comm_ >> mbox_ >> sbuff_ >> size_ >> tag_);
- XBT_DEBUG("SendTransition comm:%" PRIxPTR " mbox:%u sbuff:%" PRIxPTR " size:%zu", comm_, mbox_, sbuff_, size_);
+ XBT_DEBUG("SendTransition comm:%u mbox:%u sbuff:%" PRIxPTR " size:%zu", comm_, mbox_, sbuff_, size_);
}
std::string CommSendTransition::to_string(bool verbose = false) const
{
class CommWaitTransition : public Transition {
bool timeout_;
- uintptr_t comm_;
+ unsigned comm_;
+ unsigned mbox_;
aid_t sender_;
aid_t receiver_;
- unsigned mbox_;
uintptr_t sbuff_;
uintptr_t rbuff_;
size_t size_;
friend CommTestTransition;
public:
- CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, uintptr_t comm_, aid_t sender_, aid_t receiver_,
+ CommWaitTransition(aid_t issuer, int times_considered, bool timeout_, unsigned comm_, aid_t sender_, aid_t receiver_,
unsigned mbox_, uintptr_t sbuff_, uintptr_t rbuff_, size_t size_);
CommWaitTransition(aid_t issuer, int times_considered, std::stringstream& stream);
std::string to_string(bool verbose) const override;
bool depends(const Transition* other) const override;
bool get_timeout() const { return timeout_; }
- /** Address of the corresponding Communication object in the application */
- uintptr_t get_comm() const { return comm_; }
+ /** ID of the corresponding Communication object in the application, or 0 if unknown */
+ unsigned get_comm() const { return comm_; }
/** Sender ID */
aid_t get_sender() const { return sender_; }
/** Receiver ID */
size_t get_size() const { return size_; }
};
class CommTestTransition : public Transition {
- uintptr_t comm_;
+ unsigned comm_;
+ unsigned mbox_;
aid_t sender_;
aid_t receiver_;
- unsigned mbox_;
uintptr_t sbuff_;
uintptr_t rbuff_;
size_t size_;
friend CommRecvTransition;
public:
- CommTestTransition(aid_t issuer, int times_considered, uintptr_t comm_, aid_t sender_, aid_t receiver_,
- unsigned mbox_, uintptr_t sbuff_, uintptr_t rbuff_, size_t size_);
+ CommTestTransition(aid_t issuer, int times_considered, unsigned comm_, aid_t sender_, aid_t receiver_, unsigned mbox_,
+ uintptr_t sbuff_, uintptr_t rbuff_, size_t size_);
CommTestTransition(aid_t issuer, int times_considered, std::stringstream& stream);
std::string to_string(bool verbose) const override;
bool depends(const Transition* other) const override;
- /** Address of the corresponding Communication object in the application */
- uintptr_t get_comm() const { return comm_; }
+ /** ID of the corresponding Communication object in the application, or 0 if unknown */
+ unsigned get_comm() const { return comm_; }
/** Sender ID */
aid_t get_sender() const { return sender_; }
/** Receiver ID */
};
class CommRecvTransition : public Transition {
- uintptr_t comm_; /* Addr of the CommImpl */
+ unsigned comm_; /* ID of the CommImpl or 0 if not known */
unsigned mbox_;
uintptr_t rbuff_;
int tag_;
public:
- CommRecvTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_, uintptr_t rbuff_, int tag_);
+ CommRecvTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, uintptr_t rbuff_, int tag_);
CommRecvTransition(aid_t issuer, int times_considered, std::stringstream& stream);
std::string to_string(bool verbose) const override;
bool depends(const Transition* other) const override;
- /** Address of the corresponding Communication object in the application */
- uintptr_t get_comm() const { return comm_; }
+ /** ID of the corresponding Communication object in the application (or 0 if unknown)*/
+ unsigned get_comm() const { return comm_; }
/** Mailbox ID */
unsigned get_mailbox() const { return mbox_; }
/** Receiver buffer */
};
class CommSendTransition : public Transition {
- uintptr_t comm_; /* Addr of the CommImpl */
+ unsigned comm_;
unsigned mbox_;
uintptr_t sbuff_;
size_t size_;
int tag_;
public:
- CommSendTransition(aid_t issuer, int times_considered, uintptr_t comm_, unsigned mbox_, uintptr_t sbuff_,
- size_t size_, int tag_);
+ CommSendTransition(aid_t issuer, int times_considered, unsigned comm_, unsigned mbox_, uintptr_t sbuff_, size_t size_,
+ int tag_);
CommSendTransition(aid_t issuer, int times_considered, std::stringstream& stream);
std::string to_string(bool verbose) const override;
bool depends(const Transition* other) const override;
- /** Address of the corresponding Communication object in the application */
- uintptr_t get_comm() const { return comm_; }
+ /** ID of the corresponding Communication object in the application, or 0 if unknown */
+ unsigned get_comm() const { return comm_; }
/** Mailbox ID */
unsigned get_mailbox() const { return mbox_; }
/** Sender buffer */