From b0a383d5bd705e9e38b38e6a3ec00eb53166f1b6 Mon Sep 17 00:00:00 2001 From: Joshua Bakita Date: Tue, 26 May 2020 21:38:52 -0400 Subject: Code cleanup and bugfixes for infrastructure code - Remove unused parameters to extra.h - Use floats to avoid integer overflow when timing long loops - Only include litmus headers and/or MMDC headers if the appropriate define is set in extra.h - Update job parameters to match those used in my PRP experiments --- baseline/Makefile | 63 ++++++++++++++++++++++++++++++------------------ baseline/run_baseline.sh | 7 +++++- baseline/source/extra.h | 55 +++++++++++++++++++++--------------------- dis/original/Makefile | 18 +++++++++++--- 4 files changed, 88 insertions(+), 55 deletions(-) mode change 100644 => 100755 dis/original/Makefile diff --git a/baseline/Makefile b/baseline/Makefile index 53f53f4..ef39b7d 100644 --- a/baseline/Makefile +++ b/baseline/Makefile @@ -1,55 +1,70 @@ -CC = gcc +LIBLITMUS ?= /media/speedy/litmus/liblitmus +CC ?= gcc CFLAGS = -pthread -O2 LDFLAGS = -lrt +COMMON = ./source/extra.h + +# Handle cases where we're also profiling with the MMDC on the i.MX6Q +ifneq ($(shell grep "define MMDC 1" source/extra.h),) + COMMON += /media/speedy/litmus/tools/mmdc/mmdc.c +endif + +# Include all the LITMUS^RT headers if we're using it +ifneq ($(shell grep "define LITMUS 1" source/extra.h),) + CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include + LDFLAGS += -L${LIBLITMUS} -llitmus +endif + all: bin/cjpeg_wrbmp bin/huff_enc bin/gsm_enc bin/dijkstra bin/h264_dec bin/susan bin/adpcm_enc bin/rijndael_dec bin/huff_dec bin/rijndael_enc bin/gsm_dec bin/anagram bin/epic bin/ammunition bin/g723_enc bin/ndes bin/petrinet bin/statemate bin/cjpeg_transupp bin/mpeg2 bin/fmref bin/audiobeam bin/adpcm_dec .PHONY: clean clean: rm bin/cjpeg_wrbmp bin/huff_enc bin/gsm_enc bin/dijkstra bin/h264_dec bin/susan bin/adpcm_enc bin/rijndael_dec bin/huff_dec bin/rijndael_enc bin/gsm_dec bin/anagram bin/epic bin/ammunition bin/g723_enc bin/ndes bin/petrinet bin/statemate bin/cjpeg_transupp bin/mpeg2 bin/fmref bin/audiobeam bin/adpcm_dec -bin/cjpeg_wrbmp: ./source/extra.h ./source/cjpeg_wrbmp/cjpeg_wrbmp.c ./source/cjpeg_wrbmp/input.c +bin/cjpeg_wrbmp: ${COMMON} ./source/cjpeg_wrbmp/cjpeg_wrbmp.c ./source/cjpeg_wrbmp/input.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/huff_enc: ./source/extra.h ./source/huff_enc/huff_enc.c +bin/huff_enc: ${COMMON} ./source/huff_enc/huff_enc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/gsm_enc: ./source/extra.h ./source/gsm_enc/gsm_enc.c +bin/gsm_enc: ${COMMON} ./source/gsm_enc/gsm_enc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/dijkstra: ./source/extra.h ./source/dijkstra/dijkstra.c ./source/dijkstra/input.c +bin/dijkstra: ${COMMON} ./source/dijkstra/dijkstra.c ./source/dijkstra/input.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/h264_dec: ./source/extra.h ./source/h264_dec/h264_dec.c ./source/h264_dec/h264_decinput.c +bin/h264_dec: ${COMMON} ./source/h264_dec/h264_dec.c ./source/h264_dec/h264_decinput.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/susan: ./source/extra.h ./source/susan/input.c ./source/susan/susan.c ./source/susan/wccfile.c ./source/susan/wcclibm.c ./source/susan/wccmalloc.c +bin/susan: ${COMMON} ./source/susan/input.c ./source/susan/susan.c ./source/susan/wccfile.c ./source/susan/wcclibm.c ./source/susan/wccmalloc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/adpcm_enc: ./source/extra.h ./source/adpcm_enc/adpcm_enc.c +bin/adpcm_enc: ${COMMON} ./source/adpcm_enc/adpcm_enc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/rijndael_dec: ./source/extra.h ./source/rijndael_dec/aes.c ./source/rijndael_dec/input_small_enc.c ./source/rijndael_dec/rijndael_dec.c ./source/rijndael_dec/rijndael_dec_libc.c +bin/rijndael_dec: ${COMMON} ./source/rijndael_dec/aes.c ./source/rijndael_dec/input_small_enc.c ./source/rijndael_dec/rijndael_dec.c ./source/rijndael_dec/rijndael_dec_libc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/huff_dec: ./source/extra.h ./source/huff_dec/huff_dec.c +bin/huff_dec: ${COMMON} ./source/huff_dec/huff_dec.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/rijndael_enc: ./source/extra.h ./source/rijndael_enc/aes.c ./source/rijndael_enc/input_small.c ./source/rijndael_enc/rijndael_enc.c ./source/rijndael_enc/rijndael_enc_libc.c +bin/rijndael_enc: ${COMMON} ./source/rijndael_enc/aes.c ./source/rijndael_enc/input_small.c ./source/rijndael_enc/rijndael_enc.c ./source/rijndael_enc/rijndael_enc_libc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/gsm_dec: ./source/extra.h ./source/gsm_dec/gsm_dec.c +bin/gsm_dec: ${COMMON} ./source/gsm_dec/gsm_dec.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/anagram: ./source/extra.h ./source/anagram/anagram.c ./source/anagram/anagram_input.c ./source/anagram/anagram_stdlib.c +bin/anagram: ${COMMON} ./source/anagram/anagram.c ./source/anagram/anagram_input.c ./source/anagram/anagram_stdlib.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/epic: ./source/extra.h ./source/epic/epic.c +bin/epic: ${COMMON} ./source/epic/epic.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/ammunition: ./source/extra.h ./source/ammunition/ammunition.c ./source/ammunition/ammunition_libc.c ./source/ammunition/arithm.c ./source/ammunition/bits.c +bin/ammunition: ${COMMON} ./source/ammunition/ammunition.c ./source/ammunition/ammunition_libc.c ./source/ammunition/arithm.c ./source/ammunition/bits.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/g723_enc: ./source/extra.h ./source/g723_enc/g723_enc.c +bin/g723_enc: ${COMMON} ./source/g723_enc/g723_enc.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/ndes: ./source/extra.h ./source/ndes/ndes.c +bin/ndes: ${COMMON} ./source/ndes/ndes.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/petrinet: ./source/extra.h ./source/petrinet/petrinet.c +bin/petrinet: ${COMMON} ./source/petrinet/petrinet.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/statemate: ./source/extra.h ./source/statemate/statemate.c +bin/statemate: ${COMMON} ./source/statemate/statemate.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/cjpeg_transupp: ./source/extra.h ./source/cjpeg_transupp/cjpeg_transupp.c +bin/cjpeg_transupp: ${COMMON} ./source/cjpeg_transupp/cjpeg_transupp.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/mpeg2: ./source/extra.h ./source/mpeg2/mpeg2.c +bin/mpeg2: ${COMMON} ./source/mpeg2/mpeg2.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/fmref: ./source/extra.h ./source/fmref/fmref.c ./source/fmref/wcclibm.c +bin/fmref: ${COMMON} ./source/fmref/fmref.c ./source/fmref/wcclibm.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/audiobeam: ./source/extra.h ./source/audiobeam/audiobeam.c ./source/audiobeam/audiobeaminput.c ./source/audiobeam/audiobeamlibmalloc.c ./source/audiobeam/audiobeamlibm.c +bin/audiobeam: ${COMMON} ./source/audiobeam/audiobeam.c ./source/audiobeam/audiobeaminput.c ./source/audiobeam/audiobeamlibmalloc.c ./source/audiobeam/audiobeamlibm.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) -bin/adpcm_dec: ./source/extra.h ./source/adpcm_dec/adpcm_dec.c +bin/adpcm_dec: ${COMMON} ./source/adpcm_dec/adpcm_dec.c $(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS) + diff --git a/baseline/run_baseline.sh b/baseline/run_baseline.sh index 7fdc2aa..f7a98fa 100755 --- a/baseline/run_baseline.sh +++ b/baseline/run_baseline.sh @@ -49,7 +49,12 @@ done < $tacleNames num_tests=$(wc -l < $tacleNames) for (( i = 0; i < $num_tests ; i++ )) do - chrt -r 97 taskset -c $core ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core none none $runID 1 none + # Check if we're using LITMUS^RT or not + if grep -q "#define LITMUS 1" source/extra.h; then + ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core $runID 1 + else + chrt -r 97 taskset -c $core ./bin/${tacleProg[$i]} ${tacleProg[$i]} $maxJobs $core $runID 1 + fi echo COMPLETE: ${tacleProg[$i]} done diff --git a/baseline/source/extra.h b/baseline/source/extra.h index df8164f..81ec146 100644 --- a/baseline/source/extra.h +++ b/baseline/source/extra.h @@ -46,30 +46,28 @@ #endif #define LOAD_PARAMS_ITRL \ - if (argc < 9) { \ - printf("Usage: %s <\?\?\?>", argv[0]);\ + if (argc < 6) { \ + printf("Usage: %s \n", argv[0]);\ exit(1);\ }\ char *thisProgram=argv[1];\ int maxJobs=atoi(argv[2]);\ char *thisCore=argv[3];\ - char *otherCore=argv[4];\ - char *otherProgram=argv[5];\ - char *runID=argv[6];\ - int output=atoi(argv[7]);\ + char *runID=argv[4];\ + int output=atoi(argv[5]);\ pid_t killMe;\ struct timespec start, end;\ int jobsComplete;\ int jobs_complete = -1;\ - long progTime[maxJobs*output];\ - memset(progTime, 0, sizeof(long)*maxJobs*output);\ + float progTime[maxJobs*output];\ + memset(progTime, 0, sizeof(float)*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);\ + float mmdc_read[maxJobs];\ + float mmdc_write[maxJobs];\ + memset(mmdc_read, 0, sizeof(float)*maxJobs);\ + memset(mmdc_write, 0, sizeof(float)*maxJobs);\ strcpy(fileName, runID);\ strcat(fileName, ".txt");\ mlockall(MCL_CURRENT || MCL_FUTURE); @@ -102,10 +100,10 @@ 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.budget = ms2ns(3000); \ + res.polling_params.period = ms2ns(3000); \ res.polling_params.offset = 0; \ - res.polling_params.relative_deadline = ms2ns(999); \ + res.polling_params.relative_deadline = ms2ns(3000); \ /* Not 100% sure that we should use periodic polling */ \ if (reservation_create(PERIODIC_POLLING, &res) < 0) { \ perror("Unable to create reservation"); \ @@ -163,14 +161,19 @@ #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));\ + progTime[jobs_complete] = end.tv_sec - start.tv_sec;\ + progTime[jobs_complete] *= 1000000000;\ + progTime[jobs_complete] += end.tv_nsec - start.tv_nsec;\ 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)); + if(jobs_complete>-1) {\ + progTime[jobs_complete] = end.tv_sec - start.tv_sec;\ + progTime[jobs_complete] *= 1000000000;\ + progTime[jobs_complete] += end.tv_nsec - start.tv_nsec;\ + } #endif @@ -188,8 +191,8 @@ exit(1);\ }\ for(int i = 0; i <= jobs_complete; i++){\ - fprintf(fp, "%s %s %s %s %d %ld %s %d %lu %lu \n",\ - thisProgram, otherProgram, thisCore, otherCore, maxJobs,\ + fprintf(fp, "%s none %s none %d %.f %s %d %.f %.f \n",\ + thisProgram, thisCore, maxJobs,\ progTime[i], runID, i, mmdc_read[i], mmdc_write[i]);\ }\ fclose(fp);\ @@ -250,7 +253,7 @@ #define START_LOOP FLUSH_CACHES START_TIMER #endif -#define STOP_LOOP STOP_TIMER SAVE_RESULTS jobs_complete++; +#define STOP_LOOP STOP_TIMER jobs_complete++; SAVE_RESULTS /* @@ -260,12 +263,10 @@ main SET_UP notice that STOP LOOP negates the ++ if outout=0 for (jobsComplete=-1; jobsComplete