aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/blocking
diff options
context:
space:
mode:
authorBjoern Brandenburg <bbb@mpi-sws.org>2012-08-08 02:43:11 -0400
committerBjoern Brandenburg <bbb@mpi-sws.org>2013-02-12 06:49:40 -0500
commitc2c3126de5fc548db5821081af265bb8cf69cebd (patch)
treed43e82928b0f85f79e58bed4030b10426d70c098 /native/src/blocking
parent95cf0a86519981386d22604bab27502fa096df50 (diff)
Add support for tracking total LP generation / solving cost
Interestingly, this shows that generating huge LPs is not necessarily any faster than creating and solving many small LPs. Further investigation required.
Diffstat (limited to 'native/src/blocking')
-rw-r--r--native/src/blocking/linprog/lp_dflp.cpp80
-rw-r--r--native/src/blocking/linprog/lp_dpcp.cpp84
2 files changed, 154 insertions, 10 deletions
diff --git a/native/src/blocking/linprog/lp_dflp.cpp b/native/src/blocking/linprog/lp_dflp.cpp
index 8d5fec4..6198825 100644
--- a/native/src/blocking/linprog/lp_dflp.cpp
+++ b/native/src/blocking/linprog/lp_dflp.cpp
@@ -3,6 +3,8 @@
3#include "lp_common.h" 3#include "lp_common.h"
4#include "stl-hashmap.h" 4#include "stl-hashmap.h"
5 5
6#include "cpu_time.h"
7
6// Constraint 5 8// Constraint 5
7// only one blocking request each time a job of T_i 9// only one blocking request each time a job of T_i
8// issues a request, with regard to each cluster and each task. 10// issues a request, with regard to each cluster and each task.
@@ -109,8 +111,8 @@ void add_dflp_constraints(
109 111
110#ifdef CONFIG_MERGED_LINPROGS 112#ifdef CONFIG_MERGED_LINPROGS
111 113
112BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info, 114static BlockingBounds* _lp_dflp_bounds(const ResourceSharingInfo& info,
113 const ResourceLocality& locality) 115 const ResourceLocality& locality)
114{ 116{
115 BlockingBounds *results = new BlockingBounds(info); 117 BlockingBounds *results = new BlockingBounds(info);
116 const unsigned int num_tasks = info.get_tasks().size(); 118 const unsigned int num_tasks = info.get_tasks().size();
@@ -120,6 +122,18 @@ BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info,
120 LinearProgram lp; 122 LinearProgram lp;
121 unsigned int var_idx = 0; 123 unsigned int var_idx = 0;
122 124
125#if DEBUG_LP_OVERHEADS >= 2
126 static DEFINE_CPU_CLOCK(model_gen_cost);
127 static DEFINE_CPU_CLOCK(solver_cost);
128 static DEFINE_CPU_CLOCK(extract_cost);
129 static DEFINE_CPU_CLOCK(total_cost);
130
131 std::cout << "---- " << __FUNCTION__ << " ----" << std::endl;
132
133 model_gen_cost.start();
134 total_cost.start();
135#endif
136
123 // Generate a "merged" LP. 137 // Generate a "merged" LP.
124 for (unsigned int i = 0; i < num_tasks; i++) 138 for (unsigned int i = 0; i < num_tasks; i++)
125 { 139 {
@@ -133,11 +147,21 @@ BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info,
133 var_idx = vars.get_next_var(); 147 var_idx = vars.get_next_var();
134 } 148 }
135 149
150#if DEBUG_LP_OVERHEADS >= 2
151 model_gen_cost.stop();
152 solver_cost.start();
153#endif
154
136 // Solve the big, combined LP. 155 // Solve the big, combined LP.
137 Solution *sol = cplex_solve(lp, var_idx); 156 Solution *sol = cplex_solve(lp, var_idx);
138 157
139 assert(sol != NULL); 158 assert(sol != NULL);
140 159
160#if DEBUG_LP_OVERHEADS >= 2
161 solver_cost.stop();
162 extract_cost.start();
163#endif
164
141 // Extract each task's solution. 165 // Extract each task's solution.
142 for (unsigned int i = 0; i < num_tasks; i++) 166 for (unsigned int i = 0; i < num_tasks; i++)
143 { 167 {
@@ -152,6 +176,15 @@ BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info,
152 results->set_local_blocking(i, local); 176 results->set_local_blocking(i, local);
153 } 177 }
154 178
179#if DEBUG_LP_OVERHEADS >= 2
180 extract_cost.stop();
181 total_cost.stop();
182 std::cout << model_gen_cost << std::endl;
183 std::cout << solver_cost << std::endl;
184 std::cout << extract_cost << std::endl;
185 std::cout << total_cost << std::endl;
186#endif
187
155 delete sol; 188 delete sol;
156 delete[] local_obj; 189 delete[] local_obj;
157 delete[] remote_obj; 190 delete[] remote_obj;
@@ -173,12 +206,32 @@ static void apply_dflp_bounds_for_task(
173 const TaskInfo& ti = info.get_tasks()[i]; 206 const TaskInfo& ti = info.get_tasks()[i];
174 LinearExpression *local_obj = new LinearExpression(); 207 LinearExpression *local_obj = new LinearExpression();
175 208
209#if DEBUG_LP_OVERHEADS >= 2
210 static DEFINE_CPU_CLOCK(model_gen_cost);
211 static DEFINE_CPU_CLOCK(solver_cost);
212
213 std::cout << "---- " << __FUNCTION__ << " ----" << std::endl;
214
215 model_gen_cost.start();
216#endif
217
176 set_blocking_objective(vars, info, locality, ti, lp, local_obj); 218 set_blocking_objective(vars, info, locality, ti, lp, local_obj);
177 219
178 add_dflp_constraints(vars, info, locality, ti, lp); 220 add_dflp_constraints(vars, info, locality, ti, lp);
179 221
222#if DEBUG_LP_OVERHEADS >=2
223 model_gen_cost.stop();
224 std::cout << model_gen_cost << std::endl;
225 solver_cost.start();
226#endif
227
180 Solution *sol = cplex_solve(lp, vars.get_num_vars()); 228 Solution *sol = cplex_solve(lp, vars.get_num_vars());
181 229
230#if DEBUG_LP_OVERHEADS >=2
231 solver_cost.stop();
232 std::cout << solver_cost << std::endl;
233#endif
234
182 assert(sol != NULL); 235 assert(sol != NULL);
183 236
184 Interference total, remote, local; 237 Interference total, remote, local;
@@ -195,8 +248,8 @@ static void apply_dflp_bounds_for_task(
195 delete sol; 248 delete sol;
196} 249}
197 250
198BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info, 251static BlockingBounds* _lp_dflp_bounds(const ResourceSharingInfo& info,
199 const ResourceLocality& locality) 252 const ResourceLocality& locality)
200{ 253{
201 BlockingBounds *results = new BlockingBounds(info); 254 BlockingBounds *results = new BlockingBounds(info);
202 255
@@ -207,3 +260,22 @@ BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info,
207} 260}
208 261
209#endif 262#endif
263
264BlockingBounds* lp_dflp_bounds(const ResourceSharingInfo& info,
265 const ResourceLocality& locality)
266{
267#if DEBUG_LP_OVERHEADS >= 1
268 static DEFINE_CPU_CLOCK(cpu_costs);
269
270 cpu_costs.start();
271#endif
272
273 BlockingBounds *results = _lp_dflp_bounds(info, locality);
274
275#if DEBUG_LP_OVERHEADS >=1
276 cpu_costs.stop();
277 std::cout << cpu_costs << std::endl;
278#endif
279
280 return results;
281}
diff --git a/native/src/blocking/linprog/lp_dpcp.cpp b/native/src/blocking/linprog/lp_dpcp.cpp
index 52ecd0c..1b1cf32 100644
--- a/native/src/blocking/linprog/lp_dpcp.cpp
+++ b/native/src/blocking/linprog/lp_dpcp.cpp
@@ -6,6 +6,8 @@
6#include "blocking.h" 6#include "blocking.h"
7#include "stl-hashmap.h" 7#include "stl-hashmap.h"
8 8
9#include "cpu_time.h"
10
9#define NO_WAIT_TIME_BOUND (-1) 11#define NO_WAIT_TIME_BOUND (-1)
10 12
11class MaxWaitTimes 13class MaxWaitTimes
@@ -323,9 +325,9 @@ void add_dpcp_constraints(
323 325
324#ifdef CONFIG_MERGED_LINPROGS 326#ifdef CONFIG_MERGED_LINPROGS
325 327
326BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info, 328static BlockingBounds* _lp_dpcp_bounds(const ResourceSharingInfo& info,
327 const ResourceLocality& locality, 329 const ResourceLocality& locality,
328 bool use_rta) 330 bool use_rta)
329{ 331{
330 BlockingBounds *results = new BlockingBounds(info); 332 BlockingBounds *results = new BlockingBounds(info);
331 const unsigned int num_tasks = info.get_tasks().size(); 333 const unsigned int num_tasks = info.get_tasks().size();
@@ -337,6 +339,18 @@ BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info,
337 LinearProgram lp; 339 LinearProgram lp;
338 unsigned int var_idx = 0; 340 unsigned int var_idx = 0;
339 341
342#if DEBUG_LP_OVERHEADS >= 2
343 static DEFINE_CPU_CLOCK(model_gen_cost);
344 static DEFINE_CPU_CLOCK(solver_cost);
345