void QemuSescReader::advancePC() { if (tracEof) { PC = 0xffffffff; return; } readInst(); }
void QemuSescReader::openTrace(const char *filename) { trace = fopen(filename, "rb"); if (trace == NULL){ MSG("QemuSescReader::Can't open the trace file [%s].", filename); exit(-1); } tracEof = false; readInst(); //for first instruction if(tracEof) { MSG("QemuSescReader::Bad trace file."); exit(-1); } }
int main() { // srand(time(0)); // generateInst(CASE); for(CASE = 1; CASE<=10; CASE++) { _mkdir("GAgrid"); strcpy(strdir,"GAgrid//inst"); itoa(CASE,ch,10); strcat(strdir,ch); _mkdir(strdir); strcat(strdir,"//"); readInst(CASE); int i,j; int gen; clock_t start; ////////////////// avg_result_time = 0; ////////////////// for(trialNum = 1; trialNum <= TRIALNUM; trialNum++) { strcpy(str,strdir); strcat(str,"result.txt"); ftotal = fopen(str,"a"); strcpy(str,strdir); itoa(trialNum,ch,10); strcat(str,"resultMnum"); strcat(str,ch); strcat(str,".txt"); fresultgMnum = fopen(str,"w"); strcpy(str,strdir); strcat(str,"runtime"); strcat(str,ch); strcat(str,".txt"); fruntime = fopen(str,"w"); start = clock(); ////////////////// gen = 0; initialize(CASE); evaluate(CASE); keep_the_best(); while(gen < MAXGENS) { select(); //using roulette wheel selection crossover(); mutate(); evaluate(CASE); elitist(); gen++; // printf("%d\t%g\t%g\n",gen,pop[POPSIZE].fitness,pop[POPSIZE].cost); fprintf(fruntime,"%d\t%g\t%g\n",gen,pop[POPSIZE].fitness,pop[POPSIZE].cost); } avg_result_time += clock() - start; ////////////////// printf("%d\t%g\t%g\n",trialNum,pop[POPSIZE].fitness,pop[POPSIZE].cost); fprintf(ftotal,"%d\t%g\t%g\t%g\n",trialNum,pop[POPSIZE].fitness,pop[POPSIZE].cost,(double)avg_result_time/trialNum);////////////////// for(i=0;i<24;i++) { for(j=0;j<MTYPE;j++) { fprintf(fresultgMnum,"%d\t",pop[POPSIZE].gMnum[i][j]); } fprintf(fresultgMnum,"\n"); } // printf("\n"); fprintf(fresultgMnum,"\n"); fclose(fresultgMnum); fclose(ftotal); fclose(fruntime); } } return 0; }