diff options
| author | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-19 10:50:23 -0400 |
|---|---|---|
| committer | Joshua Bakita <bakitajoshua@gmail.com> | 2019-10-19 10:50:23 -0400 |
| commit | 4f1aa00f177646b5129304a7d587658aad949946 (patch) | |
| tree | 925a103d779bd7ae2f6568907051f8ce43b868b4 | |
| parent | 7e6ceb16b53fdbdb2a27cf3ade15d32177ff811f (diff) | |
Support LITMUS, MC^2, and alternate benchmarks
| -rw-r--r-- | baseline/source/extra.h | 230 |
1 files changed, 193 insertions, 37 deletions
diff --git a/baseline/source/extra.h b/baseline/source/extra.h index ca92812..df8164f 100644 --- a/baseline/source/extra.h +++ b/baseline/source/extra.h | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | /** | ||
| 2 | * Copyright 2019 Sims Hill Osborne and Joshua Bakita | ||
| 3 | * | ||
| 4 | * This header provides facilities by which to separably run and time TACLeBench | ||
| 5 | **/ | ||
| 1 | #include <time.h> | 6 | #include <time.h> |
| 2 | #include <sys/mman.h> | 7 | #include <sys/mman.h> |
| 3 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| @@ -5,12 +10,47 @@ | |||
| 5 | #include <string.h> | 10 | #include <string.h> |
| 6 | #include <signal.h> | 11 | #include <signal.h> |
| 7 | #include <limits.h> | 12 | #include <limits.h> |
| 13 | #include <fcntl.h> | ||
| 8 | 14 | ||
| 9 | #define L3_CACHE_SIZE (11264*1024) | 15 | // These constants correspond to the imx6q-sabredb platform |
| 16 | #define LINE_SIZE 32 | ||
| 17 | #define L2_SIZE 16*2048*32 | ||
| 10 | 18 | ||
| 19 | #if __arm__ | ||
| 20 | #include <unistd.h> | ||
| 21 | #include <sys/syscall.h> | ||
| 22 | #endif | ||
| 11 | 23 | ||
| 24 | #define LITMUS 1 | ||
| 25 | #define MC2 1 | ||
| 26 | #define MMDC_PROF 1 | ||
| 12 | 27 | ||
| 13 | #define SET_UP char *thisProgram=argv[1];\ | 28 | #if LITMUS |
| 29 | #include <litmus.h> | ||
| 30 | #endif | ||
| 31 | |||
| 32 | #if MMDC_PROF | ||
| 33 | #include "/media/speedy/litmus/tools/mmdc/mmdc.h" | ||
| 34 | #endif | ||
| 35 | |||
| 36 | #if LITMUS | ||
| 37 | #define SET_UP LOAD_PARAMS SETUP_LITMUS | ||
| 38 | #else | ||
| 39 | #define SET_UP LOAD_PARAMS | ||
| 40 | #endif | ||
| 41 | |||
| 42 | #if MMDC_PROF | ||
| 43 | #define LOAD_PARAMS LOAD_PARAMS_ITRL SETUP_MMDC | ||
| 44 | #else | ||
| 45 | #define LOAD_PARAMS LOAD_PARAMS_ITRL | ||
| 46 | #endif | ||
| 47 | |||
| 48 | #define LOAD_PARAMS_ITRL \ | ||
| 49 | if (argc < 9) { \ | ||
| 50 | printf("Usage: %s <name> <loops> <my core> <unused> <unused> <runID> <\?\?\?>", argv[0]);\ | ||
| 51 | exit(1);\ | ||
| 52 | }\ | ||
| 53 | char *thisProgram=argv[1];\ | ||
| 14 | int maxJobs=atoi(argv[2]);\ | 54 | int maxJobs=atoi(argv[2]);\ |
| 15 | char *thisCore=argv[3];\ | 55 | char *thisCore=argv[3];\ |
| 16 | char *otherCore=argv[4];\ | 56 | char *otherCore=argv[4];\ |
| @@ -20,37 +60,152 @@ | |||
| 20 | pid_t killMe;\ | 60 | pid_t killMe;\ |
| 21 | struct timespec start, end;\ | 61 | struct timespec start, end;\ |
| 22 | int jobsComplete;\ | 62 | int jobsComplete;\ |
| 63 | int jobs_complete = -1;\ | ||
| 23 | long progTime[maxJobs*output];\ | 64 | long progTime[maxJobs*output];\ |
| 65 | memset(progTime, 0, sizeof(long)*maxJobs*output);\ | ||
| 24 | char fileName[50];\ | 66 | char fileName[50];\ |
| 25 | char *bigArray;\ | 67 | char *bigArray;\ |
| 26 | int wasteCount;\ | 68 | int wasteCount;\ |
| 69 | unsigned long mmdc_read[maxJobs];\ | ||
| 70 | unsigned long mmdc_write[maxJobs];\ | ||
| 71 | memset(mmdc_read, 0, sizeof(unsigned long)*maxJobs);\ | ||
| 72 | memset(mmdc_write, 0, sizeof(unsigned long)*maxJobs);\ | ||
| 27 | strcpy(fileName, runID);\ | 73 | strcpy(fileName, runID);\ |
| 28 | strcat(fileName, ".txt");\ | 74 | strcat(fileName, ".txt");\ |
| 29 | mlockall(MCL_CURRENT || MCL_FUTURE); | 75 | mlockall(MCL_CURRENT || MCL_FUTURE); |
| 30 | 76 | ||
| 77 | #define SETUP_MMDC \ | ||
| 78 | MMDC_PROFILE_RES_t mmdc_res; \ | ||
| 79 | memset(&mmdc_res, 0, sizeof(MMDC_PROFILE_RES_t));\ | ||
| 80 | int fd = open("/dev/mem", O_RDWR, 0);\ | ||
| 81 | if (fd < 0) {\ | ||
| 82 | perror("Unable to open /dev/mem");\ | ||
| 83 | exit(1);\ | ||
| 84 | }\ | ||
| 85 | pMMDC_t mmdc = mmap(NULL, 0x4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, MMDC_P0_IPS_BASE_ADDR);\ | ||
| 86 | if (mmdc == MAP_FAILED) {\ | ||
| 87 | perror("Unable to map MMDC address space");\ | ||
| 88 | exit(1);\ | ||
| 89 | }\ | ||
| 90 | mmdc->madpcr1 = axi_arm1;\ | ||
| 91 | msync(&(mmdc->madpcr1),4,MS_SYNC); | ||
| 92 | |||
| 93 | #define SETUP_LITMUS \ | ||
| 94 | unsigned int cpu = atoi(thisCore); \ | ||
| 95 | unsigned int wait = 0; \ | ||
| 96 | if (be_migrate_to_domain(cpu) < 0) { \ | ||
| 97 | perror("Unable to migrate to specified CPU"); \ | ||
| 98 | exit(1); \ | ||
| 99 | } \ | ||
| 100 | struct reservation_config res; \ | ||
| 101 | res.id = gettid(); \ | ||
| 102 | res.cpu = cpu; \ | ||
| 103 | res.priority = LITMUS_HIGHEST_PRIORITY; \ | ||
| 104 | /* we take over half the CPU time (these are ns) */ \ | ||
| 105 | res.polling_params.budget = ms2ns(999); \ | ||
| 106 | res.polling_params.period = ms2ns(1000); \ | ||
| 107 | res.polling_params.offset = 0; \ | ||
| 108 | res.polling_params.relative_deadline = ms2ns(999); \ | ||
| 109 | /* Not 100% sure that we should use periodic polling */ \ | ||
| 110 | if (reservation_create(PERIODIC_POLLING, &res) < 0) { \ | ||
| 111 | perror("Unable to create reservation"); \ | ||
| 112 | exit(1); \ | ||
| 113 | } \ | ||
| 114 | struct rt_task rt_param; \ | ||
| 115 | init_rt_task_param(&rt_param); \ | ||
| 116 | /* Supposedly the next two parameters are irrelevant when reservations are enabled, but I'm leaving them anyway... */ \ | ||
| 117 | rt_param.exec_cost = ms2ns(999); \ | ||
| 118 | rt_param.period = ms2ns(1000); \ | ||
| 119 | rt_param.priority = LITMUS_HIGHEST_PRIORITY; \ | ||
| 120 | rt_param.cls = RT_CLASS_HARD; \ | ||
| 121 | rt_param.release_policy = TASK_PERIODIC; \ | ||
| 122 | rt_param.budget_policy = NO_ENFORCEMENT; \ | ||
| 123 | rt_param.cpu = cpu; \ | ||
| 124 | if (set_rt_task_param(gettid(), &rt_param) < 0) { \ | ||
| 125 | perror("Unable to set real-time parameters"); \ | ||
| 126 | exit(1); \ | ||
| 127 | } \ | ||
| 128 | if (init_litmus() != 0) { \ | ||
| 129 | perror("init_litmus failed"); \ | ||
| 130 | exit(1); \ | ||
| 131 | } \ | ||
| 132 | MC2_SETUP \ | ||
| 133 | if (task_mode(LITMUS_RT_TASK) != 0) { \ | ||
| 134 | perror("Unable to become real-time task"); \ | ||
| 135 | exit(1); \ | ||
| 136 | } \ | ||
| 137 | if (wait && wait_for_ts_release() != 0) { \ | ||
| 138 | perror("Unable to wait for taskset release"); \ | ||
| 139 | exit(1); \ | ||
| 140 | } | ||
| 141 | |||
| 142 | #if MC2 | ||
| 143 | #define MC2_SETUP \ | ||
| 144 | struct mc2_task mc2_param; \ | ||
| 145 | mc2_param.res_id = gettid(); \ | ||
| 146 | mc2_param.crit = CRIT_LEVEL_A; \ | ||
| 147 | if (set_mc2_task_param(gettid(), &mc2_param) < 0) { \ | ||
| 148 | perror("Unable to set MC^2 task params"); \ | ||
| 149 | exit(1); \ | ||
| 150 | } \ | ||
| 151 | set_page_color(rt_param.cpu); | ||
| 152 | #else | ||
| 153 | #define MC2_SETUP | ||
| 154 | #endif | ||
| 31 | 155 | ||
| 32 | //if output==0, endless loop | 156 | #define CLEANUP_LITMUS \ |
| 33 | //avoids int overflow error with large numbers for background loops | 157 | if (task_mode(BACKGROUND_TASK) != 0) { \ |
| 158 | perror("Unable to become a real-time task"); \ | ||
| 159 | exit(1); \ | ||
| 160 | } \ | ||
| 161 | reservation_destroy(gettid(), rt_param.cpu); | ||
| 34 | 162 | ||
| 35 | #define SAVE_RESULTS if(jobsComplete>-1) progTime[jobsComplete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec)); | 163 | #if MMDC_PROF |
| 164 | #define SAVE_RESULTS \ | ||
| 165 | if(jobs_complete>-1) {\ | ||
| 166 | progTime[jobs_complete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec));\ | ||
| 167 | mmdc_read[jobs_complete] = mmdc_res.read_bytes;\ | ||
| 168 | mmdc_write[jobs_complete] = mmdc_res.write_bytes;\ | ||
| 169 | } | ||
| 170 | #else | ||
| 171 | #define SAVE_RESULTS \ | ||
| 172 | if(jobs_complete>-1)\ | ||
| 173 | progTime[jobs_complete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec)); | ||
| 174 | #endif | ||
| 36 | 175 | ||
| 37 | #define WRITE_TO_FILE if (output){\ | 176 | |
| 177 | #if LITMUS | ||
| 178 | #define WRITE_TO_FILE WRITE_TO_FILE_ITRNL CLEANUP_LITMUS | ||
| 179 | #else | ||
| 180 | #define WRITE_TO_FILE WRITE_TO_FILE_ITRNL | ||
| 181 | #endif | ||
| 182 | |||
| 183 | #define WRITE_TO_FILE_ITRNL if (output){\ | ||
| 38 | munlockall();\ | 184 | munlockall();\ |
| 39 | FILE *fp=fopen(fileName, "a");\ | 185 | FILE *fp=fopen(fileName, "a");\ |
| 40 | if (fp == NULL) {\ | 186 | if (fp == NULL) {\ |
| 41 | perror("Error opening file. \n");\ | 187 | perror("Error opening file. \n");\ |
| 42 | exit(1);\ | 188 | exit(1);\ |
| 43 | }\ | 189 | }\ |
| 44 | for(jobsComplete=0; jobsComplete<maxJobs; jobsComplete++){\ | ||
