diff options
author | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 22:46:39 -0400 |
---|---|---|
committer | Joshua Bakita <jbakita@cs.unc.edu> | 2020-10-22 22:51:29 -0400 |
commit | a7c3210215bd1181ae93b23c313941dfb44519fb (patch) | |
tree | 0bb4bf1b40612ec04f677e5163e4ba1f3c500af6 | |
parent | 4f0a2f94f90c1d0cd5f3408a55e68b68a8c74693 (diff) |
Transform LITMUS-RT support in libextra to imply case-study mode
Adds <period> and <criticality level> parameters to benchmarks and
disables cache flushing when compiled with LITMUS. Also fixes build
with LITMUS enabled on yamaha.cs.unc.edu.
Also allows output to be disabled, automatically infers _rt_lock_id,
and allows for a specific pair ID for paired tasks. (The pair ID is
added to all the semaphore and shared memory names, allowing multiple
pairs to run in the system at a time.)
-rw-r--r-- | SD-VBS/common/makefiles/Makefile.common | 4 | ||||
-rw-r--r-- | all_pairs/Makefile | 6 | ||||
-rw-r--r-- | baseline/Makefile | 6 | ||||
-rwxr-xr-x | dis/Makefile | 6 | ||||
-rw-r--r-- | extra.h | 197 |
5 files changed, 128 insertions, 91 deletions
diff --git a/SD-VBS/common/makefiles/Makefile.common b/SD-VBS/common/makefiles/Makefile.common index 9c28cfc..964ece6 100644 --- a/SD-VBS/common/makefiles/Makefile.common +++ b/SD-VBS/common/makefiles/Makefile.common | |||
@@ -30,8 +30,8 @@ BMARK_DIR := $(TOP_DIR)/benchmarks/$(BMARK) | |||
30 | TOOL_DIR := $(TOP_DIR)/tools | 30 | TOOL_DIR := $(TOP_DIR)/tools |
31 | LIBLITMUS ?= /home/litmus/liblitmus | 31 | LIBLITMUS ?= /home/litmus/liblitmus |
32 | ifneq ($(shell grep "define LITMUS 1" ../../../../../extra.h),) | 32 | ifneq ($(shell grep "define LITMUS 1" ../../../../../extra.h),) |
33 | CFLAGS += -I${LIBLITMUS}/include | 33 | override CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include |
34 | LDFLAGS += -L${LIBLITMUS} -llitmus | 34 | override LDFLAGS += -L${LIBLITMUS} -llitmus |
35 | endif | 35 | endif |
36 | #The options set below and specific to each benchmark. Disparity takes 2 input images, whereas Tracking can take any >1 input images =. | 36 | #The options set below and specific to each benchmark. Disparity takes 2 input images, whereas Tracking can take any >1 input images =. |
37 | 37 | ||
diff --git a/all_pairs/Makefile b/all_pairs/Makefile index f0b284e..592db70 100644 --- a/all_pairs/Makefile +++ b/all_pairs/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | LIBLITMUS ?= /media/speedy/litmus/liblitmus | 1 | LIBLITMUS ?= /playpen/mc2/liblitmus |
2 | CC ?= gcc | 2 | CC ?= gcc |
3 | override CFLAGS += -pthread -O2 -I.. -DPAIRED | 3 | override CFLAGS += -pthread -O2 -I.. -DPAIRED |
4 | LDFLAGS += -lrt | 4 | LDFLAGS += -lrt |
@@ -11,8 +11,8 @@ endif | |||
11 | 11 | ||
12 | # Include all the LITMUS^RT headers if we're using it | 12 | # Include all the LITMUS^RT headers if we're using it |
13 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) | 13 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) |
14 | CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include | 14 | override CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include |
15 | LDFLAGS += -L${LIBLITMUS} -llitmus | 15 | override LDFLAGS += -L${LIBLITMUS} -llitmus |
16 | endif | 16 | endif |
17 | 17 | ||
18 | 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 | 18 | 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 |
diff --git a/baseline/Makefile b/baseline/Makefile index d6ab976..a929bc6 100644 --- a/baseline/Makefile +++ b/baseline/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | LIBLITMUS ?= /media/speedy/litmus/liblitmus | 1 | LIBLITMUS ?= /playpen/mc2/liblitmus |
2 | CC ?= gcc | 2 | CC ?= gcc |
3 | override CFLAGS = -pthread -O2 -I.. | 3 | override CFLAGS = -pthread -O2 -I.. |
4 | LDFLAGS = -lrt | 4 | LDFLAGS = -lrt |
@@ -11,8 +11,8 @@ endif | |||
11 | 11 | ||
12 | # Include all the LITMUS^RT headers if we're using it | 12 | # Include all the LITMUS^RT headers if we're using it |
13 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) | 13 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) |
14 | CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include | 14 | override CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include |
15 | LDFLAGS += -L${LIBLITMUS} -llitmus | 15 | override LDFLAGS += -L${LIBLITMUS} -llitmus |
16 | endif | 16 | endif |
17 | 17 | ||
18 | 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 | 18 | 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 |
diff --git a/dis/Makefile b/dis/Makefile index 88fa7c2..d18761b 100755 --- a/dis/Makefile +++ b/dis/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Build the DIS benchmarks with all-pairs or unpaired instrumentation | 2 | # Build the DIS benchmarks with all-pairs or unpaired instrumentation |
3 | # (I know that this Makefile is mildly evil and breaks so many rules | 3 | # (I know that this Makefile is mildly evil and breaks so many rules |
4 | # that a good Makefile should follow. Sorry - at least I have one.) | 4 | # that a good Makefile should follow. Sorry - at least I have one.) |
5 | LIBLITMUS ?= /media/speedy/litmus/liblitmus | 5 | LIBLITMUS ?= /playpen/mc2/liblitmus |
6 | CC ?= gcc | 6 | CC ?= gcc |
7 | override CFLAGS += -pthread -O2 -I.. | 7 | override CFLAGS += -pthread -O2 -I.. |
8 | LDFLAGS = -lrt -lm | 8 | LDFLAGS = -lrt -lm |
@@ -15,8 +15,8 @@ endif | |||
15 | 15 | ||
16 | # Include all the LITMUS^RT headers if we're using it | 16 | # Include all the LITMUS^RT headers if we're using it |
17 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) | 17 | ifneq ($(shell grep "define LITMUS 1" ../extra.h),) |
18 | CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include | 18 | override CFLAGS += -I${LIBLITMUS}/include -I${LIBLITMUS}/arch/arm/include |
19 | LDFLAGS += -L${LIBLITMUS} -llitmus | 19 | override LDFLAGS += -L${LIBLITMUS} -llitmus |
20 | endif | 20 | endif |
21 | 21 | ||
22 | all: baseline | 22 | all: baseline |
@@ -29,6 +29,7 @@ extern int sched_getcpu(); | |||
29 | #include <sys/syscall.h> | 29 | #include <sys/syscall.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | // This is a proxy for "case study mode" now | ||
32 | #define LITMUS 0 | 33 | #define LITMUS 0 |
33 | #define MMDC_PROF 0 | 34 | #define MMDC_PROF 0 |
34 | 35 | ||
@@ -40,18 +41,6 @@ extern int sched_getcpu(); | |||
40 | #include "/media/speedy/litmus/tools/mmdc/mmdc.h" | 41 | #include "/media/speedy/litmus/tools/mmdc/mmdc.h" |
41 | #endif | 42 | #endif |
42 | 43 | ||
43 | #if LITMUS | ||
44 | #define SET_UP LOAD_PARAMS SETUP_LITMUS | ||
45 | #else | ||
46 | #define SET_UP LOAD_PARAMS | ||
47 | #endif | ||
48 | |||
49 | #if MMDC_PROF | ||
50 | #define LOAD_PARAMS LOAD_PARAMS_ITRL SETUP_MMDC | ||
51 | #else | ||
52 | #define LOAD_PARAMS LOAD_PARAMS_ITRL | ||
53 | #endif | ||
54 | |||
55 | // Store state globally so that the job can be outside main() | 44 | // Store state globally so that the job can be outside main() |
56 | // Arrays use float as a comprimise between overflow and size | 45 | // Arrays use float as a comprimise between overflow and size |
57 | // 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 |
@@ -81,47 +70,69 @@ char *_rt_other_core; | |||
81 | char *_rt_barrier; | 70 | char *_rt_barrier; |
82 | sem_t *_rt_first_sem, *_rt_second_sem; | 71 | sem_t *_rt_first_sem, *_rt_second_sem; |
83 | int _rt_lock_id; | 72 | int _rt_lock_id; |
73 | #define _ID_SZ 128 | ||
74 | char _rt_sem1_name[_ID_SZ] = "/_libextra_first_sem-"; | ||
75 | char _rt_sem2_name[_ID_SZ] = "/_libextra_second_sem-"; | ||
76 | char _rt_shm_name[_ID_SZ] = "/_libextra_barrier-"; | ||
77 | #endif /* PAIRED */ | ||
78 | |||
79 | #if LITMUS | ||
80 | long unsigned int _rt_period; | ||
84 | #endif | 81 | #endif |
85 | 82 | ||
86 | static void _rt_load_params_itrl(int argc, char **argv) { | 83 | static void _rt_load_params_itrl(int argc, char **argv) { |
87 | #ifdef PAIRED | 84 | #ifdef PAIRED |
88 | if (argc != 8) { | 85 | if (argc != (8 + LITMUS*2) && argc != (9 + LITMUS*2)) { |
89 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <other core> <other name> <runID> <lockID>", argv[0]); | 86 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <other core> <other name> <runID> <save results?>", argv[0]); |
90 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); | ||
91 | fprintf(stderr, " <loops> integer number of iterations. -1 for infinite.\n"); | ||
92 | fprintf(stderr, " <my core> UNUSED. Core is now auto-detected.\n"); | ||
93 | fprintf(stderr, " <other core> integer for logging. Core of paired task.\n"); | ||
94 | fprintf(stderr, " <other name> string for logging. Name of paired task.\n"); | ||
95 | fprintf(stderr, " <runID> string to append with .txt to yield output file name.\n"); | ||
96 | fprintf(stderr, " <lockID> 1 to indicate this is pair member 1, otherwise pair member 2.\n"); | ||
97 | exit(1); | ||
98 | } | ||
99 | #else | 87 | #else |
100 | if (argc != 6) { | 88 | if (argc != (6 + LITMUS*2)) { |
101 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]); | 89 | fprintf(stderr, "Usage: %s <name> <loops> <my core> <runID> <save results?>\n", argv[0]); |
90 | #endif /* PAIRED */ | ||
102 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); | 91 | fprintf(stderr, " <name> string for logging. Name of this task.\n"); |
103 | fprintf(stderr, " <loops> integer number of iterations. -1 for infinite.\n"); | 92 | fprintf(stderr, " <loops> integer number of iterations. -1 for infinite.\n"); |
104 | fprintf(stderr, " <my core> UNUSED. Core is now auto-detected.\n"); | 93 | fprintf(stderr, " <my core> integer core number. Only used for LITMUS-RT.\n"); |
94 | #ifdef PAIRED | ||
95 | fprintf(stderr, " <other core> integer for logging. Core of paired task.\n"); | ||
96 | fprintf(stderr, " <other name> string for logging. Name of paired task.\n"); | ||
97 | #endif /* PAIRED */ | ||
105 | fprintf(stderr, " <runID> string to append with .txt to yield output file name.\n"); | 98 | fprintf(stderr, " <runID> string to append with .txt to yield output file name.\n"); |
106 | fprintf(stderr, " <save results?> 1 to save results, 0 to discard.\n"); | 99 | fprintf(stderr, " <save results?> 1 to save results, 0 to discard.\n"); |
100 | #ifdef PAIRED | ||
101 | fprintf(stderr, " <pairID> (optional).\n"); | ||
102 | #endif | ||
103 | #if LITMUS | ||
104 | fprintf(stderr, " <task period> in ms\n"); | ||
105 | fprintf(stderr, " <task criticality level> 0 for Level-A, 1 for Level-B, 2 for Level-C\n"); | ||
106 | #endif /* LITMUS */ | ||
107 | exit(1); | 107 | exit(1); |
108 | } | 108 | } |
109 | #endif | ||
110 | _rt_our_prog_name = argv[1]; | 109 | _rt_our_prog_name = argv[1]; |
111 | _rt_max_jobs = atol(argv[2]); | 110 | _rt_max_jobs = atol(argv[2]); |
111 | #if !LITMUS | ||
112 | _rt_core = sched_getcpu(); | 112 | _rt_core = sched_getcpu(); |
113 | #else | ||
114 | _rt_core = atoi(argv[3]); | ||
115 | #endif | ||
113 | #ifdef PAIRED | 116 | #ifdef PAIRED |
114 | _rt_other_core = argv[4]; | 117 | _rt_other_core = argv[4]; |
115 | _rt_other_prog_name = argv[5]; | 118 | _rt_other_prog_name = argv[5]; |
116 | _rt_run_id = argv[6]; | 119 | _rt_run_id = argv[6]; |
117 | _rt_lock_id = atoi(argv[7]); | 120 | _rt_will_output = atoi(argv[7]); |
118 | // The paired version doesn't support disabling output (legacy compatibility) | 121 | char *pairId; |
119 | _rt_will_output = 1; | 122 | int end; |
123 | if (argc > 8) { | ||
124 | pairId = argv[8]; | ||
125 | end = 8; | ||
126 | } else { | ||
127 | pairId = "none"; | ||
128 | end = 9; | ||
129 | } | ||
120 | #else | 130 | #else |
121 | _rt_other_core = "none"; | 131 | _rt_other_core = "none"; |
122 | _rt_other_prog_name = "none"; | 132 | _rt_other_prog_name = "none"; |
123 | _rt_run_id = argv[4]; | 133 | _rt_run_id = argv[4]; |
124 | _rt_will_output = atoi(argv[5]); | 134 | _rt_will_output = atoi(argv[5]); |
135 | int end = 6; | ||
125 | #endif /* PAIRED */ | 136 | #endif /* PAIRED */ |
126 | if (_rt_max_jobs < 0 && _rt_will_output != 0) { | 137 | if (_rt_max_jobs < 0 && _rt_will_output != 0) { |
127 | fprintf(stderr, "Infinite loops only supported when output is disabled!\n"); | 138 | fprintf(stderr, "Infinite loops only supported when output is disabled!\n"); |
@@ -132,32 +143,54 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
132 | exit(1); | 143 | exit(1); |
133 | } | 144 | } |
134 | #ifdef PAIRED | 145 | #ifdef PAIRED |
146 | // __rt_sem2_name happens to be the longest | ||
147 | if (strlen(pairId) + strlen(_rt_sem2_name) > _ID_SZ) { | ||
148 | fprintf(stderr, "PairID is too long! Maximum length is %ld characters.\n", _ID_SZ - strlen(_rt_sem2_name)); | ||
149 | exit(1); | ||
150 | } | ||
135 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 151 | _rt_start_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
136 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); | 152 | _rt_end_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(long long)); |
137 | if (!_rt_end_time || !_rt_start_time) { | 153 | if (!_rt_end_time || !_rt_start_time) { |
138 | perror("Unable to allocate buffers for execution times"); | 154 | perror("Unable to allocate buffers for execution times"); |
139 | exit(1); | 155 | exit(1); |
140 | } | 156 | } |
141 | _rt_first_sem = sem_open("/_libextra_first_sem", O_CREAT, 644, 0); | 157 | // Use PairID to create unique semaphore and shared memory paths |
142 | _rt_second_sem = sem_open("/_libextra_second_sem", O_CREAT, 644, 0); | 158 | strcat(_rt_sem1_name, pairId); |
159 | strcat(_rt_sem2_name, pairId); | ||
160 | strcat(_rt_shm_name, pairId); | ||
161 | _rt_first_sem = sem_open(_rt_sem1_name, O_CREAT, 644, 0); | ||
162 | _rt_second_sem = sem_open(_rt_sem2_name, O_CREAT, 644, 0); | ||
143 | if (_rt_first_sem == SEM_FAILED || _rt_second_sem == SEM_FAILED) { | 163 | if (_rt_first_sem == SEM_FAILED || _rt_second_sem == SEM_FAILED) { |
144 | perror("Error while creating semaphores"); | 164 | perror("Error while creating semaphores"); |
145 | exit(1); | 165 | exit(1); |
146 | } | 166 | } |
147 | int barrier_file = shm_open("/_libextra_barrier", O_CREAT | O_RDWR, 644); | 167 | // Create shared memory for barrier synchronization and infer lock ID |
168 | int barrier_file = shm_open(_rt_shm_name, O_CREAT | O_RDWR | O_EXCL, 644); | ||
169 | if (barrier_file == -1) { | ||
170 | // File already existed - we're the 2nd program and thus lock ID 2 | ||
171 | _rt_lock_id = 2; | ||
172 | barrier_file = shm_open(_rt_shm_name, O_CREAT | O_RDWR, 644); | ||
173 | } else { | ||
174 | _rt_lock_id = 1; | ||
175 | } | ||
148 | if (barrier_file == -1) { | 176 | if (barrier_file == -1) { |
149 | perror("Error while creating shared memory for barrier synchronization"); | 177 | perror("Error while creating shared memory for barrier synchronization"); |
150 | exit(1); | 178 | exit(1); |
151 | } | 179 | } |
152 | if (ftruncate(barrier_file, 1) == -1) { | 180 | if (ftruncate(barrier_file, 2) == -1) { |
153 | perror("Error while setting size of shared memory for barrier synchronization"); | 181 | perror("Error while setting size of shared memory for barrier synchronization"); |
154 | exit(1); | 182 | exit(1); |
155 | } | 183 | } |
156 | _rt_barrier = mmap(NULL, 1, PROT_WRITE, MAP_SHARED, barrier_file, 0); | 184 | _rt_barrier = mmap(NULL, 2, PROT_WRITE, MAP_SHARED, barrier_file, 0); |
157 | if (_rt_barrier == MAP_FAILED) { | 185 | if (_rt_barrier == MAP_FAILED) { |
158 | perror("Error while mapping shared memory for barrier synchronization"); | 186 | perror("Error while mapping shared memory for barrier synchronization"); |
159 | exit(1); | 187 | exit(1); |
160 | } | 188 | } |
189 | // If we're the 2nd user of this barrier, mark it as in-use | ||
190 | if (_rt_lock_id == 2 && !__sync_bool_compare_and_swap(_rt_barrier+1, 0, 1)) { | ||
191 | fprintf(stderr, "Pair ID already in use!\n"); | ||
192 | exit(1); | ||
193 | } | ||
161 | *_rt_barrier = 0; | 194 | *_rt_barrier = 0; |
162 | #else | 195 | #else |
163 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); | 196 | _rt_exec_time = calloc(_rt_max_jobs * _rt_will_output, sizeof(float)); |
@@ -168,8 +201,46 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
168 | #endif /* PAIRED */ | 201 | #endif /* PAIRED */ |
169 | _rt_jobs_complete = 0; | 202 | _rt_jobs_complete = 0; |
170 | mlockall(MCL_CURRENT || MCL_FUTURE); | 203 | mlockall(MCL_CURRENT || MCL_FUTURE); |
204 | #if LITMUS | ||
205 | _rt_period = strtoul(argv[end], NULL, 10); | ||
206 | unsigned int crit = atoi(argv[end+1]); | ||
207 | unsigned int wait = 1; | ||
208 | if (be_migrate_to_domain(_rt_core) < 0) { | ||
209 | perror("Unable to migrate to specified CPU"); | ||
210 | exit(1); | ||
211 | } | ||
212 | struct rt_task rt_param; | ||
213 | init_rt_task_param(&rt_param); | ||
214 | rt_param.exec_cost = 0; // We disable budget enforcement, so this doesn't matter | ||
215 | rt_param.period = ms2ns(_rt_period); | ||
216 | rt_param.relative_deadline = 0; | ||
217 | rt_param.phase = 0; | ||
218 | rt_param.priority = LITMUS_LOWEST_PRIORITY; | ||
219 | rt_param.cls = crit; | ||
220 | rt_param.release_policy = TASK_PERIODIC; | ||
221 | rt_param.budget_policy = NO_ENFORCEMENT; | ||
222 | rt_param.cpu = _rt_core; | ||
223 | if (set_rt_task_param(gettid(), &rt_param) < 0) { | ||
224 | perror("Unable to set real-time parameters"); | ||
225 | exit(1); | ||
226 | } | ||
227 | if (init_litmus() != 0) { | ||
228 | perror("init_litmus failed"); | ||
229 | exit(1); | ||
230 | } | ||
231 | if (task_mode(LITMUS_RT_TASK) != 0) { | ||
232 | perror("Unable to become real-time task"); | ||
233 | exit(1); | ||
234 | } | ||
235 | if (wait && wait_for_ts_release() != 0) { | ||
236 | perror("Unable to wait for taskset release"); | ||
237 | exit(1); | ||
238 | } | ||
239 | #endif /* LITMUS */ | ||
240 | #if MMDC_PROF | ||
241 | SETUP_MMDC | ||
242 | #endif | ||
171 | } | 243 | } |
172 | #define LOAD_PARAMS_ITRL _rt_load_params_itrl(argc, argv); | ||
173 | 244 | ||
174 | #define SETUP_MMDC \ | 245 | #define SETUP_MMDC \ |
175 | _rt_mmdc_read = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ | 246 | _rt_mmdc_read = calloc(_rt_max_jobs * _rt_will_output, sizeof(float));\ |
@@ -193,46 +264,6 @@ static void _rt_load_params_itrl(int argc, char **argv) { | |||
193 | mmdc->madpcr1 = axi_arm1;\ | 264 | mmdc->madpcr1 = axi_arm1;\ |
194 | msync(&(mmdc->madpcr1),4,MS_SYNC); | 265 | msync(&(mmdc->madpcr1),4,MS_SYNC); |
195 | 266 | ||
196 | #define SETUP_LITMUS \ | ||
197 | unsigned int wait = 0; \ | ||
198 | if (be_migrate_to_domain(_rt_core) < 0) { \ | ||
199 | perror("Unable to migrate to specified CPU"); \ | ||
200 | exit(1); \ | ||
201 | } \ | ||
202 | struct rt_task rt_param; \ | ||
203 | init_rt_task_param(&rt_param); \ | ||
204 | rt_param.exec_cost = ms2ns(999); \ | ||
205 | rt_param.period = ms2ns(1000); \ | ||
206 | rt_param.deadline = 0; \ | ||
207 | rt_param.phase = 0; \ | ||
208 | rt_param.priority = LITMUS_LOWEST_PRIORITY; \ | ||
209 | rt_param.cls = RT_CLASS_HARD; \ | ||
210 | rt_param.release_policy = TASK_PERIODIC; \ | ||
211 | rt_param.budget_policy = NO_ENFORCEMENT; \ | ||
212 | rt_param.cpu = _rt_core; \ | ||
213 | if (set_rt_task_param(gettid(), &rt_param) < 0) { \ | ||
214 | perror("Unable to set real-time parameters"); \ | ||
215 | exit(1); \ | ||
216 | } \ | ||
217 | if (init_litmus() != 0) { \ | ||
218 | perror("init_litmus failed"); \ | ||
219 | exit(1); \ | ||
220 | } \ | ||
221 | if (task_mode(LITMUS_RT_TASK) != 0) { \ | ||
222 | perror("Unable to become real-time task"); \ | ||
223 | exit(1); \ | ||
224 | } \ | ||
225 | if (wait && wait_for_ts_release() != 0) { \ | ||
226 | perror("Unable to wait for taskset release"); \ | ||
227 | exit(1); \ | ||
228 | } | ||
229 | |||
230 | #define CLEANUP_LITMUS \ | ||
231 | if (task_mode(BACKGROUND_TASK) != 0) { \ | ||
232 | perror("Unable to become a real-time task"); \ | ||
233 | exit(1); \ | ||
234 | } \ | ||
235 | |||
236 | #if __arm__ | 267 | #if __arm__ |
237 | // On ARM, manually flush the cache | 268 | // On ARM, manually flush the cache |
238 | #define FLUSH_CACHES \ | 269 | #define FLUSH_CACHES \ |
@@ -356,13 +387,16 @@ static void _rt_write_to_file() { | |||
356 | fclose(fp); | 387 | fclose(fp); |
357 | out: | 388 | out: |
358 | #if LITMUS | 389 | #if LITMUS |
359 | CLEANUP_LITMUS | 390 | if (task_mode(BACKGROUND_TASK) != 0) { |
391 | perror("Unable to become a real-time task"); | ||
392 | exit(1); | ||
393 | } | ||
360 | #endif /* LITMUS */ | 394 | #endif /* LITMUS */ |
361 | #ifdef PAIRED | 395 | #ifdef PAIRED |
362 | munmap(_rt_barrier, 1); | 396 | munmap(_rt_barrier, 2); |
363 | shm_unlink("/_libextra_barrier"); | 397 | sem_unlink(_rt_sem1_name); |
364 | sem_unlink("/_libextra_first_sem"); | 398 | sem_unlink(_rt_sem2_name); |
365 | sem_unlink("/_libextra_second_sem"); | 399 | shm_unlink(_rt_shm_name); |
366 | free(_rt_start_time); | 400 | free(_rt_start_time); |
367 | free(_rt_end_time); | 401 | free(_rt_end_time); |
368 | #else | 402 | #else |
@@ -387,7 +421,9 @@ static void _rt_start_loop() { | |||
387 | FIRST_UNLOCK | 421 | FIRST_UNLOCK |
388 | FIRST_LOCK | 422 | FIRST_LOCK |
389 | #endif /* PAIRED */ | 423 | #endif /* PAIRED */ |
424 | #if !LITMUS | ||
390 | FLUSH_CACHES | 425 | FLUSH_CACHES |
426 | #endif | ||
391 | #ifdef PAIRED | 427 | #ifdef PAIRED |
392 | BARRIER_SYNC | 428 | BARRIER_SYNC |
393 | #endif /* PAIRED */ | 429 | #endif /* PAIRED */ |
@@ -457,6 +493,7 @@ static void _rt_stop_loop() { | |||
457 | * able to read them. | 493 | * able to read them. |
458 | */ | 494 | */ |
459 | static int jobsComplete = 0; | 495 | static int jobsComplete = 0; |
496 | #define SET_UP _rt_load_params_itrl(argc, argv); | ||
460 | #define START_LOOP _rt_start_loop(); | 497 | #define START_LOOP _rt_start_loop(); |
461 | #define STOP_LOOP _rt_stop_loop(); | 498 | #define STOP_LOOP _rt_stop_loop(); |
462 | #define WRITE_TO_FILE _rt_write_to_file(); | 499 | #define WRITE_TO_FILE _rt_write_to_file(); |