diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-19 01:09:53 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-19 01:09:53 -0400 |
commit | a71fc97fd262e1b5770f827047ea60bbaf38d9a2 (patch) | |
tree | b45ef48c63a35817f2db93dd2fec718778f58b99 /baseline/source/litmusStuff.h | |
parent | 41358857592f1908d0c0f9898b6c9acabc1ad161 (diff) |
Unify all the versions of extra.h into a single multipurpose header
There was previously a huge amount of shared code that had to be
copied back and forth. This should reduce the maintenance burden
by containing all future changes to a single file.
New unified library is fully backwards-compatible but also
introduces and the easy-to-use `for_each_job` macro which
replaces the specific `for(...) START_LOOP ... STOP_LOOP`
format requirement and is generally much harder to abuse.
New unified library also automatically cleans up its shared memory
and semaphores, so this commit also removes the separate
`cleanupSemaphores` binary.
I also found a precursor of `extra.h` written by Sims in
`litmusStuff.h`. This code is only interesting for historical
purposes, so it is also removed in this commit.
This commit also adds debug options to all the Makefiles and
silences rm's complaints about non-existent files in make clean.
Diffstat (limited to 'baseline/source/litmusStuff.h')
-rw-r--r-- | baseline/source/litmusStuff.h | 80 |
1 files changed, 0 insertions, 80 deletions
diff --git a/baseline/source/litmusStuff.h b/baseline/source/litmusStuff.h deleted file mode 100644 index dca2360..0000000 --- a/baseline/source/litmusStuff.h +++ /dev/null | |||
@@ -1,80 +0,0 @@ | |||
1 | #include <time.h> | ||
2 | #include <sys/mman.h> | ||
3 | #include <stdlib.h> | ||
4 | #include <stdio.h> | ||
5 | #include <string.h> | ||
6 | #include <signal.h> | ||
7 | #include <limits.h> | ||
8 | #include <../litmus.h> | ||
9 | |||
10 | #define L3_CACHE_SIZE (11264*1024) | ||
11 | |||
12 | #define SAVE_RESULTS if(jobsComplete>-1) progTime[jobsComplete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec)); | ||
13 | |||
14 | |||
15 | #define SET_UP char *thisProgram=argv[1];\ | ||
16 | int maxJobs=atoi(argv[2]);\ | ||
17 | char *thisCore=argv[3];\ | ||
18 | char *otherCore=argv[4];\ | ||
19 | char *otherProgram=argv[5];\ | ||
20 | char *runID=argv[6];\ | ||
21 | int output=atoi(argv[7]);\ | ||
22 | struct timespec start, end;\ | ||
23 | int jobsComplete;\ | ||
24 | long progTime[maxJobs*output];\ | ||
25 | char fileName[50];\ | ||
26 | char *bigArray;\ | ||
27 | strcpy(fileName, runID);\ | ||
28 | strcat(fileName, ".txt");\ | ||
29 | mlockall(MCL_CURRENT || MCL_FUTURE); | ||
30 | |||
31 | #define WRITE_TO_FILE if (output){\ | ||
32 | munlockall();\ | ||
33 | FILE *fp=fopen(fileName, "a");\ | ||
34 | for(jobsComplete=0; jobsComplete<maxJobs; jobsComplete++){\ | ||
35 | fprintf(fp, "%s %s %s %s %d %ld %s %d \n",\ | ||
36 | thisProgram, otherProgram, thisCore, otherCore, maxJobs,\ | ||
37 | progTime[jobsComplete], runID, jobsComplete);\ | ||
38 | }\ | ||
39 | fclose(fp);\ | ||
40 | } | ||
41 | |||
42 | #define KILL_CACHE bigArray=(char *)malloc(L3_CACHE_SIZE);\ | ||
43 | if (bigArray==NULL) perror("Malloc failed.\n");\ | ||
44 | memset(bigArray, 1, L3_CACHE_SIZE);\ | ||
45 | munlock(bigArray, L3_CACHE_SIZE);\ | ||
46 | free(bigArray);\ | ||
47 | bigArray=NULL; | ||
48 | |||
49 | |||
50 | |||
51 | //invoke start timer twice, stop timer to make sure timer and vars are in cache | ||
52 | #define START_TIMER clock_gettime(CLOCK_MONOTONIC, &start);\ | ||
53 | clock_gettime(CLOCK_MONOTONIC, &end);\ | ||
54 | clock_gettime(CLOCK_MONOTONIC, &start);\ | ||
55 | |||
56 | #define STOP_TIMER clock_gettime(CLOCK_MONOTONIC, &end); | ||
57 | |||
58 | |||
59 | #define START_LOOP START_TIMER | ||
60 | |||
61 | #define STOP_LOOP if (output) {STOP_TIMER SAVE_RESULTS} sleep_next_period(); | ||
62 | |||
63 | |||
64 | /* | ||
65 | Intended structure | ||
66 | |||
67 | main | ||
68 | SET_UP | ||
69 | notice that STOP LOOP negates the ++ if outout=0 | ||
70 | for (jobsComplete=-1; jobsComplete<maxJobs; jobsComplete++){ | ||
71 | KILL_CACHE | ||
72 | START_TIMER | ||
73 | tacleInit(); | ||
74 | tacleMain(); | ||
75 | STOP_TIMER | ||
76 | SAVE_RESULTS | ||
77 | } | ||
78 | WRITE_TO_FILE | ||
79 | tacleReturn | ||
80 | */ | ||