diff options
author | Alexander Wieder <awieder@mpi-sws.org> | 2013-02-17 22:43:42 -0500 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2013-12-13 02:39:07 -0500 |
commit | aa1fdb655f8c70fba6421fba094793108bda9340 (patch) | |
tree | e0b6235bd78aa062048f1a0926db1d1c5b6205f5 | |
parent | 1cffe6281e3edb49ea7689a69fbab152fca3f982 (diff) |
C++ helper function split_by_clusters: allow initialization with number of processors
This can avoid issues when the no task is assigned to the last partition, in
which case the existing code would leave the last partions in the Clusters
data structure uninitialized.
-rw-r--r-- | native/include/blocking.h | 2 | ||||
-rw-r--r-- | native/src/sharedres.cpp | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/native/include/blocking.h b/native/include/blocking.h index cbb4d15..efa9cad 100644 --- a/native/include/blocking.h +++ b/native/include/blocking.h | |||
@@ -30,7 +30,7 @@ void sort_by_request_length(ContentionSet& cs); | |||
30 | typedef std::vector<const TaskInfo*> Cluster; | 30 | typedef std::vector<const TaskInfo*> Cluster; |
31 | typedef std::vector<Cluster> Clusters; | 31 | typedef std::vector<Cluster> Clusters; |
32 | 32 | ||
33 | void split_by_cluster(const ResourceSharingInfo& info, Clusters& clusters); | 33 | void split_by_cluster(const ResourceSharingInfo& info, Clusters& clusters, unsigned int num_cpus = 0); |
34 | void split_by_resource(const ResourceSharingInfo& info, Resources& resources); | 34 | void split_by_resource(const ResourceSharingInfo& info, Resources& resources); |
35 | void split_by_resource(const Cluster& cluster, Resources& resources); | 35 | void split_by_resource(const Cluster& cluster, Resources& resources); |
36 | void split_by_resource(const Clusters& clusters, ClusterResources& resources); | 36 | void split_by_resource(const Clusters& clusters, ClusterResources& resources); |
diff --git a/native/src/sharedres.cpp b/native/src/sharedres.cpp index 97cf466..5caa75e 100644 --- a/native/src/sharedres.cpp +++ b/native/src/sharedres.cpp | |||
@@ -72,8 +72,11 @@ unsigned int RequestBound::get_max_num_requests(unsigned long interval) const | |||
72 | // ****** non-exported helpers ******* | 72 | // ****** non-exported helpers ******* |
73 | 73 | ||
74 | 74 | ||
75 | void split_by_cluster(const ResourceSharingInfo& info, Clusters& clusters) | 75 | void split_by_cluster(const ResourceSharingInfo& info, Clusters& clusters, unsigned int num_cpus) |
76 | { | 76 | { |
77 | if (num_cpus > 0) | ||
78 | while (num_cpus > clusters.size()) | ||
79 | clusters.push_back(Cluster()); | ||
77 | foreach(info.get_tasks(), it) | 80 | foreach(info.get_tasks(), it) |
78 | { | 81 | { |
79 | const TaskInfo& tsk = *it; | 82 | const TaskInfo& tsk = *it; |