From 163c440444c74a4e0bbe0a8db3d1ca725413994b Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Thu, 22 Oct 2020 03:17:31 -0400 Subject: Make SD-VBS compatible with run_bench.sh and cleanup SD-VBS: - Run silently - Fix some whitespace errors - Don't duplicate extra.h - Auto-detect if building with LITMUS-RT - Disable result checking - Add helper symlinks Misc: - Remove unused code from libextra - Set some missing rt_param fields in libextra - Disable CSV info dump from computeSMTslowdown.sh - Widen scope of .gitignore on .txt files - Include list of 2MB DIS pair benchmarks and inputs --- .gitignore | 19 +- .../benchmarks/disparity/src/c/script_disparity.c | 18 +- .../localization/src/c/script_localization.c | 20 +- SD-VBS/benchmarks/mser/src/c/script_mser.c | 15 +- .../multi_ncut/src/c/script_multi_ncut.c | 10 +- SD-VBS/benchmarks/sift/src/c/script_sift.c | 9 +- SD-VBS/benchmarks/stitch/src/c/script_stitch.c | 11 +- SD-VBS/benchmarks/svm/src/c/script_svm.c | 23 +- .../src/c/script_texture_synthesis.c | 8 +- SD-VBS/benchmarks/tracking/src/c/script_tracking.c | 13 +- SD-VBS/common/c/extra.h | 479 --------------------- SD-VBS/common/makefiles/Makefile.common | 14 +- SD-VBS/disparity_qcif | 1 + SD-VBS/localization_qcif | 1 + SD-VBS/mser_qcif | 1 + SD-VBS/multi_ncut_qcif | 1 + SD-VBS/sd-vbsNames.txt | 9 + SD-VBS/sift_qcif | 1 + SD-VBS/stitch_qcif | 1 + SD-VBS/svm_qcif | 1 + SD-VBS/texture_synthesis_qcif | 1 + SD-VBS/tracking_qcif | 1 + dis/disPairs2MbInNames.txt | 6 + extra.h | 17 +- smt_analysis/computeSMTslowdown.py | 2 +- 25 files changed, 99 insertions(+), 583 deletions(-) delete mode 100644 SD-VBS/common/c/extra.h create mode 120000 SD-VBS/disparity_qcif create mode 120000 SD-VBS/localization_qcif create mode 120000 SD-VBS/mser_qcif create mode 120000 SD-VBS/multi_ncut_qcif create mode 100644 SD-VBS/sd-vbsNames.txt create mode 120000 SD-VBS/sift_qcif create mode 120000 SD-VBS/stitch_qcif create mode 120000 SD-VBS/svm_qcif create mode 120000 SD-VBS/texture_synthesis_qcif create mode 120000 SD-VBS/tracking_qcif create mode 100644 dis/disPairs2MbInNames.txt diff --git a/.gitignore b/.gitignore index 057a48b..0e0db96 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ *.txt.clean # But not benchmark lists !*Names.txt +# Special-case .txt handling for SD-VBS +**/12345.txt +!SD-VBS/benchmarks/**/*.txt # Ignore DIS benchmark binaries **/field @@ -40,12 +43,7 @@ **/statemate **/susan -# Ignore random walk benchmark -**/random_walk - -# Ignore misc debug and build outputs -**/.gdb_history - +# Ignore SD-VBS binaries **/mser **/multi_ncut **/stitch @@ -56,5 +54,10 @@ **/sift **/localization **/disparity -**/12345.txt -!SD-VBS/**/*.txt + +# Ignore random walk benchmark +**/random_walk + +# Ignore misc temporary files +**/.gdb_history +*.swp diff --git a/SD-VBS/benchmarks/disparity/src/c/script_disparity.c b/SD-VBS/benchmarks/disparity/src/c/script_disparity.c index 431c02c..7d45ada 100644 --- a/SD-VBS/benchmarks/disparity/src/c/script_disparity.c +++ b/SD-VBS/benchmarks/disparity/src/c/script_disparity.c @@ -28,9 +28,7 @@ int main(int argc, char* argv[]) int WIN_SZ=8, SHIFT=64; FILE* fp; - printf("Image 1: "); scanf("%s", im1); - printf("Image 2: "); scanf("%s", im2); #ifdef CHECK char checkFile[100] = "./expected_C.txt"; @@ -86,17 +84,15 @@ int main(int argc, char* argv[]) Iright_moved = iSetArray(paddedRows, paddedCols, 0); range = iMallocHandle(1, 2); - printf("starting..\n"); - for_each_job{ - retDisparity = getDisparity(imleft, imright, WIN_SZ, SHIFT, - minSAD, retDisp, halfWin, - IrightPadded, IleftPadded, Iright_moved, - retSAD, SAD, integralImg, - range); + for_each_job { + retDisparity = getDisparity(imleft, imright, WIN_SZ, SHIFT, + minSAD, retDisp, halfWin, + IrightPadded, IleftPadded, Iright_moved, + retSAD, SAD, integralImg, + range); } - printf("ending\n"); -#ifdef CHECK +#ifdef CHECK /** Self checking - use expected.txt from data directory **/ { int tol, ret=0; diff --git a/SD-VBS/benchmarks/localization/src/c/script_localization.c b/SD-VBS/benchmarks/localization/src/c/script_localization.c index 3392320..ed37132 100644 --- a/SD-VBS/benchmarks/localization/src/c/script_localization.c +++ b/SD-VBS/benchmarks/localization/src/c/script_localization.c @@ -41,7 +41,6 @@ int main(int argc, char* argv[]) char im1[100]; - printf("Input txt File: "); scanf("%s", im1); fid = readFile(im1); @@ -83,11 +82,10 @@ int main(int argc, char* argv[]) F2D *randn; randn = randWrapper(n,3); - printf("start\n"); - for_each_job{ - fResetArray(pos,n, 3, 0); - fResetArray(vel,n, 3, 0); - fResetArray(ones,n,1,1); + for_each_job { + fResetArray(pos,n, 3, 0); + fResetArray(vel,n, 3, 0); + fResetArray(ones,n,1,1); { int j; @@ -95,7 +93,7 @@ int main(int argc, char* argv[]) for(j=0; j<3; j++) subsref(vel, i, j) += subsref(randn,i,j) * STDDEV_ODOVel; - } + } @@ -486,17 +484,15 @@ int main(int argc, char* argv[]) subsref(resultMat,1,icount) = velOut; subsref(resultMat,2,icount) = posOut; } - + fFreeHandle(sData); - - + if (asubsref(isEOF,0) == 1) break; } } - printf("end..\n"); -#ifdef CHECK +#ifdef CHECK // Self checking - use expected.txt from data directory { diff --git a/SD-VBS/benchmarks/mser/src/c/script_mser.c b/SD-VBS/benchmarks/mser/src/c/script_mser.c index d4a98cd..3e98f86 100644 --- a/SD-VBS/benchmarks/mser/src/c/script_mser.c +++ b/SD-VBS/benchmarks/mser/src/c/script_mser.c @@ -33,7 +33,6 @@ int main(int argc, char* argv[]) int ndims, nel, gdl, nmer; - printf("Input Image: "); scanf("%s", im1); I = readImage(im1); @@ -74,19 +73,17 @@ int main(int argc, char* argv[]) out = iMallocHandle(1, nmer); - printf("start\n"); - for_each_job{ + for_each_job { idx = mser(It, 2, subs_pt, nsubs_pt, strides_pt, visited_pt, dims, - joins_pt, + joins_pt, regions_pt, - pairs_pt, + pairs_pt, forest_pt, - acc_pt, ell_pt, + acc_pt, ell_pt, out); } - printf("end..\n"); - -#ifdef CHECK + +#ifdef CHECK /** Self checking - use expected.txt from data directory **/ { int tol, ret=0; diff --git a/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c b/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c index e4f7912..77c6b71 100644 --- a/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c +++ b/SD-VBS/benchmarks/multi_ncut/src/c/script_multi_ncut.c @@ -28,7 +28,6 @@ int main(int argc, char* argv[]) F2D *imageOut, *tempOut; F2D *edgeWeights, *in; - printf("Input image: "); scanf("%s", im1); im = readImage(im1); @@ -50,13 +49,12 @@ int main(int argc, char* argv[]) u->elts = (uni_elt*)malloc(sizeof(uni_elt)*num_vertices); output = iMallocHandle(height, width); - printf("start\n"); for_each_job{ - seg = segment_image(im, sigma, k, min_size, num_ccs, segments, edges, imageOut, tempOut, kernel, edgeWeights, in, ind, u, output); - out = seg; + seg = segment_image(im, sigma, k, min_size, num_ccs, segments, edges, imageOut, tempOut, kernel, edgeWeights, in, ind, u, output); + out = seg; } - printf("end..\n"); -#ifdef CHECK + +#ifdef CHECK /** Self checking - use expected.txt from data directory **/ { int ret=0; diff --git a/SD-VBS/benchmarks/sift/src/c/script_sift.c b/SD-VBS/benchmarks/sift/src/c/script_sift.c index 0b2f106..ab39ae3 100644 --- a/SD-VBS/benchmarks/sift/src/c/script_sift.c +++ b/SD-VBS/benchmarks/sift/src/c/script_sift.c @@ -45,7 +45,6 @@ int main(int argc, char* argv[]) unsigned int* startTime, *endTime, *elapsed; char imSrc[100]; - printf("Input image: "); scanf("%s", imSrc); im = readImage(imSrc); image = fiDeepCopy(im); @@ -53,16 +52,14 @@ int main(int argc, char* argv[]) cols = image->width; - printf("start\n"); for_each_job{ image = fiDeepCopy(im); - normalizeImage(image); + normalizeImage(image); /** Extract sift features for the normalized image **/ frames = sift(image); } - printf("end..\n"); - -#ifdef CHECK + +#ifdef CHECK { int ret=0; float tol = 0.2; diff --git a/SD-VBS/benchmarks/stitch/src/c/script_stitch.c b/SD-VBS/benchmarks/stitch/src/c/script_stitch.c index 00c9a93..b7611f1 100644 --- a/SD-VBS/benchmarks/stitch/src/c/script_stitch.c +++ b/SD-VBS/benchmarks/stitch/src/c/script_stitch.c @@ -16,16 +16,13 @@ int main(int argc, char* argv[]) I2D *Icur; int i, j; char im1[100], im2[100]; - - printf("Input image: "); scanf("%s", im1); Icur = readImage(im1); rows = Icur->height; cols = Icur->width; - - printf("start\n"); - for_each_job{ + + for_each_job { v = harris(Icur); interestPnts = getANMS(v, 24); int1 = fMallocHandle(interestPnts->height, 1); @@ -38,10 +35,8 @@ int main(int argc, char* argv[]) Fcur = extractFeatures(Icur, int1, int2); } - printf("end..\n"); - -#ifdef CHECK +#ifdef CHECK /** Self checking - use expected.txt from data directory **/ { int ret=0; diff --git a/SD-VBS/benchmarks/svm/src/c/script_svm.c b/SD-VBS/benchmarks/svm/src/c/script_svm.c index 62a264d..f1ce963 100644 --- a/SD-VBS/benchmarks/svm/src/c/script_svm.c +++ b/SD-VBS/benchmarks/svm/src/c/script_svm.c @@ -70,24 +70,23 @@ int main(int argc, char* argv[]) #endif - printf("trn file 1: "); + // trn file 1 scanf("%s", im1); - trn1 = readFile(im1); + trn1 = readFile(im1); - printf("trn file 2: "); + // trn file 2 scanf("%s", im1); - trn2 = readFile(im1); + trn2 = readFile(im1); - printf("tst file 1: "); + // tst file 1 scanf("%s", im1); - tst1 = readFile(im1); + tst1 = readFile(im1); - printf("tst file 2: "); + // tst file 2 scanf("%s", im1); - tst2 = readFile(im1); + tst2 = readFile(im1); - printf("start.\n"); - for_each_job{ + for_each_job { alpha = getAlphaFromTrainSet(N, trn1, trn2, iter); a_result = alpha->a_result; b_result = alpha->b_result; @@ -135,8 +134,8 @@ int main(int argc, char* argv[]) asubsref(result,n) = maxs; } } - printf("end..\n"); -#ifdef CHECK + +#ifdef CHECK /** Self checking - use expected.txt from data directory **/ { int ret=0; diff --git a/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c b/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c index 01ddefd..2ebb423 100644 --- a/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c +++ b/SD-VBS/benchmarks/texture_synthesis/src/c/script_texture_synthesis.c @@ -27,11 +27,10 @@ int main(int argc, char **argv) image = fiDeepCopy(im); init_params(data); - printf("start.\n"); - for_each_job{ + for_each_job { create_texture(image, data); } - printf("end..\n"); + #ifdef CHECK { int ret=0; @@ -59,7 +58,6 @@ I2D* parse_flags(int argc, char ** argv) I2D* image; char fileNm[256]; - printf("Input image: "); scanf("%s", fileNm); image = readImage(fileNm); WIDTHin = image->width; @@ -122,7 +120,7 @@ I2D* parse_flags(int argc, char ** argv) localx = 5; localy = 5; #endif - printf("Input size\t\t- (%dx%d)\n", HEIGHTin, WIDTHin); +// printf("Input size\t\t- (%dx%d)\n", HEIGHTin, WIDTHin); // xloopin = malloc(2*WIDTHin*sizeof(int)); // yloopin = malloc(2*HEIGHTin*sizeof(int)); diff --git a/SD-VBS/benchmarks/tracking/src/c/script_tracking.c b/SD-VBS/benchmarks/tracking/src/c/script_tracking.c index bb48ace..2938126 100644 --- a/SD-VBS/benchmarks/tracking/src/c/script_tracking.c +++ b/SD-VBS/benchmarks/tracking/src/c/script_tracking.c @@ -96,19 +96,16 @@ int main(int argc, char* argv[]) for(count=1; count<=counter; count++) { /** Read image **/ - printf("Input image %d: ", count); - scanf("%s", im1); + scanf("%s", im1); images[count - 1] = readImage(im1); - if(count == 1) Ic = readImage(im1); + if(count == 1) Ic = readImage(im1); } rows = Ic->height; cols = Ic->width; - printf("start\n"); - for_each_job{ - + for_each_job { /** IMAGE PRE-PROCESSING **/ /** Blur the image to remove noise - weighted avergae filter **/ @@ -230,8 +227,8 @@ int main(int argc, char* argv[]) fFreeHandle(newpoints); } } - printf("end..\n"); -#ifdef CHECK + +#ifdef CHECK /* Self checking */ { int ret=0; diff --git a/SD-VBS/common/c/extra.h b/SD-VBS/common/c/extra.h deleted file mode 100644 index 8c67b33..0000000 --- a/SD-VBS/common/c/extra.h +++ /dev/null @@ -1,479 +0,0 @@ -/** - * Copyright 2019 Sims Hill Osborne and 2020 Joshua Bakita - * - * This header provides facilities by which to separably run and time TACLeBench - * To use this for paired task timing, define PAIRED (pass CFLAGS=-DPAIRED to make) - **/ -#define _GNU_SOURCE -#include // For O_CREAT and O_RDWR -#include // For sched_yield() -#include // For sem_{open, post, wait}() -#include -#include // For exit() -#include // For strlen() -#include // For mlockall() -#include // For ftruncate() -#include - -// This is only visible if _GNU_SOURCE is defined, and that define does not -// come along to places where this file is included. Address this by manually -// forcing it into the global namespace. -extern int sched_getcpu(); - -// 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 0 -#define MMDC_PROF 0 - -#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 - -// Store state globally so that the job can be outside main() -// Arrays use float as a comprimise between overflow and size -// Paired arrays use long longs as precision is more important for those times -#ifdef PAIRED -long long *_rt_start_time; -long long *_rt_end_time; -#else -float *_rt_exec_time; -#endif -#if MMDC_PERF -float *_rt_mmdc_read; -float *_rt_mmdc_write; -#endif -long _rt_jobs_complete; -long _rt_max_jobs; -int _rt_core; -int _rt_will_output; -struct timespec _rt_start, _rt_end; - -char *_rt_run_id; -char *_rt_our_prog_name; -char *_rt_other_prog_name; -char *_rt_other_core; -#define _RT_FILENAME_LEN 64 -#define _BILLION (1000*1000*1000) -#ifdef PAIRED -char *_rt_barrier; -sem_t *_rt_first_sem, *_rt_second_sem; -int _rt_lock_id; -#endif - -static void _rt_load_params_itrl(int argc, char **argv) { -#ifdef PAIRED - if (argc != 8) { - fprintf(stderr, "Usage: %s ", argv[0]); - fprintf(stderr, " string for logging. Name of this task.\n"); - fprintf(stderr, " integer number of iterations. -1 for infinite.\n"); - fprintf(stderr, " UNUSED. Core is now auto-detected.\n"); - fprintf(stderr, " integer for logging. Core of paired task.\n"); - fprintf(stderr, " string for logging. Name of paired task.\n"); - fprintf(stderr, " string to append with .txt to yield output file name.\n"); - fprintf(stderr, " 1 to indicate this is pair member 1, otherwise pair member 2.\n"); - exit(1); - } -#else - if (argc != 6) { - fprintf(stderr, "Usage: %s \n", argv[0]); - fprintf(stderr, " string for logging. Name of this task.\n"); - fprintf(stderr, " integer number of iterations. -1 for infinite.\n"); - fprintf(stderr, " UNUSED. Core is now auto-detected.\n"); - fprintf(stderr, " string to append with .txt to yield output file name.\n"); - fprintf(stderr, " 1 to save results, 0 to discard.\n"); - exit(1); - } -#endif - _rt_our_prog_name = argv[1]; - _rt_max_jobs = atol(argv[2]); - _rt_core = sched_getcpu(); -#ifdef PAIRED - _rt_other_core = argv[4]; - _rt_other_prog_name = argv[5]; - _rt_run_id = argv[6]; - _rt_lock_id = atoi(argv[7]); - // The paired version doesn't support disabling output (legacy compatibility) - _rt_will_output = 1; -#else - _rt_other_core = "none"; - _rt_other_prog_name = "none"; - _rt_run_id = argv[4]; - _rt_will_output = atoi(argv[5]); -#endif /* PAIRED */ - if (_rt_max_jobs < 0 && _rt_will_output != 0) { - fprintf(stderr, "Infinite loops only supported when _rt_will_output is disabled!\n"); - exit(1); - } - if (strlen(_rt_run_id) + 5 > _RT_FILENAME_LEN) { - fprintf(stderr, "Run ID is too large! Keep it to less than %d characters.\n", _RT_FILENAME_LEN); - exit(1); - } -#ifdef PAIRED - _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); - _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); - if (!_rt_end_time || !_rt_start_time) { - perror("Unable to allocate buffers for execution times"); - exit(1); - } - _rt_first_sem = sem_open("/_libextra_first_sem", O_CREAT, 644, 0); - _rt_second_sem = sem_open("/_libextra_second_sem", O_CREAT, 644, 0); - if (_rt_first_sem == SEM_FAILED || _rt_second_sem == SEM_FAILED) { - perror("Error while creating semaphores"); - exit(1); - } - int barrier_file = shm_open("/_libextra_barrier", O_CREAT | O_RDWR, 644); - if (barrier_file == -1) { - perror("Error while creating shared memory for barrier synchronization"); - exit(1); - } - if (ftruncate(barrier_file, 1) == -1) { - perror("Error while setting size of shared memory for barrier synchronization"); - exit(1); - } - _rt_barrier = mmap(NULL, 1, PROT_WRITE, MAP_SHARED, barrier_file, 0); - if (_rt_barrier == MAP_FAILED) { - perror("Error while mapping shared memory for barrier synchronization"); - exit(1); - } - *_rt_barrier = 0; -#else - _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); - if (!_rt_exec_time) { - perror("Unable to allocate buffer for execution times"); - exit(1); - } -#endif /* PAIRED */ - _rt_jobs_complete = 0; - mlockall(MCL_CURRENT || MCL_FUTURE); -} -#define LOAD_PARAMS_ITRL _rt_load_params_itrl(argc, argv); - -#define SETUP_MMDC \ - _rt_mmdc_read = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ - _rt_mmdc_write = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ - if (!_rt_mmdc_read || !_rt_mmdc_write) {\ - perror("Unable to allocate buffer for MMDC data");\ - exit(1);\ - }\ - 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 wait = 0; \ - if (be_migrate_to_domain(_rt_core) < 0) { \ - perror("Unable to migrate to specified CPU"); \ - 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 = _rt_core; \ - 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 \ - - set_page_color(rt_param.cpu); -#else -#define MC2_SETUP -#endif - -#define CLEANUP_LITMUS \ - if (task_mode(BACKGROUND_TASK) != 0) { \ - perror("Unable to become a real-time task"); \ - exit(1); \ - } \ - -#if __arm__ -// On ARM, manually flush the cache -#define FLUSH_CACHES \ - volatile uint8_t buffer[L2_SIZE * 4]; \ - for (uint32_t j = 0; j < 4; j++) \ - for (uint32_t i = 0; i < L2_SIZE * 4; i += LINE_SIZE) \ - buffer[i]++; -#else -// On x86 call the wbinvld instruction (it's in a kernel module due to it being ring-0) -#define FLUSH_CACHES \ - FILE *fp = fopen("/proc/wbinvd", "r");\ - if (fp == NULL) {\ - perror("Cache flush module interface cannot be opened");\ - exit(1);\ - }\ - char dummy;\ - if (fread(&dummy, 1, 1, fp) == 0) {\ - perror("Unable to access cache flush module interface");\ - exit(1);\ - }\ - fclose(fp); -#endif - -// This semaphore-based synchronization is from Sims -#define FIRST_UNLOCK \ - if (_rt_lock_id == 1) {\ - if (sem_post(_rt_second_sem) != 0) {\ - perror("Unable to unlock second semaphore");\ - exit(1);\ - }\ - } \ - else {\ - if (sem_post(_rt_first_sem) != 0) {\ - perror("Unable to unlock first semaphore");\ - exit(1);\ - }\ - } \ - -#define FIRST_LOCK \ - if (_rt_lock_id == 1) {\ - if (sem_wait(_rt_first_sem) != 0) {\ - perror("Unable to wait on first semaphore");\ - exit(1);\ - }\ - }\ - else {\ - if (sem_wait(_rt_second_sem) != 0) {\ - perror("Unable to wait on second semaphore");\ - exit(1);\ - }\ - } - -// This ensures a very low difference between pair member start times -#define BARRIER_SYNC \ - if (__sync_bool_compare_and_swap(_rt_barrier, 0, 1)) {\ - while (!__sync_bool_compare_and_swap(_rt_barrier, 0, 0)) {};\ - }\ - else {\ - __sync_bool_compare_and_swap(_rt_barrier, 1, 0);\ - } - -// Buffer timing result from a single job -static void _rt_save_job_result() { - if (_rt_jobs_complete >= _rt_max_jobs) { - 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); - exit(1); - } - if (_rt_jobs_complete > -1 && _rt_will_output) { -#ifdef PAIRED - _rt_start_time[_rt_jobs_complete] = _rt_start.tv_sec; - _rt_start_time[_rt_jobs_complete] *= _BILLION; - _rt_start_time[_rt_jobs_complete] += _rt_start.tv_nsec; - _rt_end_time[_rt_jobs_complete] = _rt_end.tv_sec; - _rt_end_time[_rt_jobs_complete] *= _BILLION; - _rt_end_time[_rt_jobs_complete] += _rt_end.tv_nsec; -#else - _rt_exec_time[_rt_jobs_complete] = _rt_end.tv_sec - _rt_start.tv_sec; - _rt_exec_time[_rt_jobs_complete] *= _BILLION; - _rt_exec_time[_rt_jobs_complete] += _rt_end.tv_nsec - _rt_start.tv_nsec; -#endif /* PAIRED */ -#if MMDC_PROF - _rt_mmdc_read[_rt_jobs_complete] = mmdc_res.read_bytes; - _rt_mmdc_write[_rt_jobs_complete] = mmdc_res.write_bytes; -#endif - } -} - -// Save all buffered timing results to disk -static void _rt_write_to_file() { - char fileName[_RT_FILENAME_LEN]; - FILE *fp; - munlockall(); - if (!_rt_will_output) - goto out; - strcpy(fileName, _rt_run_id); - strcat(fileName, ".txt"); - fp = fopen(fileName, "a"); - if (fp == NULL) { - perror("Unable to open output file"); - exit(1); - } - // Baseline output uses a similar format with "none" for unused fields - for (int i = 0; i < _rt_jobs_complete; i++){ - fprintf(fp, "%s %s %u %s %ld", _rt_our_prog_name, _rt_other_prog_name, - _rt_core, _rt_other_core, _rt_max_jobs); -#ifdef PAIRED - // For unclear legacy reasons, paired tasks emit sec and ns separately - fprintf(fp, " %lld %lld %lld %lld", - _rt_start_time[i] / _BILLION, _rt_start_time[i] % _BILLION, - _rt_end_time[i] / _BILLION, _rt_end_time[i] % _BILLION); -#else - fprintf(fp, " %.f", _rt_exec_time[i]); -#endif /* PAIRED */ - fprintf(fp, " %s %d %.f %.f\n", _rt_run_id, i, -#if MMDC_PROF - _rt_mmdc_read[i], _rt_mmdc_write[i]); -#else - 0.0, 0.0); -#endif /* MMDC_PROF */ - } - fclose(fp); -out: -#if LITMUS - CLEANUP_LITMUS -#endif /* LITMUS */ -#ifdef PAIRED - munmap(_rt_barrier, 1); - shm_unlink("/_libextra_barrier"); - sem_unlink("/_libextra_first_sem"); - sem_unlink("/_libextra_second_sem"); - free(_rt_start_time); - free(_rt_end_time); -#else - free(_rt_exec_time); -#endif /* PAIRED */ -#if MMDC_PROF - free(_rt_mmdc_read); - free(_rt_mmdc_write); -#endif /* MMDC_PROF */ -} - -// Start a job -static void _rt_start_loop() { -#if LITMUS - if (sleep_next_period() != 0) { - perror("Unable to sleep for next period"); - } -#else - sched_yield(); -#endif /* LITMUS */ -#ifdef PAIRED - FIRST_UNLOCK - FIRST_LOCK -#endif /* PAIRED */ - FLUSH_CACHES -#ifdef PAIRED - BARRIER_SYNC -#endif /* PAIRED */ -#if MMDC_PROF - /* This disables profiling, resets the counters, clears the overflow bit, and enables profiling */ - start_mmdc_profiling(mmdc); -#endif /* MMDC_PROF */ - clock_gettime(CLOCK_MONOTONIC, &_rt_start); -} - -// Complete a job -static void _rt_stop_loop() { - clock_gettime(CLOCK_MONOTONIC, &_rt_end); -#if MMDC_PROF - /* This freezes the profiling and makes results available */ - pause_mmdc_profiling(mmdc); - get_mmdc_profiling_results(mmdc, &mmdc_res); -#endif /* MMDC_PROF */ - _rt_save_job_result(); - _rt_jobs_complete++; -} - -/****** New API ****** - * Intended structure: - * - * |int main(int argc, char **argv) { - * | SET_UP - * | ... - * | for_each_job { - * | tacleInit(); - * | tacleMain(); - * | } - * | WRITE_TO_FILE - * |} - * - * The main() function must call its parameters argc and argv for SET_UP to be - * able to read them. - * Only SET_UP necessarily has to be in main(). - * - * We use some niche C features, here's a quick explaination: - * 1. The && operator doesn't evaluate the right-hand side of the expression - * unless the left side evaluated to true. We use this to only execute - * _rt_start_loop() when the loop will actually run. - * 2. The comma operator executes the first expression and then throws away the - * result. We use this to call our void function from inside a comparison. - */ -#define for_each_job \ - for (; _rt_jobs_complete < _rt_max_jobs && (_rt_start_loop(),1); \ - _rt_stop_loop()) - -/****** Legacy API ****** - * Intended structure: - * - * |int main(int argc, char **argv) { - * | SET_UP - * | for (jobsComplete=0; jobsComplete1 input images =. # Variables exported from the benchmark specific Makefiles: @@ -55,8 +59,8 @@ COMMON_SRC := $(wildcard $(COMMON_DIR)/*.c) # RULES EXE = -INCLUDES = -I$(COMMON_DIR) -I$(C_DIR) -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include -COMPILE_C = $(CC) $(CFLAGS) $(INCLUDES) -O2 +INCLUDES = -I$(COMMON_DIR) -I$(C_DIR) +COMPILE_C = $(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) -O2 #COMPILE_C = $(CC) $(CFLAGS) -DGENERATE_OUTPUT -lm -O2 $(INCLUDES) COMPILE_G = $(CC) $(CFLAGS) -g -lm $(INCLUDES) COMPILE_PG = $(COMPILE_G) -pg @@ -107,7 +111,7 @@ compile-preload: compile: $(C_SRC) @echo @echo -e "Benchmark\t\t- $(BMARK)" - @$(COMPILE_C) $(COMMON_SRC) $(C_SRC) -lrt -L$(LIBLITMUS) -llitmus -lm -w -o $(BMARK)$(EXE) + @$(COMPILE_C) $(COMMON_SRC) $(C_SRC) -lrt -lm -w -o $(BMARK)$(EXE) compile-prof: $(C_SRC) @echo diff --git a/SD-VBS/disparity_qcif b/SD-VBS/disparity_qcif new file mode 120000 index 0000000..9874fe6 --- /dev/null +++ b/SD-VBS/disparity_qcif @@ -0,0 +1 @@ +benchmarks/disparity/data/qcif/disparity \ No newline at end of file diff --git a/SD-VBS/localization_qcif b/SD-VBS/localization_qcif new file mode 120000 index 0000000..d81d27e --- /dev/null +++ b/SD-VBS/localization_qcif @@ -0,0 +1 @@ +benchmarks/localization/data/qcif/localization \ No newline at end of file diff --git a/SD-VBS/mser_qcif b/SD-VBS/mser_qcif new file mode 120000 index 0000000..8121c92 --- /dev/null +++ b/SD-VBS/mser_qcif @@ -0,0 +1 @@ +benchmarks/mser/data/qcif/mser \ No newline at end of file diff --git a/SD-VBS/multi_ncut_qcif b/SD-VBS/multi_ncut_qcif new file mode 120000 index 0000000..e3f755f --- /dev/null +++ b/SD-VBS/multi_ncut_qcif @@ -0,0 +1 @@ +benchmarks/multi_ncut/data/qcif/multi_ncut \ No newline at end of file diff --git a/SD-VBS/sd-vbsNames.txt b/SD-VBS/sd-vbsNames.txt new file mode 100644 index 0000000..23b168d --- /dev/null +++ b/SD-VBS/sd-vbsNames.txt @@ -0,0 +1,9 @@ +disparity_qcif echo -e "./benchmarks/disparity/data/qcif/1.bmp\\n./benchmarks/disparity/data/qcif/2.bmp" +localization_qcif echo "./benchmarks/localization/data/qcif/1.txt" +mser_qcif echo "./benchmarks/mser/data/qcif/1.bmp" +multi_ncut_qcif echo "./benchmarks/multi_ncut/data/qcif/1.bmp" +sift_qcif echo "./benchmarks/sift/data/qcif/1.bmp" +stitch_qcif echo "./benchmarks/stitch/data/qcif/1.bmp" +svm_qcif echo -e "./benchmarks/svm/data/qcif/d16trn_1.txt\\n./benchmarks/svm/data/qcif/d16trn_2.txt\\n./benchmarks/svm/data/qcif/d16tst_1.txt\\n./benchmarks/svm/data/qcif/d16tst_2.txt" +texture_synthesis_qcif echo "./benchmarks/texture_synthesis/data/qcif/1.bmp" +tracking_qcif echo -e "./benchmarks/tracking/data/qcif/1.bmp\\n./benchmarks/tracking/data/qcif/2.bmp\\n./benchmarks/tracking/data/qcif/3.bmp\\n./benchmarks/tracking/data/qcif/4.bmp" diff --git a/SD-VBS/sift_qcif b/SD-VBS/sift_qcif new file mode 120000 index 0000000..724930b --- /dev/null +++ b/SD-VBS/sift_qcif @@ -0,0 +1 @@ +benchmarks/sift/data/qcif/sift \ No newline at end of file diff --git a/SD-VBS/stitch_qcif b/SD-VBS/stitch_qcif new file mode 120000 index 0000000..0b05a84 --- /dev/null +++ b/SD-VBS/stitch_qcif @@ -0,0 +1 @@ +benchmarks/stitch/data/qcif/stitch \ No newline at end of file diff --git a/SD-VBS/svm_qcif b/SD-VBS/svm_qcif new file mode 120000 index 0000000..a8dc348 --- /dev/null +++ b/SD-VBS/svm_qcif @@ -0,0 +1 @@ +benchmarks/svm/data/qcif/svm \ No newline at end of file diff --git a/SD-VBS/texture_synthesis_qcif b/SD-VBS/texture_synthesis_qcif new file mode 120000 index 0000000..e198a53 --- /dev/null +++ b/SD-VBS/texture_synthesis_qcif @@ -0,0 +1 @@ +benchmarks/texture_synthesis/data/qcif/texture_synthesis \ No newline at end of file diff --git a/SD-VBS/tracking_qcif b/SD-VBS/tracking_qcif new file mode 120000 index 0000000..683191e --- /dev/null +++ b/SD-VBS/tracking_qcif @@ -0,0 +1 @@ +benchmarks/tracking/data/qcif/tracking \ No newline at end of file diff --git a/dis/disPairs2MbInNames.txt b/dis/disPairs2MbInNames.txt new file mode 100644 index 0000000..a45ead4 --- /dev/null +++ b/dis/disPairs2MbInNames.txt @@ -0,0 +1,6 @@ +field_all ./gen_input.py field inputs/Field/in0 2097152 +matrix_all ./gen_input.py matrix inputs/Matrix/in0 2097152 +neighborhood_all ./gen_input.py neighborhood inputs/Neighborhood/in0 2097152 +pointer_all ./gen_input.py pointer inputs/Pointer/in0 2097152 +transitive_all ./gen_input.py transitive inputs/Transitive/in0 2097152 +update_all ./gen_input.py update inputs/Update/in0 2097152 diff --git a/extra.h b/extra.h index 0d700ab..59ae97a 100644 --- a/extra.h +++ b/extra.h @@ -29,8 +29,7 @@ extern int sched_getcpu(); #include #endif -#define LITMUS 1 -#define MC2 0 +#define LITMUS 0 #define MMDC_PROF 0 #if LITMUS @@ -202,10 +201,11 @@ static void _rt_load_params_itrl(int argc, char **argv) { } \ 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.deadline = 0; \ + rt_param.phase = 0; \ + rt_param.priority = LITMUS_LOWEST_PRIORITY; \ rt_param.cls = RT_CLASS_HARD; \ rt_param.release_policy = TASK_PERIODIC; \ rt_param.budget_policy = NO_ENFORCEMENT; \ @@ -218,7 +218,6 @@ static void _rt_load_params_itrl(int argc, char **argv) { perror("init_litmus failed"); \ exit(1); \ } \ - MC2_SETUP \ if (task_mode(LITMUS_RT_TASK) != 0) { \ perror("Unable to become real-time task"); \ exit(1); \ @@ -228,14 +227,6 @@ static void _rt_load_params_itrl(int argc, char **argv) { exit(1); \ } -#if MC2 -#define MC2_SETUP \ - - set_page_color(rt_param.cpu); -#else -#define MC2_SETUP -#endif - #define CLEANUP_LITMUS \ if (task_mode(BACKGROUND_TASK) != 0) { \ perror("Unable to become a real-time task"); \ diff --git a/smt_analysis/computeSMTslowdown.py b/smt_analysis/computeSMTslowdown.py index 2cf58ac..aa7aa21 100755 --- a/smt_analysis/computeSMTslowdown.py +++ b/smt_analysis/computeSMTslowdown.py @@ -247,7 +247,7 @@ print(plt.hist(M_vals_to_plot, bins=10)) ##### BELOW TEXT IS OLD OFFSET CODE (patched) ##### ## This still works, but is hacky and deprecated ## ## PearsonR doesn't work though ## -if not LEVEL_C_ANALYSIS: +if not LEVEL_C_ANALYSIS and False: benchmarkNames = idx_to_name benchmarkCount = len(benchmarkNames) numJobs = len(paired_times[0][0]) -- cgit v1.2.2