コード例 #1
0
ファイル: SRDAGVertex.cpp プロジェクト: louisbob/Spider
void SRDAGVertex::updateState(){
	if(state_ == SRDAG_NEXEC){
		/* Check Input Edges */
		for (int i = 0; i < getNConnectedInEdge(); i++){
			SRDAGVertex* predecessor = getInEdge(i)->getSrc();

			if(!predecessor || predecessor->isHierarchical()){
				state_ = SRDAG_NEXEC;
				return;
			}

			if(predecessor->state_ == SRDAG_NEXEC){
				predecessor->updateState();
				if(predecessor->state_ == SRDAG_NEXEC){
					state_ = SRDAG_NEXEC;
					return;
				}
			}
		}
		state_ = SRDAG_EXEC;
	}
}
コード例 #2
0
ファイル: SRDAGGraph.cpp プロジェクト: hewumars/Spider
/** Print Fct */
void SRDAGGraph::print(const char *path){

	if(!check())
		printf("Errors in the SRDAG Graph\n");

	int maxId = -1;
	int file = Platform::get()->fopen(path);
	if(file == -1){
		printf("cannot open %s\n", path);
		return;
	}

	// Writing header
	Platform::get()->fprintf(file, "digraph csdag {\n");
	Platform::get()->fprintf(file, "\tnode [color=\"#433D63\"];\n");
	Platform::get()->fprintf(file, "\tedge [color=\"#9262B6\" arrowhead=\"empty\"];\n");
	Platform::get()->fprintf(file, "\trankdir=LR;\n\n");

	// Drawing vertices.
	Platform::get()->fprintf(file, "\t# Vertices\n");
	for (int i=0; i<vertices_.getN(); i++){
		char name[100];
		SRDAGVertex* vertex = vertices_[i];
		vertex->toString(name, 100);
		Platform::get()->fprintf(file, "\t%d [shape=ellipse,label=\"%d\\n%s (%d)\n%s",
				vertex->getId(),
				vertex->getId(),
				name,
				vertex->getFctId(),
				stateStrings[vertex->getState()]);
		Platform::get()->fprintf(file, "\",color=");
		switch (vertex->getState()){
			case SRDAG_EXEC:
				Platform::get()->fprintf(file, "blue");
				break;
			case SRDAG_RUN:
				Platform::get()->fprintf(file, "gray");
				break;
			case SRDAG_NEXEC:
				if(vertex->isHierarchical())
					Platform::get()->fprintf(file, "red");
				else
					Platform::get()->fprintf(file, "black");
				break;
		}
		Platform::get()->fprintf(file, "];\n");

		maxId = std::max(vertex->getId(),maxId);
	}

	// Drawing edges.
	Platform::get()->fprintf(file, "\t# Edges\n");
	for (int i=0; i<edges_.getN(); i++) {
		SRDAGEdge* edge = edges_[i];
		int snkIx, srcIx;

		if(edge->getSrc())
			srcIx = edge->getSrc()->getId();
		else{
			maxId++;
			Platform::get()->fprintf(file, "\t%d [shape=point];\n", maxId);
			srcIx = maxId;
		}
		if(edge->getSnk())
			snkIx = edge->getSnk()->getId();
		else{
			maxId++;
			Platform::get()->fprintf(file, "\t%d [shape=point];\n", maxId);
			snkIx = maxId;
		}

//		switch(mode){
//		case DataRates:
			Platform::get()->fprintf(file, "\t%d->%d [label=\"%d (ID%d)\n%#x (ix %d : %d tokens)\",taillabel=\"%d\",headlabel=\"%d\"];\n",
					srcIx, snkIx,
					edge->getRate(),
					edge->getId(),
					edge->getAlloc(),
					edge->getAllocIx(),
					edge->getNToken(),
					edge->getSrcPortIx(),
					edge->getSnkPortIx());
//			break;
//		case Allocation:
//			Platform::get()->fprintf(file, "\t%d->%d [label=\"%d: %#x (%#x)\"];\n",
//					srcIx, snkIx,
//					edge->fifo.id,
//					edge->fifo.add,
//					edge->fifo.size);
//			break;
//		}

	}


	Platform::get()->fprintf(file, "}\n");
	Platform::get()->fclose(file);
}