Beispiel #1
0
int datFill(char *datSrc, int numel,void *rp, void *ip, int dtype){
if ( strcmp(datSrc,"rand")==0 ) {
	 randFill(numel,rp,dtype);
	 if ( ip ) randFill(numel,ip,dtype);	
  } else {
	 FILE *fd = fopen(datSrc,"r");
	 if ( !fd ) {
		datSrc = readMx(&numel,datSrc,rp,dtype);
		if ( ip ) datSrc=readMx(&numel,datSrc,ip,dtype);			
	 } else {
		fd=freadMx(&numel,fd,rp,dtype);
		if ( ip ) fd=freadMx(&numel,fd,ip,dtype);	
		fclose(fd);
	 }
  }
 return numel;
}
Beispiel #2
0
// {{{ elapsedTime
stat_t elapsedTime (int n, int m, int c, int nb_iter) {
	int i=0;
	stat_t result;
	GTimer *timer = g_timer_new();

	memset(&result, 0, sizeof(stat_t));

	for (i=0; i< nb_iter; i++) {

		// Graph Initialization
    Graph * lcLab = allocListGraph(n);
    Graph * lcFIFO = allocListGraph(n);
    randFill(lcLab,m,c,1,lcFIFO);
		Graph *lcDinic = copyGraph(lcLab);

    int f,g,h;

		// FIFO Algorithm
    Graph * lfFIFO = allocGraph(lcFIFO);
    Graph * ldFIFO = copyGraph(lcFIFO);

//		printf ("Entrée FIFO\n");
		g_timer_start(timer);
    h=algoFIFO (lcFIFO,ldFIFO,lfFIFO,0,1);
		g_timer_stop(timer);
//		printf ("Sortie FIFO\n");

		freeGraph(ldFIFO); freeGraph(lfFIFO); 

		if (h) {
			result._st1 += (double) g_timer_elapsed(timer, NULL);
			g_timer_reset(timer);

			// High Label Algorithm
			Graph * lfLab = allocGraph(lcLab);
			Graph * ldLab = copyGraph(lcLab);

//			printf ("Entrée High Label\n");
			g_timer_start(timer);
			g=algoLabel (lcLab,ldLab,lfLab,0,1);
			g_timer_stop(timer);
			result._st2 += (double) g_timer_elapsed(timer, NULL);
			g_timer_reset(timer);
//			printf ("Sortie High Label\n");

			freeGraph(lfLab); freeGraph(ldLab);


			// Dinic Algorithm
			Graph * lfDinic = allocGraph(lcLab);

//			printf("Entrée Dinic\n");
			g_timer_start(timer);
			f=algoDinic (lcDinic,lfDinic,0,1);
			g_timer_stop(timer);
			result._st3 += (double) g_timer_elapsed(timer, NULL);
			g_timer_reset(timer);
//			printf("Sortie Dinic\n");

			freeGraph (lfDinic);
		}
		else {
			printf ("Flot nul.\n");
			g_timer_reset(timer);
			i --;
		}
    
		freeGraph (lcFIFO); 
		freeGraph (lcLab);
		freeGraph (lcDinic);
	}

	result._st1 /= nb_iter;
	result._st2 /= nb_iter;
	result._st3 /= nb_iter;
	result._st4 /= nb_iter;

	g_timer_destroy(timer);


	return result;
}