From a298df4f5c08023b8447e53aba14e062e551e10c Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Sat, 26 May 2012 17:19:39 -0400 Subject: GPUSync RTSS12 liblitmus --- src/litmus.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/syscalls.c | 10 +++++++++ 2 files changed, 81 insertions(+) (limited to 'src') diff --git a/src/litmus.c b/src/litmus.c index d3cc6bb..4f404e2 100644 --- a/src/litmus.c +++ b/src/litmus.c @@ -100,3 +100,74 @@ void exit_litmus(void) { /* nothing to do in current version */ } + +int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware) +{ + int lock_od; + int affinity_od; + int num_replicas; + struct gpu_affinity_observer_args aff_args; + int aff_type; + + // number of GPU tokens + num_replicas = num_gpus * num_simult_users; + + // create the GPU token lock + lock_od = open_kfmlp_sem(fd, name, (void*)&num_replicas); + if(lock_od < 0) { + perror("open_kfmlp_sem"); + return -1; + } + + // create the affinity method to use. + // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS + aff_args.obs.lock_od = lock_od; + aff_args.replica_to_gpu_offset = gpu_offset; + aff_args.nr_simult_users = num_simult_users; + + aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS; + affinity_od = od_openx(fd, aff_type, name+1, &aff_args); + if(affinity_od < 0) { + perror("open_kfmlp_aff"); + return -1; + } + + return lock_od; +} + + + +int 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) +{ + int lock_od; + int affinity_od; + int num_replicas; + struct gpu_affinity_observer_args aff_args; + int aff_type; + + // number of GPU tokens + num_replicas = num_gpus * num_simult_users; + + // create the GPU token lock + lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas); + if(lock_od < 0) { + perror("open_ikglp_sem"); + return -1; + } + + // create the affinity method to use. + // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS + aff_args.obs.lock_od = lock_od; + aff_args.replica_to_gpu_offset = gpu_offset; + aff_args.nr_simult_users = num_simult_users; + aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0; + + aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS; + affinity_od = od_openx(fd, aff_type, name+1, &aff_args); + if(affinity_od < 0) { + perror("open_ikglp_aff"); + return -1; + } + + return lock_od; +} diff --git a/src/syscalls.c b/src/syscalls.c index e0ce941..97d1ebd 100644 --- a/src/syscalls.c +++ b/src/syscalls.c @@ -96,3 +96,13 @@ int null_call(cycles_t *timestamp) { return syscall(__NR_null_call, timestamp); } + +int register_nv_device(int nv_device_id) +{ + return syscall(__NR_register_nv_device, nv_device_id, 1); +} + +int unregister_nv_device(int nv_device_id) +{ + return syscall(__NR_register_nv_device, nv_device_id, 0); +} -- cgit v1.2.2