1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
#include <time.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <limits.h>
#include <../litmus.h>
#define L3_CACHE_SIZE (11264*1024)
#define SAVE_RESULTS if(jobsComplete>-1) progTime[jobsComplete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec));
#define SET_UP char *thisProgram=argv[1];\
int maxJobs=atoi(argv[2]);\
char *thisCore=argv[3];\
char *otherCore=argv[4];\
char *otherProgram=argv[5];\
char *runID=argv[6];\
int output=atoi(argv[7]);\
struct timespec start, end;\
int jobsComplete;\
long progTime[maxJobs*output];\
char fileName[50];\
char *bigArray;\
strcpy(fileName, runID);\
strcat(fileName, ".txt");\
mlockall(MCL_CURRENT || MCL_FUTURE);
#define WRITE_TO_FILE if (output){\
munlockall();\
FILE *fp=fopen(fileName, "a");\
for(jobsComplete=0; jobsComplete<maxJobs; jobsComplete++){\
fprintf(fp, "%s %s %s %s %d %ld %s %d \n",\
thisProgram, otherProgram, thisCore, otherCore, maxJobs,\
progTime[jobsComplete], runID, jobsComplete);\
}\
fclose(fp);\
}
#define KILL_CACHE bigArray=(char *)malloc(L3_CACHE_SIZE);\
if (bigArray==NULL) perror("Malloc failed.\n");\
memset(bigArray, 1, L3_CACHE_SIZE);\
munlock(bigArray, L3_CACHE_SIZE);\
free(bigArray);\
bigArray=NULL;
//invoke start timer twice, stop timer to make sure timer and vars are in cache
#define START_TIMER clock_gettime(CLOCK_MONOTONIC, &start);\
clock_gettime(CLOCK_MONOTONIC, &end);\
clock_gettime(CLOCK_MONOTONIC, &start);\
#define STOP_TIMER clock_gettime(CLOCK_MONOTONIC, &end);
#define START_LOOP START_TIMER
#define STOP_LOOP if (output) {STOP_TIMER SAVE_RESULTS} sleep_next_period();
/*
Intended structure
main
SET_UP
notice that STOP LOOP negates the ++ if outout=0
for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){
KILL_CACHE
START_TIMER
tacleInit();
tacleMain();
STOP_TIMER
SAVE_RESULTS
}
WRITE_TO_FILE
tacleReturn
*/
|