aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-05-26 17:19:39 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2012-05-26 17:19:39 -0400
commita298df4f5c08023b8447e53aba14e062e551e10c (patch)
tree66f2a8a2f2c2e3f8949de9d26b44ca6592797201
parentab4d9b18499d87cc63d2dd06999b364e5c809eb9 (diff)
GPUSync RTSS12 liblitmuswip-gpu-rtss12
-rw-r--r--include/litmus.h48
-rw-r--r--src/litmus.c71
-rw-r--r--src/syscalls.c10
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(
51typedef enum { 51typedef enum {
52 FMLP_SEM = 0, 52 FMLP_SEM = 0,
53 SRP_SEM = 1, 53 SRP_SEM = 1,
54 RSM_SEM = 2, 54
55 IKGLP_SEM = 3, 55 RSM_MUTEX = 2,
56 IKGLP_SEM = 3,
57 KFMLP_SEM = 4,
58
59 IKGLP_SIMPLE_GPU_AFF_OBS = 5,
60 IKGLP_GPU_AFF_OBS = 6,
61 KFMLP_SIMPLE_GPU_AFF_OBS = 7,
62 KFMLP_GPU_AFF_OBS = 8,
56} obj_type_t; 63} obj_type_t;
57 64
58int od_openx(int fd, obj_type_t type, int obj_id, void* config); 65int od_openx(int fd, obj_type_t type, int obj_id, void* config);
@@ -76,7 +83,11 @@ int litmus_unlock(int od);
76 */ 83 */
77int litmus_dgl_lock(int* ods, int dgl_size); 84int litmus_dgl_lock(int* ods, int dgl_size);
78int litmus_dgl_unlock(int* ods, int dgl_size); 85int litmus_dgl_unlock(int* ods, int dgl_size);
79 86
87/* nvidia graphics cards */
88int register_nv_device(int nv_device_id);
89int unregister_nv_device(int nv_device_id);
90
80/* job control*/ 91/* job control*/
81int get_job_no(unsigned int* job_no); 92int get_job_no(unsigned int* job_no);
82int wait_for_job_release(unsigned int job_no); 93int wait_for_job_release(unsigned int job_no);
@@ -134,6 +145,11 @@ static inline int open_fmlp_sem(int fd, int name)
134 return od_open(fd, FMLP_SEM, name); 145 return od_open(fd, FMLP_SEM, name);
135} 146}
136 147
148static inline int open_kfmlp_sem(int fd, int name, void* arg)
149{
150 return od_openx(fd, KFMLP_SEM, name, arg);
151}
152
137static inline int open_srp_sem(int fd, int name) 153static inline int open_srp_sem(int fd, int name)
138{ 154{
139 return od_open(fd, SRP_SEM, name); 155 return od_open(fd, SRP_SEM, name);
@@ -141,14 +157,38 @@ static inline int open_srp_sem(int fd, int name)
141 157
142static inline int open_rsm_sem(int fd, int name) 158static inline int open_rsm_sem(int fd, int name)
143{ 159{
144 return od_open(fd, RSM_SEM, name); 160 return od_open(fd, RSM_MUTEX, name);
145} 161}
146 162
147static inline int open_ikglp_sem(int fd, int name, void *arg) 163static inline int open_ikglp_sem(int fd, int name, void *arg)
148{ 164{
149 return od_openx(fd, IKGLP_SEM, name, arg); 165 return od_openx(fd, IKGLP_SEM, name, arg);
150} 166}
167
168static inline int open_kfmlp_simple_gpu_aff_obs(int fd, int name, struct gpu_affinity_observer_args *arg)
169{
170 return od_openx(fd, KFMLP_SIMPLE_GPU_AFF_OBS, name, arg);
171}
172
173static inline int open_kfmlp_gpu_aff_obs(int fd, int name, struct gpu_affinity_observer_args *arg)
174{
175 return od_openx(fd, KFMLP_GPU_AFF_OBS, name, arg);
176}
177
178static inline int open_ikglp_simple_gpu_aff_obs(int fd, int name, void *arg)
179{
180 return od_openx(fd, IKGLP_SIMPLE_GPU_AFF_OBS, name, arg);
181}
182
183static inline int open_ikglp_gpu_aff_obs(int fd, int name, void *arg)
184{
185 return od_openx(fd, IKGLP_GPU_AFF_OBS, name, arg);
186}
151 187
188// takes names "name" and "name+1"
189int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware);
190int 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);
191
152/* syscall overhead measuring */ 192/* syscall overhead measuring */
153int null_call(cycles_t *timestamp); 193int null_call(cycles_t *timestamp);
154 194
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)
100{ 100{
101 /* nothing to do in current version */ 101 /* nothing to do in current version */
102} 102}
103
104int open_kfmlp_gpu_sem(int fd, int name, int num_gpus, int gpu_offset, int num_simult_users, int affinity_aware)
105{
106 int lock_od;
107 int affinity_od;
108 int num_replicas;
109 struct gpu_affinity_observer_args aff_args;
110 int aff_type;
111
112 // number of GPU tokens
113 num_replicas = num_gpus * num_simult_users;
114
115 // create the GPU token lock
116 lock_od = open_kfmlp_sem(fd, name, (void*)&num_replicas);
117 if(lock_od < 0) {
118 perror("open_kfmlp_sem");
119 return -1;
120 }
121
122 // create the affinity method to use.
123 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
124 aff_args.obs.lock_od = lock_od;
125 aff_args.replica_to_gpu_offset = gpu_offset;
126 aff_args.nr_simult_users = num_simult_users;
127
128 aff_type = (affinity_aware) ? KFMLP_GPU_AFF_OBS : KFMLP_SIMPLE_GPU_AFF_OBS;
129 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
130 if(affinity_od < 0) {
131 perror("open_kfmlp_aff");
132 return -1;
133 }
134
135 return lock_od;
136}
137
138
139
140int 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)
141{
142 int lock_od;
143 int affinity_od;
144 int num_replicas;
145 struct gpu_affinity_observer_args aff_args;
146 int aff_type;
147
148 // number of GPU tokens
149 num_replicas = num_gpus * num_simult_users;
150
151 // create the GPU token lock
152 lock_od = open_ikglp_sem(fd, name, (void*)&num_replicas);
153 if(lock_od < 0) {
154 perror("open_ikglp_sem");
155 return -1;
156 }
157
158 // create the affinity method to use.
159 // "no affinity" -> KFMLP_SIMPLE_GPU_AFF_OBS
160 aff_args.obs.lock_od = lock_od;
161 aff_args.replica_to_gpu_offset = gpu_offset;
162 aff_args.nr_simult_users = num_simult_users;
163 aff_args.relaxed_rules = (relax_max_fifo_len) ? 1 : 0;
164
165 aff_type = (affinity_aware) ? IKGLP_GPU_AFF_OBS : IKGLP_SIMPLE_GPU_AFF_OBS;
166 affinity_od = od_openx(fd, aff_type, name+1, &aff_args);
167 if(affinity_od < 0) {
168 perror("open_ikglp_aff");
169 return -1;
170 }
171
172 return lock_od;
173}
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)
96{ 96{
97 return syscall(__NR_null_call, timestamp); 97 return syscall(__NR_null_call, timestamp);
98} 98}
99
100int register_nv_device(int nv_device_id)
101{
102 return syscall(__NR_register_nv_device, nv_device_id, 1);
103}
104
105int unregister_nv_device(int nv_device_id)
106{
107 return syscall(__NR_register_nv_device, nv_device_id, 0);
108}