aboutsummaryrefslogtreecommitdiffstats
path: root/litmus/gpu_affinity.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-05-14 16:51:05 -0400
committerGlenn Elliott <gelliott@cs.unc.edu>2012-05-14 16:51:05 -0400
commit6827bb817faecede51838e2fcc8b6283e54fe872 (patch)
tree00ff42c305926c800e18b13df8440a4de1a1a041 /litmus/gpu_affinity.c
parentaf6eeb156c7da47ff5df03a3da04432c8ac4460c (diff)
Final GPUSync implementation.wip-gpu-rtss12
Diffstat (limited to 'litmus/gpu_affinity.c')
-rw-r--r--litmus/gpu_affinity.c38
1 files changed, 28 insertions, 10 deletions
diff --git a/litmus/gpu_affinity.c b/litmus/gpu_affinity.c
index 70a86bdd9aec..9762be1a085e 100644
--- a/litmus/gpu_affinity.c
+++ b/litmus/gpu_affinity.c
@@ -5,25 +5,32 @@
5#include <litmus/litmus.h> 5#include <litmus/litmus.h>
6#include <litmus/gpu_affinity.h> 6#include <litmus/gpu_affinity.h>
7 7
8#include <litmus/sched_trace.h>
9
8#define OBSERVATION_CAP 2*1e9 10#define OBSERVATION_CAP 2*1e9
9 11
10static void update_estimate(feedback_est_t* fb, fp_t a, fp_t b, lt_t observed) 12static fp_t update_estimate(feedback_est_t* fb, fp_t a, fp_t b, lt_t observed)
11{ 13{
14 fp_t relative_err;
12 fp_t err, new; 15 fp_t err, new;
13 fp_t actual = _integer_to_fp(observed); 16 fp_t actual = _integer_to_fp(observed);
14 17
15 err = _sub(actual, fb->est); 18 err = _sub(actual, fb->est);
16 new = _add(_mul(a, err), _mul(b, fb->accum_err)); 19 new = _add(_mul(a, err), _mul(b, fb->accum_err));
17 20
21 relative_err = _div(err, actual);
22
18 fb->est = new; 23 fb->est = new;
19 fb->accum_err = _add(fb->accum_err, err); 24 fb->accum_err = _add(fb->accum_err, err);
25
26 return relative_err;
20} 27}
21 28
22void update_gpu_estimate(struct task_struct *t, lt_t observed) 29void update_gpu_estimate(struct task_struct *t, lt_t observed)
23{ 30{
24 feedback_est_t *fb = &(tsk_rt(t)->gpu_migration_est[tsk_rt(t)->gpu_migration]); 31 feedback_est_t *fb = &(tsk_rt(t)->gpu_migration_est[tsk_rt(t)->gpu_migration]);
25 32
26 WARN_ON(tsk_rt(t)->gpu_migration > MIG_LAST); 33 BUG_ON(tsk_rt(t)->gpu_migration > MIG_LAST);
27 34
28 if(unlikely(fb->est.val == 0)) { 35 if(unlikely(fb->est.val == 0)) {
29 // kludge-- cap observed values to prevent whacky estimations. 36 // kludge-- cap observed values to prevent whacky estimations.
@@ -40,18 +47,29 @@ void update_gpu_estimate(struct task_struct *t, lt_t observed)
40 fb->accum_err = _div(fb->est, _integer_to_fp(2)); // ...seems to work. 47 fb->accum_err = _div(fb->est, _integer_to_fp(2)); // ...seems to work.
41 } 48 }
42 else { 49 else {
43 update_estimate(fb, 50 fp_t rel_err = update_estimate(fb,
44 tsk_rt(t)->gpu_fb_param_a, 51 tsk_rt(t)->gpu_fb_param_a[tsk_rt(t)->gpu_migration],
45 tsk_rt(t)->gpu_fb_param_b, 52 tsk_rt(t)->gpu_fb_param_b[tsk_rt(t)->gpu_migration],
46 observed); 53 observed);
47 54
48 if(_fp_to_integer(fb->est) <= 0) { 55 if(unlikely(_fp_to_integer(fb->est) <= 0)) {
49 // TODO: talk to Jonathan about how well this works.
50 // Maybe we should average the observed and est instead?
51 TRACE_TASK(t, "Invalid estimate. Patching.\n"); 56 TRACE_TASK(t, "Invalid estimate. Patching.\n");
52 fb->est = _integer_to_fp(observed); 57 fb->est = _integer_to_fp(observed);
53 fb->accum_err = _div(fb->est, _integer_to_fp(2)); // ...seems to work. 58 fb->accum_err = _div(fb->est, _integer_to_fp(2)); // ...seems to work.
54 } 59 }
60 else {
61// struct migration_info mig_info;
62
63 sched_trace_prediction_err(t,
64 &(tsk_rt(t)->gpu_migration),
65 &rel_err);
66
67// mig_info.observed = observed;
68// mig_info.estimated = get_gpu_estimate(t, tsk_rt(t)->gpu_migration);
69// mig_info.distance = tsk_rt(t)->gpu_migration;
70//
71// sched_trace_migration(t, &mig_info);
72 }
55 } 73 }
56 74
57 TRACE_TASK(t, "GPU est update after (dist = %d, obs = %llu): %d.%d\n", 75 TRACE_TASK(t, "GPU est update after (dist = %d, obs = %llu): %d.%d\n",