Esempio n. 1
0
bool SRDAGGraph::check(){
	bool result = true;

	/* Check vertices */
	for (int i=0; i<vertices_.getN(); i++){
		SRDAGVertex* vertex = vertices_[i];
		int j;

		// Check input edges
		for(j=0; j<vertex->getNConnectedInEdge(); j++){
			const SRDAGEdge* edge = vertex->getInEdge(j);
			if(vertex->getType() == SRDAG_JOIN
					&& edge == NULL){
				printf("Warning V%d Input%d: not connected\n", vertex->getId(), j);
			}else if(edge == NULL){
				printf("Error V%d Input%d: not connected\n", vertex->getId(), j);
				result = false;
			}else if(edge->getSnk() != vertex){
				printf("Error V%d E%d: connection mismatch\n", vertex->getId(), edge->getId());
				result = false;
			}
		}

		// Check output edges
		for(j=0; j<vertex->getNConnectedOutEdge(); j++){
			const SRDAGEdge* edge = vertex->getOutEdge(j);
			if(vertex->getType() == SRDAG_FORK
					&& edge == NULL){
				printf("Warning V%d Output%d: not connected\n", vertex->getId(), j);
			}else if(edge == NULL){
				printf("Error V%d Output%d: not connected\n", vertex->getId(), j);
				result = false;
			}else if(edge->getSrc() != vertex){
				printf("Error V%d E%d: connection mismatch\n", vertex->getId(), edge->getId());
				result = false;
			}
		}
	}

	/* Check edges */


	return result;
}
Esempio n. 2
0
/** 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);
}