diff options
| author | leochanj105 <leochanj@live.unc.edu> | 2021-10-29 03:40:38 -0400 |
|---|---|---|
| committer | leochanj105 <leochanj@live.unc.edu> | 2021-10-29 03:40:38 -0400 |
| commit | 92df3dcae6747e4410574e7bf1f14dd1c07c3471 (patch) | |
| tree | fafe9dbe89a4f7f715eee72644b906e698af29dc /extra.h | |
| parent | 895707a76ef3711474eb98c4358588a96926739f (diff) | |
tmp 10/29
Diffstat (limited to 'extra.h')
| -rw-r--r-- | extra.h | 163 |
1 files changed, 101 insertions, 62 deletions
| @@ -30,7 +30,7 @@ extern int sched_getcpu(); | |||
| 30 | #endif | 30 | #endif |
| 31 | 31 | ||
| 32 | // This is a proxy for "case study mode" now | 32 | // This is a proxy for "case study mode" now |
| 33 | #define LITMUS 1 | 33 | #define LITMUS 0 |
| 34 | #define MMDC_PROF 0 | 34 | #define MMDC_PROF 0 |
| 35 | 35 | ||
| 36 | #if LITMUS | 36 | #if LITMUS |
| @@ -44,12 +44,12 @@ extern int sched_getcpu(); | |||
| 44 | // Store state globally so that the job can be outside main() | 44 | // Store state globally so that the job can be outside main() |
| 45 | // Arrays use float as a comprimise between overflow and size | 45 | // Arrays use float as a comprimise between overflow and size |
| 46 | // Paired arrays use long longs as precision is more important for those times | 46 | // Paired arrays use long longs as precision is more important for those times |
| 47 | #ifdef PAIRED | 47 | // #ifdef PAIRED |
| 48 | long long *_rt_start_time; | 48 | long long *_rt_start_time; |
| 49 | long long *_rt_end_time; | 49 | long long *_rt_end_time; |
| 50 | #else | 50 | // #else |
| 51 | float *_rt_exec_time; | 51 | float *_rt_exec_time; |
| 52 | #endif | 52 | // #endif |
| 53 | #if MMDC_PERF | 53 | #if MMDC_PERF |
| 54 | float *_rt_mmdc_read; | 54 | float *_rt_mmdc_read; |
| 55 | float *_rt_mmdc_write; | 55 | float *_rt_mmdc_write; |
| @@ -60,6 +60,8 @@ int _rt_core; | |||
| 60 | int _rt_will_output; | 60 | int _rt_will_output; |
| 61 | struct timespec _rt_start, _rt_end; | 61 | struct timespec _rt_start, _rt_end; |
| 62 | 62 | ||
| 63 | int first_job; | ||
| 64 | |||
| 63 | char *_rt_run_id; | 65 | char *_rt_run_id; |
| 64 | char *_rt_our_prog_name; | 66 | char *_rt_our_prog_name; |
| 65 | char *_rt_other_prog_name; | 67 | char *_rt_other_prog_name; |
| @@ -79,15 +81,18 @@ char _rt_shm_name[_ID_SZ] = "/_libextra_barrier-"; | |||
| 79 | #if LITMUS | 81 | #if LITMUS |
| 80 | lt_t _rt_period; | 82 | lt_t _rt_period; |
| 81 | int _rt_crit; | 83 | int _rt_crit; |
| 84 | lt_t _rt_phase; | ||
| 85 | lt_t _rt_cost; | ||
| 86 | lt_t _rt_deadline; | ||
| 82 | struct control_page *_rt_cp; | 87 | struct control_page *_rt_cp; |
| 83 | #endif | 88 | #endif |
| 84 | 89 | ||
| 85 | static void _rt_load_params_itrl(int argc, char **argv) { | 90 | static void _rt_load_params_itrl(int argc, char **argv) { |
| 86 | #ifdef PAIRED | 91 | #ifdef PAIRED |
| 87 | if (argc != (8 + LITMUS*2) && argc != (9 + LITMUS*2)) { | 92 | if (argc != (8 + LITMUS*5) && argc != (9 + LITMUS*5)) { |
| 88 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <other core> <other name> <runID> <save results?> <pairID>\n", argv[0]); | 93 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <other core> <other name> <runID> <save results?> <pairID>\n", argv[0]); |
| 89 | #else | 94 | #else |
| 90 | if (argc != (6 + LITMUS*2)) { | 95 | if (argc != (6 + LITMUS*5)) { |
| 91 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]); | 96 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]); |
| 92 | #endif /* PAIRED */ | 97 | #endif /* PAIRED */ |
| 93 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); | 98 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); |
| @@ -105,6 +110,9 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 105 | #if LITMUS | 110 | #if LITMUS |
| 106 | fprintf(stderr, " <task period> in ms\n"); | 111 | fprintf(stderr, " <task period> in ms\n"); |
| 107 | fprintf(stderr, " <task criticality level> 0 for Level-A, 1 for Level-B, 2 for Level-C\n"); | 112 | fprintf(stderr, " <task criticality level> 0 for Level-A, 1 for Level-B, 2 for Level-C\n"); |
| 113 | fprintf(stderr, " <task phase> in ms\n"); | ||
| 114 | fprintf(stderr, " <task cost> in ms\n"); | ||
| 115 | fprintf(stderr, " <task deadline> in ms\n"); | ||
| 108 | #endif /* LITMUS */ | 116 | #endif /* LITMUS */ |
| 109 | exit(1); | 117 | exit(1); |
| 110 | } | 118 | } |
| @@ -144,18 +152,23 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 144 | fprintf(stderr, "Run ID is too large! Keep it to less than %d characters.\n", _RT_FILENAME_LEN); | 152 | fprintf(stderr, "Run ID is too large! Keep it to less than %d characters.\n", _RT_FILENAME_LEN); |
| 145 | exit(1); | 153 | exit(1); |
| 146 | } | 154 | } |
| 147 | #ifdef PAIRED | ||
| 148 | // __rt_sem2_name happens to be the longest | ||
| 149 | if (strlen(pairId) + strlen(_rt_sem2_name) > _ID_SZ) { | ||
| 150 | fprintf(stderr, "PairID is too long! Maximum length is %ld characters.\n", _ID_SZ - strlen(_rt_sem2_name)); | ||
| 151 | exit(1); | ||
| 152 | } | ||
| 153 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 155 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
| 154 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 156 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
| 155 | if (!_rt_end_time || !_rt_start_time) { | 157 | if (!_rt_end_time || !_rt_start_time) { |
| 156 | perror("Unable to allocate buffers for execution times"); | 158 | perror("Unable to allocate buffers for execution times"); |
| 157 | exit(1); | 159 | exit(1); |
| 158 | } | 160 | } |
| 161 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | ||
| 162 | if (!_rt_exec_time) { | ||
| 163 | perror("Unable to allocate buffer for execution times"); | ||
| 164 | exit(1); | ||
| 165 | } | ||
| 166 | #ifdef PAIRED | ||
| 167 | // __rt_sem2_name happens to be the longest | ||
| 168 | if (strlen(pairId) + strlen(_rt_sem2_name) > _ID_SZ) { | ||
| 169 | fprintf(stderr, "PairID is too long! Maximum length is %ld characters.\n", _ID_SZ - strlen(_rt_sem2_name)); | ||
| 170 | exit(1); | ||
| 171 | } | ||
| 159 | // Use PairID to create unique semaphore and shared memory paths | 172 | // Use PairID to create unique semaphore and shared memory paths |
| 160 | strcat(_rt_sem1_name, pairId); | 173 | strcat(_rt_sem1_name, pairId); |
| 161 | strcat(_rt_sem2_name, pairId); | 174 | strcat(_rt_sem2_name, pairId); |
| @@ -194,18 +207,18 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 194 | exit(1); | 207 | exit(1); |
| 195 | } | 208 | } |
| 196 | *_rt_barrier = 0; | 209 | *_rt_barrier = 0; |
| 197 | #else | 210 | // #else |
| 198 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | 211 | |
| 199 | if (!_rt_exec_time) { | ||
| 200 | perror("Unable to allocate buffer for execution times"); | ||
| 201 | exit(1); | ||
| 202 | } | ||
| 203 | #endif /* PAIRED */ | 212 | #endif /* PAIRED */ |
| 204 | _rt_jobs_complete = 0; | 213 | _rt_jobs_complete = 0; |
| 214 | first_job = 1; | ||
| 205 | mlockall(MCL_CURRENT || MCL_FUTURE); | 215 | mlockall(MCL_CURRENT || MCL_FUTURE); |
| 206 | #if LITMUS | 216 | #if LITMUS |
| 207 | _rt_period = ms2ns(strtoul(argv[end], NULL, 10)); | 217 | _rt_period = ms2ns(strtoul(argv[end], NULL, 10)); |
| 208 | _rt_crit = atoi(argv[end+1]); | 218 | _rt_crit = atoi(argv[end+1]); |
| 219 | _rt_phase = ms2ns(strtoul(argv[end+2], NULL, 10)); | ||
| 220 | _rt_cost = ms2ns(strtoul(argv[end+3], NULL, 10)); | ||
| 221 | _rt_deadline = ms2ns(strtoul(argv[end+4], NULL, 10)); | ||
| 209 | unsigned int wait = 1; | 222 | unsigned int wait = 1; |
| 210 | if (be_migrate_to_domain(_rt_core) < 0) { | 223 | if (be_migrate_to_domain(_rt_core) < 0) { |
| 211 | perror("Unable to migrate to specified CPU"); | 224 | perror("Unable to migrate to specified CPU"); |
| @@ -214,10 +227,10 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 214 | struct rt_task rt_param; | 227 | struct rt_task rt_param; |
| 215 | init_rt_task_param(&rt_param); | 228 | init_rt_task_param(&rt_param); |
| 216 | // Fake exec cost - this value ignored by the MC^2 scheduler | 229 | // Fake exec cost - this value ignored by the MC^2 scheduler |
| 217 | rt_param.exec_cost = _rt_period; | 230 | rt_param.exec_cost = _rt_cost; |
| 218 | rt_param.period = _rt_period; | 231 | rt_param.period = _rt_period; |
| 219 | rt_param.relative_deadline = 0; | 232 | rt_param.relative_deadline = _rt_deadline; |
| 220 | rt_param.phase = 0; | 233 | rt_param.phase = _rt_phase; |
| 221 | rt_param.priority = LITMUS_LOWEST_PRIORITY; | 234 | rt_param.priority = LITMUS_LOWEST_PRIORITY; |
| 222 | rt_param.cls = _rt_crit; | 235 | rt_param.cls = _rt_crit; |
| 223 | rt_param.budget_policy = NO_ENFORCEMENT; | 236 | rt_param.budget_policy = NO_ENFORCEMENT; |
| @@ -236,10 +249,10 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
| 236 | exit(1); | 249 | exit(1); |
| 237 | } | 250 | } |
| 238 | _rt_cp = get_ctrl_page(); | 251 | _rt_cp = get_ctrl_page(); |
| 239 | if (wait && wait_for_ts_release() != 0) { | 252 | // if (wait && wait_for_ts_release() != 0) { |
| 240 | perror("Unable to wait for taskset release"); | 253 | // perror("Unable to wait for taskset release"); |
| 241 | exit(1); | 254 | // exit(1); |
| 242 | } | 255 | // } |
| 243 | #endif /* LITMUS */ | 256 | #endif /* LITMUS */ |
| 244 | #if MMDC_PROF | 257 | #if MMDC_PROF |
| 245 | SETUP_MMDC | 258 | SETUP_MMDC |
| @@ -337,18 +350,18 @@ static void _rt_save_job_result() { | |||
| 337 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%ld when we only have space for %ld jobs. Exiting...\n", _rt_jobs_complete, _rt_max_jobs); | 350 | fprintf(stderr, "Max jobs setting too small! Trying to record job #%ld when we only have space for %ld jobs. Exiting...\n", _rt_jobs_complete, _rt_max_jobs); |
| 338 | exit(1); | 351 | exit(1); |
| 339 | } | 352 | } |
| 340 | #ifdef PAIRED | 353 | // #ifdef PAIRED |
| 341 | _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; | 354 | _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; |
| 342 | _rt_start_time[_rt_jobs_complete] *= _BILLION; | 355 | _rt_start_time[_rt_jobs_complete] *= _BILLION; |
| 343 | _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; | 356 | _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; |
| 344 | _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; | 357 | _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; |
| 345 | _rt_end_time[_rt_jobs_complete] *= _BILLION; | 358 | _rt_end_time[_rt_jobs_complete] *= _BILLION; |
| 346 | _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; | 359 | _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; |
| 347 | #else | 360 | // #else |
| 348 | _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; | 361 | _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; |
| 349 | _rt_exec_time[_rt_jobs_complete] *= _BILLION; | 362 | _rt_exec_time[_rt_jobs_complete] *= _BILLION; |
| 350 | _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; | 363 | _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; |
| 351 | #endif /* PAIRED */ | 364 | // #endif /* PAIRED */ |
| 352 | #if MMDC_PROF | 365 | #if MMDC_PROF |
| 353 | _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; | 366 | _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; |
| 354 | _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; | 367 | _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; |
| @@ -373,14 +386,14 @@ static void _rt_write_to_file() { | |||
| 373 | for (int i = 0; i < _rt_jobs_complete; i++){ | 386 | for (int i = 0; i < _rt_jobs_complete; i++){ |
| 374 | fprintf(fp, "%s %s %u %s %ld", _rt_our_prog_name, _rt_other_prog_n | ||
