aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2013-02-28 10:27:11 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2013-02-28 10:27:11 -0500
commitf338b34ea0fb6136ea3895a07161ece030c4b998 (patch)
treea874ad94b1af1dc31254583932c777b8cd1df32c /src
parentaf6f6aa0477fc3887792a3646bfb98d469a695b7 (diff)
Work with wip-2012.3-gpu
Diffstat (limited to 'src')
-rw-r--r--src/litmus.c113
-rw-r--r--src/syscalls.c22
2 files changed, 114 insertions, 21 deletions
diff --git a/src/litmus.c b/src/litmus.c
index c026af0..ba47e45 100644
--- a/src/litmus.c
+++ b/src/litmus.c
@@ -24,7 +24,7 @@ static struct {
24 LP(DPCP), 24 LP(DPCP),
25 LP(PCP), 25 LP(PCP),
26 26
27 {RSM_MUTEX, "RSM"}, 27 {FIFO_MUTEX, "FIFO"},
28 LP(IKGLP), 28 LP(IKGLP),
29 LP(KFMLP), 29 LP(KFMLP),
30 30
@@ -32,6 +32,8 @@ static struct {
32 {IKGLP_GPU_AFF_OBS, "IKGLP-GPU"}, 32 {IKGLP_GPU_AFF_OBS, "IKGLP-GPU"},
33 {KFMLP_SIMPLE_GPU_AFF_OBS, "KFMLP-GPU-SIMPLE"}, 33 {KFMLP_SIMPLE_GPU_AFF_OBS, "KFMLP-GPU-SIMPLE"},
34 {KFMLP_GPU_AFF_OBS, "KFMLP-GPU"}, 34 {KFMLP_GPU_AFF_OBS, "KFMLP-GPU"},
35
36 {PRIOQ_MUTEX, "PRIOQ"},
35}; 37};
36 38
37#define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0])) 39#define NUM_PROTOS (sizeof(protocol)/sizeof(protocol[0]))
@@ -160,19 +162,21 @@ void exit_litmus(void)
160 /* nothing to do in current version */ 162 /* nothing to do in current version */
161} 163}
162 164
163int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware) 165int open_kfmlp_gpu_sem(int fd, int name,
166 unsigned int num_gpus, unsigned int gpu_offset, unsigned int rho,
167 int affinity_aware)
164{ 168{
165 int lock_od; 169 int lock_od;
166 int affinity_od; 170 int affinity_od;
167 int num_replicas; 171 unsigned int num_replicas;
168 struct gpu_affinity_observer_args aff_args; 172 struct gpu_affinity_observer_args aff_args;
169 int aff_type; 173 int aff_type;
170 174
171 // number of GPU tokens 175 // number of GPU tokens
172 num_replicas = num_gpus * num_simult_users; 176 num_replicas = num_gpus * rho;
173 177
174 // create the GPU token lock 178 // create the GPU token lock
175 lock_od = open_kfmlp_sem(fd, name, (void*)&num_replicas); 179 lock_od = open_kfmlp_sem(fd, name, num_replicas);
176 if(lock_od < 0) { 180 if(lock_od < 0) {
177 perror("open_kfmlp_sem"); 181 perror("open_kfmlp_sem");
178 return -1; 182 return -1;
@@ -182,7 +186,7 @@ int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_s
182 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS 186 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
183 aff_args.obs.lock_od = lock_od; 187 aff_args.obs.lock_od = lock_od;
184 aff_args.replica_to_gpu_offset = gpu_offset; 188 aff_args.replica_to_gpu_offset = gpu_offset;
185 aff_args.nr_simult_users = num_simult_users; 189 aff_args.rho = rho;
186 190
187 aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS; 191 aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS;
188 affinity_od = od_openx(fd, aff_type, name+1, &aff_args); 192 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
@@ -195,38 +199,107 @@ int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_s
195} 199}
196 200
197 201
202//int open_ikglp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int rho, int affinity_aware, int relax_max_fifo_len)
203//{
204// int lock_od;
205// int affinity_od;
206// int num_replicas;
207// struct gpu_affinity_observer_args aff_args;
208// int aff_type;
209//
210// // number of GPU tokens
211// num_replicas = num_gpus * num_simult_users;
212//
213// // create the GPU token lock
214// lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas);
215// if(lock_od < 0) {
216// perror("open_ikglp_sem");
217// return -1;
218// }
219//
220// // create the affinity method to use.
221// // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
222// aff_args.obs.lock_od = lock_od;
223// aff_args.replica_to_gpu_offset = gpu_offset;
224// aff_args.nr_simult_users = num_simult_users;
225// aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0;
226//
227// aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS;
228// affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
229// if(affinity_od < 0) {
230// perror("open_ikglp_aff");
231// return -1;
232// }
233//
234// return lock_od;
235//}
236
237
238
239
240int open_ikglp_sem(int fd, int name, unsigned int nr_replicas)
241{
242 struct ikglp_args args = {
243 .nr_replicas = nr_replicas,
244 .max_in_fifos = IKGLP_M_IN_FIFOS,
245 .max_fifo_len = IKGLP_OPTIMAL_FIFO_LEN};
246
247 return od_openx(fd, IKGLP_SEM, name, &args);
248}
249
250
198 251
199int open_ikglp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware, int relax_max_fifo_len) 252int open_gpusync_token_lock(int fd, int name,
253 unsigned int num_gpus, unsigned int gpu_offset,
254 unsigned int rho, unsigned int max_in_fifos,
255 unsigned int max_fifo_len,
256 int enable_affinity_heuristics)
200{ 257{
201 int lock_od; 258 int lock_od;
202 int affinity_od; 259 int affinity_od;
203 int num_replicas; 260
261 struct ikglp_args args = {
262 .nr_replicas = num_gpus*rho,
263 .max_in_fifos = max_in_fifos,
264 .max_fifo_len = max_fifo_len,
265 };
204 struct gpu_affinity_observer_args aff_args; 266 struct gpu_affinity_observer_args aff_args;
205 int aff_type; 267 int aff_type;
206
207 // number of GPU tokens
208 num_replicas = num_gpus * num_simult_users;
209 268
210 // create the GPU token lock 269 if (!num_gpus || !rho) {
211 lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas); 270 perror("open_gpusync_sem");
271 return -1;
272 }
273
274 if ((max_in_fifos != IKGLP_UNLIMITED_IN_FIFOS) &&
275 (max_fifo_len != IKGLP_UNLIMITED_FIFO_LEN) &&
276 (max_in_fifos > args.nr_replicas * max_fifo_len)) {
277 perror("open_gpusync_sem");
278 return(-1);
279 }
280
281 lock_od = od_openx(fd, IKGLP_SEM, name, &args);
212 if(lock_od < 0) { 282 if(lock_od < 0) {
213 perror("open_ikglp_sem"); 283 perror("open_gpusync_sem");
214 return -1; 284 return -1;
215 } 285 }
216 286
217 // create the affinity method to use. 287 // create the affinity method to use.
218 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
219 aff_args.obs.lock_od = lock_od; 288 aff_args.obs.lock_od = lock_od;
220 aff_args.replica_to_gpu_offset = gpu_offset; 289 aff_args.replica_to_gpu_offset = gpu_offset;
221 aff_args.nr_simult_users = num_simult_users; 290 aff_args.rho = rho;
222 aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0; 291 aff_args.relaxed_rules = (max_fifo_len == IKGLP_UNLIMITED_FIFO_LEN) ? 1 : 0;
223 292
224 aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS; 293 aff_type = (enable_affinity_heuristics) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS;
225 affinity_od = od_openx(fd, aff_type, name+1, &aff_args); 294 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
226 if(affinity_od < 0) { 295 if(affinity_od < 0) {
227 perror("open_ikglp_aff"); 296 perror("open_gpusync_affinity");
228 return -1; 297 return -1;
229 } 298 }
230 299
231 return lock_od; 300 return lock_od;
232} 301}
302
303
304
305
diff --git a/src/syscalls.c b/src/syscalls.c
index 6308dac..12fe485 100644
--- a/src/syscalls.c
+++ b/src/syscalls.c
@@ -82,9 +82,19 @@ int sched_getscheduler(pid_t pid)
82 return syscall(__NR_sched_getscheduler, pid); 82 return syscall(__NR_sched_getscheduler, pid);
83} 83}
84 84
85static int __wait_for_ts_release(struct timespec *release)
86{
87 return syscall(__NR_wait_for_ts_release, release);
88}
89
85int wait_for_ts_release(void) 90int wait_for_ts_release(void)
86{ 91{
87 return syscall(__NR_wait_for_ts_release); 92 return __wait_for_ts_release(NULL);
93}
94
95int wait_for_ts_release2(struct timespec *release)
96{
97 return __wait_for_ts_release(release);
88} 98}
89 99
90int release_ts(lt_t *delay) 100int release_ts(lt_t *delay)
@@ -129,4 +139,14 @@ int inject_completion(unsigned int job_no)
129 return syscall(__NR_sched_trace_event, ST_INJECT_COMPLETION, &args); 139 return syscall(__NR_sched_trace_event, ST_INJECT_COMPLETION, &args);
130} 140}
131 141
142int inject_gpu_migration(unsigned int to, unsigned int from)
143{
144 struct st_inject_args args = {.to = to, .from = from};
145 return syscall(__NR_sched_trace_event, ST_INJECT_MIGRATION, &args);
146}
132 147
148int __inject_action(unsigned int action)
149{
150 struct st_inject_args args = {.action = action};
151 return syscall(__NR_sched_trace_event, ST_INJECT_ACTION, &args);
152}