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 static DEFINE_CPU_CLOCK(extract_cost);
346 static DEFINE_CPU_CLOCK(total_cost);
347
348 std::cout << "---- " << __FUNCTION__ << " ----" << std::endl;
349
350 model_gen_cost.start();
351 total_cost.start();
352#endif
353
340 // Generate a "merged" LP. 354 // Generate a "merged" LP.
341 for (unsigned int i = 0; i < num_tasks; i++) 355 for (unsigned int i = 0; i < num_tasks; i++)
342 { 356 {
@@ -351,11 +365,21 @@ BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info,
351 var_idx = vars.get_next_var(); 365 var_idx = vars.get_next_var();
352 } 366 }
353 367
368#if DEBUG_LP_OVERHEADS >= 2
369 model_gen_cost.stop();
370 solver_cost.start();
371#endif
372
354 // Solve the big, combined LP. 373 // Solve the big, combined LP.
355 Solution *sol = cplex_solve(lp, var_idx); 374 Solution *sol = cplex_solve(lp, var_idx);
356 375
357 assert(sol != NULL); 376 assert(sol != NULL);
358 377
378#if DEBUG_LP_OVERHEADS >= 2
379 solver_cost.stop();
380 extract_cost.start();
381#endif
382
359 // Extract each task's solution. 383 // Extract each task's solution.
360 for (unsigned int i = 0; i < num_tasks; i++) 384 for (unsigned int i = 0; i < num_tasks; i++)
361 { 385 {
@@ -370,6 +394,15 @@ BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info,
370 results->set_local_blocking(i, local); 394 results->set_local_blocking(i, local);
371 } 395 }
372 396
397#if DEBUG_LP_OVERHEADS >= 2
398 extract_cost.stop();
399 total_cost.stop();
400 std::cout << model_gen_cost << std::endl;
401 std::cout << solver_cost << std::endl;
402 std::cout << extract_cost << std::endl;
403 std::cout << total_cost << std::endl;
404#endif
405
373 delete sol; 406 delete sol;
374 delete[] local_obj; 407 delete[] local_obj;
375 delete[] remote_obj; 408 delete[] remote_obj;
@@ -392,13 +425,32 @@ static void apply_dpcp_bounds_for_task(
392 const TaskInfo& ti = info.get_tasks()[i]; 425 const TaskInfo& ti = info.get_tasks()[i];
393 LinearExpression *local_obj = new LinearExpression(); 426 LinearExpression *local_obj = new LinearExpression();
394 427
428#if DEBUG_LP_OVERHEADS >= 2
429 static DEFINE_CPU_CLOCK(model_gen_cost);
430 static DEFINE_CPU_CLOCK(solver_cost);
431
432 std::cout << "---- " << __FUNCTION__ << " ----" << std::endl;
433
434 model_gen_cost.start();
435#endif
436
395 set_blocking_objective(vars, info, locality, ti, lp, local_obj); 437 set_blocking_objective(vars, info, locality, ti, lp, local_obj);
396 438
397 add_dpcp_constraints(vars, info, locality, ti, 439 add_dpcp_constraints(vars, info, locality, ti,
398 prio_ceilings, lp, use_rta); 440 prio_ceilings, lp, use_rta);
399 441
442#if DEBUG_LP_OVERHEADS >= 2
443 model_gen_cost.stop();
444 std::cout << model_gen_cost << std::endl;
445 solver_cost.start();
446#endif
447
400 Solution *sol = cplex_solve(lp, vars.get_num_vars()); 448 Solution *sol = cplex_solve(lp, vars.get_num_vars());
401 449
450#if DEBUG_LP_OVERHEADS >= 2
451 solver_cost.stop();
452 std::cout << solver_cost << std::endl;
453#endif
402 assert(sol != NULL); 454 assert(sol != NULL);
403 455
404 Interference total, remote, local; 456 Interference total, remote, local;
@@ -416,9 +468,9 @@ static void apply_dpcp_bounds_for_task(
416} 468}
417 469
418 470
419BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info, 471static BlockingBounds* _lp_dpcp_bounds(const ResourceSharingInfo& info,
420 const ResourceLocality& locality, 472 const ResourceLocality& locality,
421 bool use_rta) 473 bool use_rta)
422{ 474{
423 BlockingBounds* results = new BlockingBounds(info); 475 BlockingBounds* results = new BlockingBounds(info);
424 476
@@ -432,3 +484,23 @@ BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info,
432} 484}
433 485
434#endif 486#endif
487
488BlockingBounds* lp_dpcp_bounds(const ResourceSharingInfo& info,
489 const ResourceLocality& locality,
490 bool use_rta)
491{
492#if DEBUG_LP_OVERHEADS >= 1
493 static DEFINE_CPU_CLOCK(cpu_costs);
494
495 cpu_costs.start();
496#endif
497
498 BlockingBounds *results = _lp_dpcp_bounds(info, locality, use_rta);
499
500#if DEBUG_LP_OVERHEADS >= 1
501 cpu_costs.stop();
502 std::cout << cpu_costs << std::endl;
503#endif
504
505 return results;
506}