aboutsummaryrefslogtreecommitdiffstats
path: root/native/src
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-10-02 06:10:13 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-02-12 06:55:16 -0500
commit5b01c84940965f053f5eacd401a132a2008dac71 (patch)
tree0f5300f1aaef06e30e15147b42e5f66d2745f1d0 /native/src
parent9a62e1d8e573973a5a094d9e9458fd444aed1231 (diff)
Add generic LP support for shared-memory protocols
Diffstat (limited to 'native/src')
-rw-r--r--native/src/blocking/linprog/lp_common.cpp81
1 files changed, 81 insertions, 0 deletions
diff --git a/native/src/blocking/linprog/lp_common.cpp b/native/src/blocking/linprog/lp_common.cpp
index eca5cc2..a7bb1b5 100644
--- a/native/src/blocking/linprog/lp_common.cpp
+++ b/native/src/blocking/linprog/lp_common.cpp
@@ -66,6 +66,59 @@ void set_blocking_objective(
66#endif 66#endif
67} 67}
68 68
69// This version is for partitioned shared-memory protocols where each
70// task executes its critical section on its assigned processor.
71void set_blocking_objective_part_shm(
72 VarMapper& vars,
73 const ResourceSharingInfo& info,
74 const TaskInfo& ti,
75 LinearProgram& lp,
76 LinearExpression *local_obj,
77 LinearExpression *remote_obj)
78{
79 LinearExpression *obj;
80
81 obj = lp.get_objective();
82
83 foreach_task_except(info.get_tasks(), ti, tx)
84 {
85 unsigned int t = tx->get_id();
86 bool local = tx->get_cluster() == ti.get_cluster();
87
88 foreach(tx->get_requests(), request)
89 {
90 unsigned int q = request->get_resource_id();
91 double length = request->get_request_length();;
92
93 foreach_request_instance(*request, ti, v)
94 {
95 unsigned int var_id;
96
97 var_id = vars.lookup(t, q, v, BLOCKING_DIRECT);
98 obj->add_term(length, var_id);
99 if (local && local_obj)
100 local_obj->add_term(length, var_id);
101 else if (!local && remote_obj)
102 remote_obj->add_term(length, var_id);
103
104 var_id = vars.lookup(t, q, v, BLOCKING_INDIRECT);
105 obj->add_term(length, var_id);
106 if (local && local_obj)
107 local_obj->add_term(length, var_id);
108 else if (!local && remote_obj)
109 remote_obj->add_term(length, var_id);
110
111 var_id = vars.lookup(t, q, v, BLOCKING_PREEMPT);
112 obj->add_term(length, var_id);
113 if (local && local_obj)
114 local_obj->add_term(length, var_id);
115 else if (!local && remote_obj)
116 remote_obj->add_term(length, var_id);
117 }
118 }
119 }
120}
121
69// Constraint 1 in [Brandenburg 2013] 122// Constraint 1 in [Brandenburg 2013]
70void add_mutex_constraints( 123void add_mutex_constraints(
71 VarMapper& vars, 124 VarMapper& vars,
@@ -180,3 +233,31 @@ void add_local_lower_priority_constraints(
180 } 233 }
181} 234}
182 235
236
237// For shared-memory protocols.
238// Remote tasks cannot preempt Ti since they are not scheduled
239// on Ti's assigned task; therefore force BLOCKING_PREEMPT to zero.
240void add_topology_constraints_shm(
241 VarMapper& vars,
242 const ResourceSharingInfo& info,
243 const TaskInfo& ti,
244 LinearProgram& lp)
245{
246 LinearExpression *exp = new LinearExpression();
247
248 foreach_remote_task(info.get_tasks(), ti, tx)
249 {
250 unsigned int t = tx->get_id();
251 foreach(tx->get_requests(), request)
252 {
253 unsigned int q = request->get_resource_id();
254 foreach_request_instance(*request, ti, v)
255 {
256 unsigned int var_id;
257 var_id = vars.lookup(t, q, v, BLOCKING_PREEMPT);
258 exp->add_var(var_id);
259 }
260 }
261 }
262 lp.add_equality(exp, 0);
263}