SPEC

From Yefu's notes
Jump to: navigation, search
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>

char bmarks[][256] ={
"perlbench",
"bzip2",
"gcc",
"mcf",
"gobmk",
"hmmer",
"sjeng",
"libquantum",
"h264ref",
"omnetpp",
"astar",
"xalancbmk",
"bwaves",
"gamess",
"milc",
"zeusmp",
"gromacs",
"cactusADM",
"leslie3d",
"namd",
"dealII",
"soplex",
"povray",
"calculix",
"GemsFDTD",
"tonto",
"lbm",
"wrf",
"sphinx3"
};


int main()
{
system("source /usr/cpu2006/shrcyefu");
char cmd[256];
char buf[1024];
int ret=mkfifo("/tmp/bench",0777);
chmod("/tmp/ffreq",S_IRUSR| S_IWUSR | S_IRGRP | S_IWGRP | S_IWOTH);
int i;
if(!ret)perror("mkfifo");


for(;;)
{
printf("Before open FIFO\n");
FILE* ft = fopen("/tmp/bench", "r");
bzero(buf,1024);
printf("W8ing4IO\n");
fgets(buf,1024,ft);
fclose(ft);

sprintf(cmd,"killall -g runspec");
system(cmd);

for(i=0;i<1024;i++)
{
if(buf[i]=='\n' || buf[i] == '\r')
{
buf[i]='\0';
}
}

sprintf(cmd,"runspec --config=yefu.cfg --size=ref --noreportable --iterations=3 %s &\n",buf);
int j;
for(j=0;j<4;j++)
{
//int pid=fork();
//if(pid==0)
//{
//	execve(cmd, NULL, NULL);
// }
system(cmd);
puts("next");
system("sleep 5");
puts(cmd);
}
system("sleep 10");
printf("Begin to collect data for %s", buf);

}
}