This class has five private states as follows.
IntState doCompile;If these states are set YES, we compile and run the generated code.
IntState doRun;
StringState machineNames;We list the machine names separated by commas. If all machines names listed have the same suffix, we separate that suffix in the second state. For example, if
StringState nameSuffix;
machineName
is "ohm" and nameSuffix
is ".berkeley.edu", we mean machine named "ohm.berkeley.edu".
IntState portNumber;To make socket connections, we assign port numbers that are available. For now, we set the starting port number with this state. We will increase this number by one every time we add a new connection. Therefore, it should be confirmed that these assigned port numbers should be available. If the Ptolemy program is assigned a port number in the future, then we will be able to let the system choose the available port number for each connection.
With the given list of machine names, we prepare a data structure called
MachineInfo
that pairs the machine name and internet address.
class MachineInfo {This class has a constructor with three argument like its base classes. The destructor deallocates
friend class CGCMultiTarget;
const char* inetAdddrr; // internet address
const char* nm; // machine name
public:
MachineInfo: inetAddr(0), nm(0) { }
}
MachineInfo
arrays if allocated. It has makeNew
method and isA
method redefined.
void setup();If the child targets are inherited, we also inherit the machine information. Otherwise, we set up the machine information. The number of processors and the number of machines names should be equal. Then, we call
CGMultiTarget::setup
for normal setup operation . At last, we set the hostName
state of child targets with the machine names.
int wormLoadCode();This method do nothing if
doCompile
state is NO. Otherwise, it compiles the code for all child targets (compileCode).
Then, it checks whether doRun
state is YES or NO. If it is YES, we execute the code.
int sendWormData(PortHole& p);These method should be redefined in the future to support wormhole interface. Currently, they do same tasks with the base Target classes.
int receiveWormData(PortHole& p);
int sendWormData();
int receiveWormData();
MachineInfo* getMachineInfo();These methods return the current machine information and the next port number to be assigned.
int* getPortNumber();
DataFlowStar* createSend(int from, int to, int num);The above methods create CGCUnixSend and CGCUnixReceive stars for communication stars with TCP protocol.
DataFlowStar* createReceive(int from, int to, int num);
void pairSendReceive(DataFlowStar* snd, DataFlowStar* rcv);This method pairs a UnixSend star and a UnixReceive star to make a connection. We assign a port number to the connection. More important task is to generate function calls in the initialization code (
commInit
stream) of two child targets which these communication stars belong to. These functions will make a TCP connection between two child targets with the assigned port number. The UnixSend star will call connect
function while the UnixReceive star will call listen
function.
void setMachineAddr(CGStar* snd, CGStar* rcv);This method informs the
snd
star about the internet address of the machine that the rcv
star is scheduled on. The address is needed in connect
function.
void signalCopy(int flag);By giving a non-zero value as the argument, we indicate that the code will be duplicated in different set of processors so that we need to adjust the machine information of communication stars.
void prepCode(Profile* pf, int nP, int numChunk);This method is also used to allow code replication into different set of targets.
DataFlowStar* createCollect();These methods create CGCCollect and CGCSpread stars.
DataFlowStar* createSpread();