aboutsummaryrefslogtreecommitdiffstats
path: root/include/litmus/gpu_affinity.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/litmus/gpu_affinity.h')
-rw-r--r--include/litmus/gpu_affinity.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/include/litmus/gpu_affinity.h b/include/litmus/gpu_affinity.h
new file mode 100644
index 000000000000..47da725717b0
--- /dev/null
+++ b/include/litmus/gpu_affinity.h
@@ -0,0 +1,66 @@
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
8void update_gpu_estimate(struct task_struct* t, lt_t observed);
9gpu_migration_dist_t gpu_migration_distance(int a, int b);
10
11static inline void reset_gpu_tracker(struct task_struct* t)
12{
13 t->rt_param.accum_gpu_time = 0;
14}
15
16static inline void start_gpu_tracker(struct task_struct* t)
17{
18 t->rt_param.gpu_time_stamp = litmus_clock();
19}
20
21static inline void stop_gpu_tracker(struct task_struct* t)
22{
23 lt_t now = litmus_clock();
24 t->rt_param.accum_gpu_time += (now - t->rt_param.gpu_time_stamp);
25}
26
27static inline lt_t get_gpu_time(struct task_struct* t)
28{
29 return t->rt_param.accum_gpu_time;
30}
31
32static inline lt_t get_gpu_estimate(struct task_struct* t, gpu_migration_dist_t dist)
33{
34 int i;
35 lt_t val;
36
37 if(dist == MIG_NONE) {
38 dist = MIG_LOCAL;
39 }
40
41 val = t->rt_param.gpu_migration_est[dist].avg;
42 for(i = dist-1; i >= 0; --i) {
43 if(t->rt_param.gpu_migration_est[i].avg > val) {
44 val = t->rt_param.gpu_migration_est[i].avg;
45 }
46 }
47
48#if 0
49// int i;
50// fpbuf_t temp = _fp_to_integer(t->rt_param.gpu_migration_est[dist].est);
51// lt_t val = (temp >= 0) ? temp : 0; // never allow negative estimates...
52 lt_t val = t->rt_param.gpu_migration_est[dist].avg;
53
54// WARN_ON(temp < 0);
55
56 // lower-bound a distant migration to be at least equal to the level
57 // below it.
58// for(i = dist-1; (val == 0) && (i >= MIG_LOCAL); --i) {
59// val = _fp_to_integer(t->rt_param.gpu_migration_est[i].est);
60// }
61#endif
62
63 return ((val > 0) ? val : dist+1);
64}
65
66#endif