diff options
| author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-05-16 12:37:19 -0400 |
|---|---|---|
| committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-05-16 12:37:19 -0400 |
| commit | 4bfee51d6ae7356b3f6cb2cee74123a684b4d593 (patch) | |
| tree | b6053bcb137089f478b0b2eb7251e185bc04d456 | |
| parent | dd7f66806e66d9637b070841c2a7c914671db969 (diff) | |
C++: Break out the G-OMLP and G-FMLP code into own file
Part of refactoring sharedres.cpp.
| -rw-r--r-- | native/Makefile | 2 | ||||
| -rw-r--r-- | native/src/blocking/global-fmlp.cpp | 53 | ||||
| -rw-r--r-- | native/src/blocking/global-omlp.cpp | 61 | ||||
| -rw-r--r-- | native/src/sharedres.cpp | 104 |
4 files changed, 115 insertions, 105 deletions
diff --git a/native/Makefile b/native/Makefile index 1957006..3a697db 100644 --- a/native/Makefile +++ b/native/Makefile | |||
| @@ -54,7 +54,7 @@ vpath %.cpp src src/edf src/blocking | |||
| 54 | EDF_OBJ = baker.o baruah.o gfb.o bcl.o bcl_iterative.o rta.o ffdbf.o gedf.o load.o cpu_time.o | 54 | EDF_OBJ = baker.o baruah.o gfb.o bcl.o bcl_iterative.o rta.o ffdbf.o gedf.o load.o cpu_time.o |
| 55 | SCHED_OBJ = sim.o schedule_sim.o | 55 | SCHED_OBJ = sim.o schedule_sim.o |
| 56 | CORE_OBJ = tasks.o | 56 | CORE_OBJ = tasks.o |
| 57 | SYNC_OBJ = sharedres.o dpcp.o mpcp.o fmlp_plus.o | 57 | SYNC_OBJ = sharedres.o dpcp.o mpcp.o fmlp_plus.o global-omlp.o global-fmlp.o |
| 58 | 58 | ||
| 59 | # #### Targets #### | 59 | # #### Targets #### |
| 60 | 60 | ||
diff --git a/native/src/blocking/global-fmlp.cpp b/native/src/blocking/global-fmlp.cpp new file mode 100644 index 0000000..b7cd25b --- /dev/null +++ b/native/src/blocking/global-fmlp.cpp | |||
| @@ -0,0 +1,53 @@ | |||
| 1 | #include "sharedres.h" | ||
| 2 | #include "blocking.h" | ||
| 3 | |||
| 4 | #include "stl-helper.h" | ||
| 5 | |||
| 6 | |||
| 7 | BlockingBounds* global_fmlp_bounds(const ResourceSharingInfo& info) | ||
| 8 | { | ||
| 9 | // split every thing by resources, sort, and then start counting. | ||
| 10 | Resources resources; | ||
| 11 | |||
| 12 | split_by_resource(info, resources); | ||
| 13 | sort_by_request_length(resources); | ||
| 14 | |||
| 15 | |||
| 16 | unsigned int i; | ||
| 17 | BlockingBounds* _results = new BlockingBounds(info); | ||
| 18 | BlockingBounds& results = *_results; | ||
| 19 | |||
| 20 | unsigned int num_tasks = info.get_tasks().size(); | ||
| 21 | |||
| 22 | for (i = 0; i < info.get_tasks().size(); i++) | ||
| 23 | { | ||
| 24 | const TaskInfo& tsk = info.get_tasks()[i]; | ||
| 25 | Interference bterm; | ||
| 26 | |||
| 27 | |||
| 28 | foreach(tsk.get_requests(), jt) | ||
| 29 | { | ||
| 30 | const RequestBound& req = *jt; | ||
| 31 | const ContentionSet& cs = | ||
| 32 | resources[req.get_resource_id()]; | ||
| 33 | |||
| 34 | unsigned long interval = tsk.get_response(); | ||
| 35 | unsigned long issued = req.get_num_requests(); | ||
| 36 | |||
| 37 | // every other task may block once per request | ||
| 38 | unsigned int total_limit = (num_tasks - 1) * issued; | ||
| 39 | unsigned int per_src_limit = issued; | ||
| 40 | |||
| 41 | bterm += bound_blocking(cs, | ||
| 42 | interval, | ||
| 43 | total_limit, | ||
| 44 | per_src_limit, | ||
| 45 | &tsk); | ||
| 46 | } | ||
| 47 | |||
| 48 | results[i] = bterm; | ||
| 49 | } | ||
| 50 | |||
| 51 | return _results; | ||
| 52 | } | ||
| 53 | |||
diff --git a/native/src/blocking/global-omlp.cpp b/native/src/blocking/global-omlp.cpp new file mode 100644 index 0000000..3c4f3da --- /dev/null +++ b/native/src/blocking/global-omlp.cpp | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | #include "sharedres.h" | ||
| 2 | #include "blocking.h" | ||
| 3 | |||
| 4 | #include "stl-helper.h" | ||
| 5 | |||
| 6 | BlockingBounds* global_omlp_bounds(const ResourceSharingInfo& info, | ||
| 7 | unsigned int num_procs) | ||
| 8 | { | ||
| 9 | // split every thing by resources, sort, and then start counting. | ||
| 10 | Resources resources; | ||
| 11 | |||
| 12 | split_by_resource(info, resources); | ||
| 13 | sort_by_request_length(resources); | ||
| 14 | |||
| 15 | unsigned int i; | ||
| 16 | BlockingBounds* _results = new BlockingBounds(info); | ||
| 17 | BlockingBounds& results = *_results; | ||
| 18 | |||
| 19 | for (i = 0; i < info.get_tasks().size(); i++) | ||
| 20 | { | ||
| 21 | const TaskInfo& tsk = info.get_tasks()[i]; | ||
| 22 | Interference bterm; | ||
| 23 | |||
| 24 | foreach(tsk.get_requests(), jt) | ||
| 25 | { | ||
| 26 | const RequestBound& req = *jt; | ||
| 27 | const ContentionSet& cs = | ||
| 28 | resources[req.get_resource_id()]; | ||
| 29 | |||
| 30 | unsigned int num_sources = cs.size(); | ||
| 31 | unsigned long interval = tsk.get_response(); | ||
| 32 | unsigned long issued = req.get_num_requests(); | ||
| 33 | |||
| 34 | |||
| 35 | unsigned int total_limit = (2 * num_procs - 1) * issued; | ||
| 36 | // Derived in the dissertation: at most twice per request. | ||
| 37 | unsigned int per_src_limit = 2 * issued; | ||
| 38 | |||
| 39 | if (num_sources <= num_procs + 1) { | ||
| 40 | // FIFO case: no job is ever skipped in the | ||
| 41 | // priority queue (since at most one job is in | ||
| 42 | // PQ at any time). | ||
| 43 | // Lemma 15 in RTSS'10: at most one blocking | ||
| 44 | // request per source per issued request. | ||
| 45 | per_src_limit = issued; | ||
| 46 | total_limit = (num_sources - 1) * issued; | ||
| 47 | } | ||
| 48 | |||
| 49 | bterm += bound_blocking(cs, | ||
| 50 | interval, | ||
| 51 | total_limit, | ||
| 52 | per_src_limit, | ||
| 53 | &tsk); | ||
| 54 | } | ||
| 55 | |||
| 56 | results[i] = bterm; | ||
| 57 | } | ||
| 58 | |||
| 59 | return _results; | ||
| 60 | } | ||
| 61 | |||
diff --git a/native/src/sharedres.cpp b/native/src/sharedres.cpp index 259e5a7..4520ccb 100644 --- a/native/src/sharedres.cpp +++ b/native/src/sharedres.cpp | |||
| @@ -468,110 +468,6 @@ static void charge_arrival_blocking(const ResourceSharingInfo& info, | |||
| 468 | 468 | ||
| 469 | // **** blocking term analysis **** | 469 | // **** blocking term analysis **** |
| 470 | 470 | ||
| 471 | BlockingBounds* global_omlp_bounds(const ResourceSharingInfo& info, | ||
| 472 | unsigned int num_procs) | ||
| 473 | { | ||
| 474 | // split every thing by resources, sort, and then start counting. | ||
| 475 | Resources resources; | ||
| 476 | |||
| 477 | split_by_resource(info, resources); | ||
| 478 | sort_by_request_length(resources); | ||
| 479 | |||
| 480 | unsigned int i; | ||
| 481 | BlockingBounds* _results = new BlockingBounds(info); | ||
| 482 | BlockingBounds& results = *_results; | ||
| 483 | |||
| 484 | for (i = 0; i < info.get_tasks().size(); i++) | ||
| 485 | { | ||
| 486 | const TaskInfo& tsk = info.get_tasks()[i]; | ||
| 487 | Interference bterm; | ||
| 488 | |||
| 489 | foreach(tsk.get_requests(), jt) | ||
| 490 | { | ||
| 491 | const RequestBound& req = *jt; | ||
| 492 | const ContentionSet& cs = | ||
| 493 | resources[req.get_resource_id()]; | ||
| 494 | |||
| 495 | unsigned int num_sources = cs.size(); | ||
| 496 | unsigned long interval = tsk.get_response(); | ||
| 497 | unsigned long issued = req.get_num_requests(); | ||
| 498 | |||
| 499 | |||
| 500 | unsigned int total_limit = (2 * num_procs - 1) * issued; | ||
| 501 | // Derived in the dissertation: at most twice per request. | ||
| 502 | unsigned int per_src_limit = 2 * issued; | ||
| 503 | |||
| 504 | if (num_sources <= num_procs + 1) { | ||
| 505 | // FIFO case: no job is ever skipped in the | ||
| 506 | // priority queue (since at most one job is in | ||
| 507 | // PQ at any time). | ||
| 508 | // Lemma 15 in RTSS'10: at most one blocking | ||
| 509 | // request per source per issued request. | ||
| 510 | per_src_limit = issued; | ||
| 511 | total_limit = (num_sources - 1) * issued; | ||
| 512 | } | ||
| 513 | |||
| 514 | bterm += bound_blocking(cs, | ||
| 515 | interval, | ||
| 516 | total_limit, | ||
| 517 | per_src_limit, | ||
| 518 | &tsk); | ||
| 519 | } | ||
| 520 | |||
| 521 | results[i] = bterm; | ||
| 522 | } | ||
| 523 | |||
| 524 | return _results; | ||
| 525 | } | ||
| 526 | |||
| 527 | |||
| 528 | BlockingBounds* global_fmlp_bounds(const ResourceSharingInfo& info) | ||
| 529 | { | ||
| 530 | // split every thing by resources, sort, and then start counting. | ||
| 531 | Resources resources; | ||
| 532 | |||
| 533 | split_by_resource(info, resources); | ||
| 534 | sort_by_request_length(resources); | ||
| 535 | |||
| 536 | |||
| 537 | unsigned int i; | ||
| 538 | BlockingBounds* _results = new BlockingBounds(info); | ||
| 539 | BlockingBounds& results = *_results; | ||
| 540 | |||
| 541 | unsigned int num_tasks = info.get_tasks().size(); | ||
| 542 | |||
| 543 | for (i = 0; i < info.get_tasks().size(); i++) | ||
| 544 | { | ||
| 545 | const TaskInfo& tsk = info.get_tasks()[i]; | ||
| 546 | Interference bterm; | ||
