From 150c1d5ed8541f3a2bfcde3d5f3174b9af4ab4fc Mon Sep 17 00:00:00 2001 From: Glenn Elliott Date: Thu, 20 Sep 2012 18:57:20 -0400 Subject: Generalized GPU cost predictors + EWMA. (untested) --- include/litmus/gpu_affinity.h | 26 ++++++++------- include/litmus/rt_param.h | 77 +++++++++++++++++++++++++++++++++++++------ include/litmus/unistd_32.h | 5 +-- include/litmus/unistd_64.h | 7 ++-- 4 files changed, 88 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/litmus/gpu_affinity.h b/include/litmus/gpu_affinity.h index d64a15cbf2a5..a2abc4c1fd7c 100644 --- a/include/litmus/gpu_affinity.h +++ b/include/litmus/gpu_affinity.h @@ -31,18 +31,20 @@ static inline lt_t get_gpu_time(struct task_struct* t) static inline lt_t get_gpu_estimate(struct task_struct* t, gpu_migration_dist_t dist) { -// int i; -// fpbuf_t temp = _fp_to_integer(t->rt_param.gpu_migration_est[dist].est); -// lt_t val = (temp >= 0) ? temp : 0; // never allow negative estimates... - lt_t val = t->rt_param.gpu_migration_est[dist].avg; - -// WARN_ON(temp < 0); - - // lower-bound a distant migration to be at least equal to the level - // below it. -// for(i = dist-1; (val == 0) && (i >= MIG_LOCAL); --i) { -// val = _fp_to_integer(t->rt_param.gpu_migration_est[i].est); -// } + lt_t val = 0; + + switch(t->rt_param.prediction_mode) { + case SIMPLE_AVG: + case CC_BRUTE_AVG: + case CC_MR_AVG: + val = t->rt_param.gpu_avg_est[dist].center_line; + break; + case SIMPLE_EWMA: + case CC_BRUTE_EWMA: + case CC_MR_EWMA: + val = t->rt_param.gpu_ewma_est[dist].center_line; + break; + } return ((val > 0) ? val : dist+1); } diff --git a/include/litmus/rt_param.h b/include/litmus/rt_param.h index 44f85a366574..6da36f50240d 100644 --- a/include/litmus/rt_param.h +++ b/include/litmus/rt_param.h @@ -41,6 +41,32 @@ typedef enum { PRECISE_SIGNALS, /* budget signals are triggered with hrtimers */ } budget_signal_policy_t; +typedef enum +{ + /* simple - all observations counted */ + SIMPLE_AVG = 1, + SIMPLE_EWMA, + + /* control chart, brute - std deviation fully calculated */ + CC_BRUTE_AVG, + CC_BRUTE_EWMA, + + /* control chart, moving range - std deviation est. from moving range */ + CC_MR_AVG, + CC_MR_EWMA, +} predictor_type; + +typedef struct predictor +{ + predictor_type type; + uint16_t window_size; + + uint8_t sigmas; + uint16_t alpha_num; + uint16_t alpha_denom; +} predictor_t; + + /* We use the common priority interpretation "lower index == higher priority", * which is commonly used in fixed-priority schedulability analysis papers. * So, a numerically lower priority value implies higher scheduling priority, @@ -180,23 +206,48 @@ typedef enum gpu_migration_dist MIG_LAST = MIG_NONE } gpu_migration_dist_t; -typedef struct feedback_est{ - fp_t est; - fp_t accum_err; -} feedback_est_t; - - #define AVG_EST_WINDOW_SIZE 20 -typedef struct avg_est{ - lt_t history[AVG_EST_WINDOW_SIZE]; +typedef struct obs_history +{ + uint16_t window_size; uint16_t count; uint16_t idx; + uint16_t ridx; + + lt_t last_observed; + lt_t *observations; + lt_t *range; +} obs_history_t; + +typedef struct avg_est { + uint8_t sigmas; + + obs_history_t history; + lt_t sum; + lt_t rsum; + lt_t std; - lt_t avg; + lt_t center_line; } avg_est_t; + +typedef struct ewma_est { + uint8_t sigmas; + uint16_t alpha_num; + uint16_t alpha_denom; + + obs_history_t history; + + lt_t rsum; + + lt_t std; + lt_t center_line; +} ewma_est_t; + + + /* RT task parameters for scheduling extensions * These parameters are inherited during clone and therefore must * be explicitly set up before the task set is launched. @@ -243,7 +294,13 @@ struct rt_param { long unsigned int held_gpus; // bitmap of held GPUs. #ifdef CONFIG_LITMUS_AFFINITY_LOCKING - avg_est_t gpu_migration_est[MIG_LAST+1]; +// avg_est_t gpu_migration_est[MIG_LAST+1]; + predictor_type prediction_mode; + union + { + avg_est_t gpu_avg_est[MIG_LAST+1]; + ewma_est_t gpu_ewma_est[MIG_LAST+1]; + }; gpu_migration_dist_t gpu_migration; int last_gpu; diff --git a/include/litmus/unistd_32.h b/include/litmus/unistd_32.h index c86b743408ed..964f02082275 100644 --- a/include/litmus/unistd_32.h +++ b/include/litmus/unistd_32.h @@ -21,6 +21,7 @@ #define __NR_litmus_dgl_unlock __LSC(13) #define __NR_register_nv_device __LSC(14) -#define __NR_set_aux_tasks _LSC(15) +#define __NR_config_gpu_affinity_predictor __LSC(15) +#define __NR_set_aux_tasks _LSC(16) -#define NR_litmus_syscalls 16 +#define NR_litmus_syscalls 17 diff --git a/include/litmus/unistd_64.h b/include/litmus/unistd_64.h index 3825bc129dbd..70be98d4f1e7 100644 --- a/include/litmus/unistd_64.h +++ b/include/litmus/unistd_64.h @@ -35,8 +35,9 @@ __SYSCALL(__NR_litmus_dgl_lock, sys_litmus_dgl_lock) __SYSCALL(__NR_litmus_dgl_unlock, sys_litmus_dgl_unlock) #define __NR_register_nv_device __LSC(14) __SYSCALL(__NR_register_nv_device, sys_register_nv_device) - -#define __NR_set_aux_tasks __LSC(15) +#define __NR_config_gpu_affinity_predictor __LSC(15) +__SYSCALL(__NR_config_gpu_affinity_predictor, sys_config_gpu_affinity_predictor) +#define __NR_set_aux_tasks __LSC(16) __SYSCALL(__NR_set_aux_tasks, sys_set_aux_tasks) -#define NR_litmus_syscalls 16 +#define NR_litmus_syscalls 17 -- cgit v1.2.2