diff options
author | Glenn Elliott <gelliott@cs.unc.edu> | 2013-10-31 14:34:59 -0400 |
---|---|---|
committer | Glenn Elliott <gelliott@cs.unc.edu> | 2014-03-03 10:12:28 -0500 |
commit | 35a855f55eeeda1946294c3fc27e0927b6055da2 (patch) | |
tree | d6eb04bc0f28d93926bd5eec914f137971c47c16 /include/litmus/gpu_affinity.h | |
parent | 63a87f4eca47a185eb8e73cb6f34071864c02297 (diff) |
Add GPU affinity tracking.
Adds GPU affinity tracking/prediction routines. Tracking
uses a process-chart method whereby observations over two
standard deviations below or above the average are discarded.
Diffstat (limited to 'include/litmus/gpu_affinity.h')
-rw-r--r-- | include/litmus/gpu_affinity.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/include/litmus/gpu_affinity.h b/include/litmus/gpu_affinity.h new file mode 100644 index 000000000000..de5d1a5ab9e9 --- /dev/null +++ b/include/litmus/gpu_affinity.h | |||
@@ -0,0 +1,58 @@ | |||
1 | #ifndef LITMUS_GPU_AFFINITY_H | ||
2 | #define LITMUS_GPU_AFFINITY_H | ||
3 | |||
4 | #include <litmus/rt_param.h> | ||
5 | #include <litmus/sched_plugin.h> | ||
6 | #include <litmus/litmus.h> | ||
7 | |||
8 | void update_gpu_estimate(struct task_struct* t, lt_t observed); | ||
9 | gpu_migration_dist_t gpu_migration_distance(int a, int b); | ||
10 | |||
11 | static inline void reset_gpu_tracker(struct task_struct* t) | ||
12 | { | ||
13 | t->rt_param.accum_gpu_time = 0; | ||
14 | t->rt_param.gpu_time_stamp = 0; | ||
15 | } | ||
16 | |||
17 | static inline void start_gpu_tracker(struct task_struct* t) | ||
18 | { | ||
19 | lt_t now = litmus_clock(); | ||
20 | if (likely(!t->rt_param.gpu_time_stamp)) | ||
21 | t->rt_param.gpu_time_stamp = now; | ||
22 | } | ||
23 | |||
24 | static inline void stop_gpu_tracker(struct task_struct* t) | ||
25 | { | ||
26 | lt_t now = litmus_clock(); | ||
27 | if (likely(t->rt_param.gpu_time_stamp)) { | ||
28 | t->rt_param.accum_gpu_time += (now - t->rt_param.gpu_time_stamp); | ||
29 | t->rt_param.gpu_time_stamp = 0; | ||
30 | } | ||
31 | } | ||
32 | |||
33 | static inline lt_t get_gpu_time(struct task_struct* t) | ||
34 | { | ||
35 | lt_t accum = t->rt_param.accum_gpu_time; | ||
36 | if (t->rt_param.gpu_time_stamp != 0) | ||
37 | accum += (litmus_clock() - t->rt_param.gpu_time_stamp); | ||
38 | return accum; | ||
39 | } | ||
40 | |||
41 | static inline lt_t get_gpu_estimate(struct task_struct* t, | ||
42 | gpu_migration_dist_t dist) | ||
43 | { | ||
44 | int i; | ||
45 | lt_t val; | ||
46 | |||
47 | if(dist == MIG_NONE) | ||
48 | dist = MIG_LOCAL; | ||
49 | |||
50 | val = t->rt_param.gpu_migration_est[dist].avg; | ||
51 | for(i = dist-1; i >= 0; --i) | ||
52 | if(t->rt_param.gpu_migration_est[i].avg > val) | ||
53 | val = t->rt_param.gpu_migration_est[i].avg; | ||
54 | |||
55 | return ((val > 0) ? val : dist+1); | ||
56 | } | ||
57 | |||
58 | #endif | ||