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 --- include/litmus.h | 48 ++++++++++++++++++++++++++++++++++---- src/litmus.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/syscalls.c | 10 ++++++++ 3 files changed, 125 insertions(+), 4 deletions(-) diff --git a/include/litmus.h b/include/litmus.h index 955f239..2e26868 100644 --- a/include/litmus.h +++ b/include/litmus.h @@ -51,8 +51,15 @@ int sporadic_task_ns( typedef enum { FMLP_SEM = 0, SRP_SEM = 1, - RSM_SEM = 2, - IKGLP_SEM = 3, + + RSM_MUTEX = 2, + IKGLP_SEM = 3, + KFMLP_SEM = 4, + + IKGLP_SIMPLE_GPU_AFF_OBS = 5, + IKGLP_GPU_AFF_OBS = 6, + KFMLP_SIMPLE_GPU_AFF_OBS = 7, + KFMLP_GPU_AFF_OBS = 8, } obj_type_t; int od_openx(int fd, obj_type_t type, int obj_id, void* config); @@ -76,7 +83,11 @@ int litmus_unlock(int od); */ int litmus_dgl_lock(int* ods, int dgl_size); int litmus_dgl_unlock(int* ods, int dgl_size); - + +/* nvidia graphics cards */ +int register_nv_device(int nv_device_id); +int unregister_nv_device(int nv_device_id); + /* job control*/ int get_job_no(unsigned int* job_no); int wait_for_job_release(unsigned int job_no); @@ -134,6 +145,11 @@ static inline int open_fmlp_sem(int fd, int name) return od_open(fd, FMLP_SEM, name); } +static inline int open_kfmlp_sem(int fd, int name, void* arg) +{ + return od_openx(fd, KFMLP_SEM, name, arg); +} + static inline int open_srp_sem(int fd, int name) { return od_open(fd, SRP_SEM, name); @@ -141,14 +157,38 @@ static inline int open_srp_sem(int fd, int name) static inline int open_rsm_sem(int fd, int name) { - return od_open(fd, RSM_SEM, name); + return od_open(fd, RSM_MUTEX, name); } static inline int open_ikglp_sem(int fd, int name, void *arg) { return od_openx(fd, IKGLP_SEM, name, arg); } + +static inline int open_kfmlp_simple_gpu_aff_obs(int fd, int name, struct gpu_affinity_observer_args *arg) +{ + return od_openx(fd, KFMLP_SIMPLE_GPU_AFF_OBS, name, arg); +} + +static inline int open_kfmlp_gpu_aff_obs(int fd, int name, struct gpu_affinity_observer_args *arg) +{ + return od_openx(fd, KFMLP_GPU_AFF_OBS, name, arg); +} + +static inline int open_ikglp_simple_gpu_aff_obs(int fd, int name, void *arg) +{ + return od_openx(fd, IKGLP_SIMPLE_GPU_AFF_OBS, name, arg); +} + +static inline int open_ikglp_gpu_aff_obs(int fd, int name, void *arg) +{ + return od_openx(fd, IKGLP_GPU_AFF_OBS, name, arg); +} +// takes names "name" and "name+1" +int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware); +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); + /* syscall overhead measuring */ int null_call(cycles_t *timestamp); 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