From 4f1aa00f177646b5129304a7d587658aad949946 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Sat, 19 Oct 2019 10:50:23 -0400 Subject: Support LITMUS, MC^2, and alternate benchmarks --- baseline/source/extra.h | 230 ++++++++++++++++++++++++++++++++++++++++-------- 1 file 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 @@ +/** + * Copyright 2019 Sims Hill Osborne and Joshua Bakita + * + * This header provides facilities by which to separably run and time TACLeBench + **/ #include #include #include @@ -5,12 +10,47 @@ #include #include #include +#include -#define L3_CACHE_SIZE (11264*1024) +// These constants correspond to the imx6q-sabredb platform +#define LINE_SIZE 32 +#define L2_SIZE 16*2048*32 +#if __arm__ +#include +#include +#endif +#define LITMUS 1 +#define MC2 1 +#define MMDC_PROF 1 -#define SET_UP char *thisProgram=argv[1];\ +#if LITMUS +#include +#endif + +#if MMDC_PROF +#include "/media/speedy/litmus/tools/mmdc/mmdc.h" +#endif + +#if LITMUS +#define SET_UP LOAD_PARAMS SETUP_LITMUS +#else +#define SET_UP LOAD_PARAMS +#endif + +#if MMDC_PROF +#define LOAD_PARAMS LOAD_PARAMS_ITRL SETUP_MMDC +#else +#define LOAD_PARAMS LOAD_PARAMS_ITRL +#endif + +#define LOAD_PARAMS_ITRL \ + if (argc < 9) { \ + printf("Usage: %s <\?\?\?>", argv[0]);\ + exit(1);\ + }\ + char *thisProgram=argv[1];\ int maxJobs=atoi(argv[2]);\ char *thisCore=argv[3];\ char *otherCore=argv[4];\ @@ -20,37 +60,152 @@ pid_t killMe;\ struct timespec start, end;\ int jobsComplete;\ + int jobs_complete = -1;\ long progTime[maxJobs*output];\ + memset(progTime, 0, sizeof(long)*maxJobs*output);\ char fileName[50];\ char *bigArray;\ int wasteCount;\ + unsigned long mmdc_read[maxJobs];\ + unsigned long mmdc_write[maxJobs];\ + memset(mmdc_read, 0, sizeof(unsigned long)*maxJobs);\ + memset(mmdc_write, 0, sizeof(unsigned long)*maxJobs);\ strcpy(fileName, runID);\ strcat(fileName, ".txt");\ mlockall(MCL_CURRENT || MCL_FUTURE); +#define SETUP_MMDC \ + MMDC_PROFILE_RES_t mmdc_res; \ + memset(&mmdc_res, 0, sizeof(MMDC_PROFILE_RES_t));\ + int fd = open("/dev/mem", O_RDWR, 0);\ + if (fd < 0) {\ + perror("Unable to open /dev/mem");\ + exit(1);\ + }\ + pMMDC_t mmdc = mmap(NULL, 0x4000, PROT_READ | PROT_WRITE, MAP_SHARED, fd, MMDC_P0_IPS_BASE_ADDR);\ + if (mmdc == MAP_FAILED) {\ + perror("Unable to map MMDC address space");\ + exit(1);\ + }\ + mmdc->madpcr1 = axi_arm1;\ + msync(&(mmdc->madpcr1),4,MS_SYNC); + +#define SETUP_LITMUS \ + unsigned int cpu = atoi(thisCore); \ + unsigned int wait = 0; \ + if (be_migrate_to_domain(cpu) < 0) { \ + perror("Unable to migrate to specified CPU"); \ + exit(1); \ + } \ + struct reservation_config res; \ + res.id = gettid(); \ + res.cpu = cpu; \ + res.priority = LITMUS_HIGHEST_PRIORITY; \ + /* we take over half the CPU time (these are ns) */ \ + res.polling_params.budget = ms2ns(999); \ + res.polling_params.period = ms2ns(1000); \ + res.polling_params.offset = 0; \ + res.polling_params.relative_deadline = ms2ns(999); \ + /* Not 100% sure that we should use periodic polling */ \ + if (reservation_create(PERIODIC_POLLING, &res) < 0) { \ + perror("Unable to create reservation"); \ + exit(1); \ + } \ + struct rt_task rt_param; \ + init_rt_task_param(&rt_param); \ + /* Supposedly the next two parameters are irrelevant when reservations are enabled, but I'm leaving them anyway... */ \ + rt_param.exec_cost = ms2ns(999); \ + rt_param.period = ms2ns(1000); \ + rt_param.priority = LITMUS_HIGHEST_PRIORITY; \ + rt_param.cls = RT_CLASS_HARD; \ + rt_param.release_policy = TASK_PERIODIC; \ + rt_param.budget_policy = NO_ENFORCEMENT; \ + rt_param.cpu = cpu; \ + if (set_rt_task_param(gettid(), &rt_param) < 0) { \ + perror("Unable to set real-time parameters"); \ + exit(1); \ + } \ + if (init_litmus() != 0) { \ + perror("init_litmus failed"); \ + exit(1); \ + } \ + MC2_SETUP \ + if (task_mode(LITMUS_RT_TASK) != 0) { \ + perror("Unable to become real-time task"); \ + exit(1); \ + } \ + if (wait && wait_for_ts_release() != 0) { \ + perror("Unable to wait for taskset release"); \ + exit(1); \ + } + +#if MC2 +#define MC2_SETUP \ + struct mc2_task mc2_param; \ + mc2_param.res_id = gettid(); \ + mc2_param.crit = CRIT_LEVEL_A; \ + if (set_mc2_task_param(gettid(), &mc2_param) < 0) { \ + perror("Unable to set MC^2 task params"); \ + exit(1); \ + } \ + set_page_color(rt_param.cpu); +#else +#define MC2_SETUP +#endif -//if output==0, endless loop -//avoids int overflow error with large numbers for background loops +#define CLEANUP_LITMUS \ + if (task_mode(BACKGROUND_TASK) != 0) { \ + perror("Unable to become a real-time task"); \ + exit(1); \ + } \ + reservation_destroy(gettid(), rt_param.cpu); -#define SAVE_RESULTS if(jobsComplete>-1) progTime[jobsComplete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec)); +#if MMDC_PROF +#define SAVE_RESULTS \ + if(jobs_complete>-1) {\ + progTime[jobs_complete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec));\ + mmdc_read[jobs_complete] = mmdc_res.read_bytes;\ + mmdc_write[jobs_complete] = mmdc_res.write_bytes;\ + } +#else +#define SAVE_RESULTS \ + if(jobs_complete>-1)\ + progTime[jobs_complete]=(end.tv_nsec-start.tv_nsec)+(1000000000*(end.tv_sec-start.tv_sec)); +#endif -#define WRITE_TO_FILE if (output){\ + +#if LITMUS +#define WRITE_TO_FILE WRITE_TO_FILE_ITRNL CLEANUP_LITMUS +#else +#define WRITE_TO_FILE WRITE_TO_FILE_ITRNL +#endif + +#define WRITE_TO_FILE_ITRNL if (output){\ munlockall();\ FILE *fp=fopen(fileName, "a");\ if (fp == NULL) {\ perror("Error opening file. \n");\ exit(1);\ }\ - for(jobsComplete=0; jobsComplete