00001 #include "simulator.h" 00002 #include "link.h" 00003 00004 using namespace std; 00005 00006 Link::Link(int srcComponentId, int linkWidth) 00007 { 00008 src=srcComponentId; 00009 width=linkWidth; 00010 //lookup src component 00011 ComponentDescription* compDesc=Simulator::getComponentDesc(srcComponentId); 00012 if(compDesc->lpId==Simulator::MyRank()) 00013 { 00014 //add link to src component 00015 compDesc->ptr->addOutputLink(this); 00016 } 00017 } 00018 00019 void Link::Send(uint64_t data, int srcComponentId) 00020 { 00021 list<OutputBase*>::iterator iter; 00022 for(iter=outputs.begin(); iter!=outputs.end(); iter++) 00023 { 00024 ComponentDescription* compDesc= 00025 Simulator::getComponentDesc((*iter)->componentId); 00026 if(compDesc->lpId==Simulator::MyRank()) 00027 { 00028 Simulator::Schedule(Simulator::Now()+((*iter)->latency), 00029 &OutputBase::CallHandler, (*iter), data, 00030 srcComponentId); 00031 } 00032 else 00033 { 00034 //Send with MPI 00035 } 00036 } 00037 }