in astra-sim-alibabacloud/astra-sim/system/Sys.cc [467:529]
int Sys::sim_send(
Tick delay,
void* buffer,
uint64_t count,
int type,
int dst,
int tag,
sim_request* request,
void (*msg_handler)(void* fun_arg),
void* fun_arg) {
if (delay == 0 && fun_arg == nullptr) {
Sys::sysCriticalSection cs;
SendPacketEventHandlerData* fun_arg_tmp =
new SendPacketEventHandlerData(this, id+npu_offset, dst, tag);
fun_arg = (void*)fun_arg_tmp;
if (is_there_pending_sends.find(std::make_pair(dst, tag)) == is_there_pending_sends.end() ||
is_there_pending_sends[std::make_pair(dst, tag)] == false) {
is_there_pending_sends[std::make_pair(dst, tag)] = true;
cs.ExitSection();
} else {
if (pending_sends.find(std::make_pair(dst, tag)) ==
pending_sends.end()) {
std::list<SimSendCaller*> tmp;
pending_sends[std::make_pair(dst, tag)] = tmp;
}
pending_sends[std::make_pair(dst, tag)].push_back(
new SimSendCaller(
this,
buffer,
count,
type,
dst,
tag,
*request,
msg_handler,
fun_arg));
cs.ExitSection();
return 1;
}
}
if (delay == 0) {
NI->sim_send(buffer, count, type, dst, tag, request, msg_handler, fun_arg);
} else {
try_register_event(
new SimSendCaller(
this,
buffer,
count,
type,
dst,
tag,
*request,
msg_handler,
fun_arg),
EventType::General,
nullptr,
delay);
}
return 1;
}