aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-12-12 16:38:55 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-12-12 16:38:55 -0500
commit2ccc2c4cc981a68e703082e6e32f5483ad87b61c (patch)
tree8cc9c32d0909f6543080d3f125df0084ed9f6b82
parent9207c7f874e7754391fdf184187fc763455466c5 (diff)
Use num_online_gpus()
Note that num_online_gpus() merely reports the staticly configured maximum number of available GPUs. Will make dynamic in the future.
-rw-r--r--include/litmus/nvidia_info.h6
-rw-r--r--include/litmus/sched_plugin.h2
-rw-r--r--litmus/nvidia_info.c8
-rw-r--r--litmus/sched_cedf.c27
-rw-r--r--litmus/sched_gsn_edf.c2
-rw-r--r--litmus/sched_plugin.c2
6 files changed, 30 insertions, 17 deletions
diff --git a/include/litmus/nvidia_info.h b/include/litmus/nvidia_info.h
index 6f354c8b00ac..8c2a5524512e 100644
--- a/include/litmus/nvidia_info.h
+++ b/include/litmus/nvidia_info.h
@@ -8,6 +8,10 @@
8 8
9#define NV_DEVICE_NUM CONFIG_NV_DEVICE_NUM 9#define NV_DEVICE_NUM CONFIG_NV_DEVICE_NUM
10 10
11/* TODO: Make this a function that checks the PCIe bus or maybe proc settings */
12#define num_online_gpus() (NV_DEVICE_NUM)
13
14
11/* Functions used for decoding NVIDIA blobs. */ 15/* Functions used for decoding NVIDIA blobs. */
12 16
13int init_nvidia_info(void); 17int init_nvidia_info(void);
@@ -21,8 +25,6 @@ void dump_nvidia_info(const struct tasklet_struct *t);
21u32 get_tasklet_nv_device_num(const struct tasklet_struct *t); 25u32 get_tasklet_nv_device_num(const struct tasklet_struct *t);
22u32 get_work_nv_device_num(const struct work_struct *t); 26u32 get_work_nv_device_num(const struct work_struct *t);
23 27
24
25
26/* Functions for figuring out the priority of GPU-using tasks */ 28/* Functions for figuring out the priority of GPU-using tasks */
27 29
28struct task_struct* get_nv_max_device_owner(u32 target_device_id); 30struct task_struct* get_nv_max_device_owner(u32 target_device_id);
diff --git a/include/litmus/sched_plugin.h b/include/litmus/sched_plugin.h
index cfa218504d75..78004381a6cc 100644
--- a/include/litmus/sched_plugin.h
+++ b/include/litmus/sched_plugin.h
@@ -103,7 +103,7 @@ typedef int (*__higher_prio_t)(struct task_struct* a, comparison_mode_t a_mod,
103#endif 103#endif
104 104
105#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) 105#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
106typedef int (*default_cpu_for_gpu_t)(int gpu, int num_gpus); 106typedef int (*default_cpu_for_gpu_t)(int gpu);
107#endif 107#endif
108 108
109 109
diff --git a/litmus/nvidia_info.c b/litmus/nvidia_info.c
index 0b39dcc84115..7883296a7a18 100644
--- a/litmus/nvidia_info.c
+++ b/litmus/nvidia_info.c
@@ -444,13 +444,13 @@ static int init_nv_device_reg(void)
444 mb(); 444 mb();
445 445
446 446
447 for(i = 0; i < NV_DEVICE_NUM; ++i) { 447 for(i = 0; i < num_online_gpus(); ++i) {
448 raw_spin_lock_init(&NV_DEVICE_REG[i].lock); 448 raw_spin_lock_init(&NV_DEVICE_REG[i].lock);
449 INIT_BINHEAP_HANDLE(&NV_DEVICE_REG[i].owners, gpu_owner_max_priority_order); 449 INIT_BINHEAP_HANDLE(&NV_DEVICE_REG[i].owners, gpu_owner_max_priority_order);
450 450
451#ifdef CONFIG_LITMUS_SOFTIRQD 451#ifdef CONFIG_LITMUS_SOFTIRQD
452 { 452 {
453 int default_cpu = litmus->map_gpu_to_cpu(i, NV_DEVICE_NUM); 453 int default_cpu = litmus->map_gpu_to_cpu(i);
454 454
455 NV_DEVICE_REG[i].callback.func = nvidia_klmirqd_cb; 455 NV_DEVICE_REG[i].callback.func = nvidia_klmirqd_cb;
456 NV_DEVICE_REG[i].callback.arg = (void*)(long long)(i); 456 NV_DEVICE_REG[i].callback.arg = (void*)(long long)(i);
@@ -478,7 +478,7 @@ static int shutdown_nv_device_reg(void)
478 int i; 478 int i;
479 nv_device_registry_t *reg; 479 nv_device_registry_t *reg;
480 480
481 for (i = 0; i < NV_DEVICE_NUM; ++i) { 481 for (i = 0; i < num_online_gpus(); ++i) {
482 482
483 TRACE("Shutting down GPU %d.\n", i); 483 TRACE("Shutting down GPU %d.\n", i);
484 484
@@ -829,7 +829,7 @@ int reg_nv_device(int reg_device_id, int reg_action, struct task_struct *t)
829{ 829{
830 int ret; 830 int ret;
831 831
832 if((reg_device_id < NV_DEVICE_NUM) && (reg_device_id >= 0)) 832 if((reg_device_id < num_online_gpus()) && (reg_device_id >= 0))
833 { 833 {
834 if(reg_action) 834 if(reg_action)
835 ret = __reg_nv_device(reg_device_id, t); 835 ret = __reg_nv_device(reg_device_id, t);
diff --git a/litmus/sched_cedf.c b/litmus/sched_cedf.c
index 35ea1544ce69..46de8041cf59 100644
--- a/litmus/sched_cedf.c
+++ b/litmus/sched_cedf.c
@@ -157,6 +157,13 @@ static unsigned int cluster_size;
157 157
158static int clusters_allocated = 0; 158static int clusters_allocated = 0;
159 159
160
161#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
162static int num_gpu_clusters;
163static unsigned int gpu_cluster_size;
164#endif
165
166
160#ifdef CONFIG_LITMUS_DGL_SUPPORT 167#ifdef CONFIG_LITMUS_DGL_SUPPORT
161static raw_spinlock_t* cedf_get_dgl_spinlock(struct task_struct *t) 168static raw_spinlock_t* cedf_get_dgl_spinlock(struct task_struct *t)
162{ 169{
@@ -1653,18 +1660,11 @@ static void cleanup_cedf(void)
1653} 1660}
1654 1661
1655#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) 1662#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
1656static int cedf_map_gpu_to_cpu(int gpu, int num_gpus) 1663static int cedf_map_gpu_to_cpu(int gpu)
1657{ 1664{
1658 /* TODO: Some sort of smart clustering on the PCIe bus topology */
1659 int num_gpu_clusters = num_clusters;
1660 unsigned int gpu_cluster_size = num_gpus / num_gpu_clusters;
1661 int cpu_cluster = gpu / gpu_cluster_size; 1665 int cpu_cluster = gpu / gpu_cluster_size;
1662 int default_cpu = cedf[cpu_cluster].cpus[0]->cpu; // first CPU in given cluster 1666 int default_cpu = cedf[cpu_cluster].cpus[0]->cpu; // first CPU in given cluster
1663 1667
1664 if(num_gpus % num_gpu_clusters != 0) {
1665 TRACE("GPU clusters are of non-uniform size!\n");
1666 }
1667
1668 TRACE("CPU %d is default for GPU %d interrupt threads.\n", default_cpu, gpu); 1668 TRACE("CPU %d is default for GPU %d interrupt threads.\n", default_cpu, gpu);
1669 1669
1670 return default_cpu; 1670 return default_cpu;
@@ -1717,6 +1717,17 @@ static long cedf_activate_plugin(void)
1717 printk(KERN_INFO "C-EDF: %d cluster(s) of size = %d\n", 1717 printk(KERN_INFO "C-EDF: %d cluster(s) of size = %d\n",
1718 num_clusters, cluster_size); 1718 num_clusters, cluster_size);
1719 1719
1720
1721#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
1722 num_gpu_clusters = min(num_clusters, num_online_gpus());
1723 gpu_cluster_size = num_online_gpus() / num_gpu_clusters;
1724
1725 if (((num_online_gpus() % gpu_cluster_size) != 0) ||
1726 (num_gpu_clusters != num_clusters)) {
1727 printk(KERN_WARNING "C-EDF: GPUs not uniformly distributed among CPU clusters.\n");
1728 }
1729#endif
1730
1720 /* initialize clusters */ 1731 /* initialize clusters */
1721 cedf = kmalloc(num_clusters * sizeof(cedf_domain_t), GFP_ATOMIC); 1732 cedf = kmalloc(num_clusters * sizeof(cedf_domain_t), GFP_ATOMIC);
1722 for (i = 0; i < num_clusters; i++) { 1733 for (i = 0; i < num_clusters; i++) {
diff --git a/litmus/sched_gsn_edf.c b/litmus/sched_gsn_edf.c
index 1b5d8d73dc16..4ac573a6f0f7 100644
--- a/litmus/sched_gsn_edf.c
+++ b/litmus/sched_gsn_edf.c
@@ -1836,7 +1836,7 @@ UNSUPPORTED_AFF_OBS:
1836 1836
1837 1837
1838#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) 1838#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
1839static int gsnedf_map_gpu_to_cpu(int gpu, int num_gpus) 1839static int gsnedf_map_gpu_to_cpu(int gpu)
1840{ 1840{
1841 return 0; // CPU_0 is default in all cases. 1841 return 0; // CPU_0 is default in all cases.
1842} 1842}
diff --git a/litmus/sched_plugin.c b/litmus/sched_plugin.c
index ea89f5fedcab..76ff892122aa 100644
--- a/litmus/sched_plugin.c
+++ b/litmus/sched_plugin.c
@@ -223,7 +223,7 @@ static long litmus_dummy_allocate_aff_obs(struct affinity_observer **aff_obs,
223#endif 223#endif
224 224
225#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD) 225#if defined(CONFIG_LITMUS_NVIDIA) && defined(CONFIG_LITMUS_SOFTIRQD)
226static int litmus_dummy_map_gpu_to_cpu(int gpu, int num_gpus) 226static int litmus_dummy_map_gpu_to_cpu(int gpu)
227{ 227{
228 return 0; 228 return 0;
229} 229}