Skip to content

Commit d33610b

Browse files
Cleanup some more code. (#264)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent fdfcc6c commit d33610b

7 files changed

+44
-32
lines changed

src/qvi-hwpool.cc

+6
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ pool_release_cpus_by_cpuset(
123123
}
124124
#endif
125125

126+
qv_scope_create_hints_t
127+
qvi_hwpool_res_s::hints(void)
128+
{
129+
return m_hints;
130+
}
131+
126132
qvi_hwloc_bitmap_s &
127133
qvi_hwpool_cpu_s::cpuset(void)
128134
{

src/qvi-hwpool.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,18 @@ struct qvi_hwpool_res_s {
2626
protected:
2727
/** Resource hint flags. */
2828
qv_scope_create_hints_t m_hints = QV_SCOPE_CREATE_HINT_NONE;
29+
public:
30+
/** Returns the resource's create hints. */
31+
qv_scope_create_hints_t
32+
hints(void);
2933
};
3034

3135
/**
3236
* Defines a hardware pool CPU. A CPU here may have multiple
3337
* processing units (PUs), which are defined in the CPU's cpuset.
3438
*/
3539
struct qvi_hwpool_cpu_s : qvi_hwpool_res_s {
36-
protected:
40+
private:
3741
/** The cpuset of the CPU's PUs. */
3842
qvi_hwloc_bitmap_s m_cpuset;
3943
public:

src/qvi-hwsplit.cc

+18-19
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ qvi_hwsplit_s::~qvi_hwsplit_s(void)
4949
void
5050
qvi_hwsplit_s::reserve(void)
5151
{
52-
m_taskids.resize(m_group_size);
52+
m_group_tids.resize(m_group_size);
5353
m_hwpools.resize(m_group_size);
5454
m_colors.resize(m_group_size);
5555
m_affinities.resize(m_group_size);
@@ -237,7 +237,7 @@ qvi_hwsplit_s::split_devices_affinity_preserving(void)
237237
}
238238
// Store device affinities.
239239
qvi_hwloc_cpusets_t devaffs;
240-
for (auto &dev : devs) {
240+
for (const auto &dev : devs) {
241241
devaffs.push_back(dev->affinity());
242242
}
243243

@@ -429,7 +429,7 @@ qvi_hwsplit_s::split(void)
429429
return rc;
430430
}
431431

432-
qvi_coll_hwsplit_s::qvi_coll_hwsplit_s(
432+
qvi_hwsplit_coll_s::qvi_hwsplit_coll_s(
433433
qv_scope_t *parent,
434434
uint_t npieces,
435435
int color,
@@ -438,7 +438,7 @@ qvi_coll_hwsplit_s::qvi_coll_hwsplit_s(
438438
, m_color(color)
439439
{
440440
const qvi_group_t *const pgroup = m_parent->group();
441-
if (pgroup->rank() == qvi_coll_hwsplit_s::s_rootid) {
441+
if (pgroup->rank() == qvi_hwsplit_coll_s::s_rootid) {
442442
m_hwsplit = qvi_hwsplit_s(
443443
m_parent, pgroup->size(), npieces, split_at_type
444444
);
@@ -447,7 +447,7 @@ qvi_coll_hwsplit_s::qvi_coll_hwsplit_s(
447447

448448
template <typename TYPE>
449449
int
450-
qvi_coll_hwsplit_s::scatter_values(
450+
qvi_hwsplit_coll_s::scatter_values(
451451
const std::vector<TYPE> &values,
452452
TYPE *value
453453
) {
@@ -490,7 +490,7 @@ qvi_coll_hwsplit_s::scatter_values(
490490

491491
template <typename TYPE>
492492
int
493-
qvi_coll_hwsplit_s::bcast_value(
493+
qvi_hwsplit_coll_s::bcast_value(
494494
TYPE *value
495495
) {
496496
static_assert(std::is_trivially_copyable<TYPE>::value, "");
@@ -506,7 +506,7 @@ qvi_coll_hwsplit_s::bcast_value(
506506

507507
template <typename TYPE>
508508
int
509-
qvi_coll_hwsplit_s::gather_values(
509+
qvi_hwsplit_coll_s::gather_values(
510510
TYPE invalue,
511511
std::vector<TYPE> &outvals
512512
) {
@@ -554,7 +554,7 @@ qvi_coll_hwsplit_s::gather_values(
554554
}
555555

556556
int
557-
qvi_coll_hwsplit_s::gather_hwpools(
557+
qvi_hwsplit_coll_s::gather_hwpools(
558558
qvi_hwpool_s *txpool,
559559
std::vector<qvi_hwpool_s *> &rxpools
560560
) {
@@ -597,20 +597,19 @@ qvi_coll_hwsplit_s::gather_hwpools(
597597
}
598598

599599
int
600-
qvi_coll_hwsplit_s::gather(void)
600+
qvi_hwsplit_coll_s::gather(void)
601601
{
602-
int rc = gather_values(qvi_task_t::mytid(), m_hwsplit.m_taskids);
602+
int rc = gather_values(qvi_task_t::mytid(), m_hwsplit.m_group_tids);
603+
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
604+
rc = gather_values(m_color, m_hwsplit.m_colors);
603605
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
604606
// Note that the result hwpools are copies, so we can modify them freely.
605607
rc = gather_hwpools(m_parent->hwpool(), m_hwsplit.m_hwpools);
606608
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
607609

608-
rc = gather_values(m_color, m_hwsplit.m_colors);
609-
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
610-
611-
const int myid = m_parent->group()->rank();
610+
const int myrank = m_parent->group()->rank();
612611
const uint_t group_size = m_parent->group()->size();
613-
if (myid == qvi_coll_hwsplit_s::s_rootid) {
612+
if (myrank == qvi_hwsplit_coll_s::s_rootid) {
614613
m_hwsplit.m_affinities.resize(group_size);
615614
for (uint_t tid = 0; tid < group_size; ++tid) {
616615
hwloc_cpuset_t cpuset = nullptr;
@@ -627,7 +626,7 @@ qvi_coll_hwsplit_s::gather(void)
627626
}
628627

629628
int
630-
qvi_coll_hwsplit_s::scatter_hwpools(
629+
qvi_hwsplit_coll_s::scatter_hwpools(
631630
const std::vector<qvi_hwpool_s *> &pools,
632631
qvi_hwpool_s **pool
633632
) {
@@ -667,7 +666,7 @@ qvi_coll_hwsplit_s::scatter_hwpools(
667666
}
668667

669668
int
670-
qvi_coll_hwsplit_s::scatter(
669+
qvi_hwsplit_coll_s::scatter(
671670
int *colorp,
672671
qvi_hwpool_s **result
673672
) {
@@ -677,13 +676,13 @@ qvi_coll_hwsplit_s::scatter(
677676
}
678677

679678
int
680-
qvi_coll_hwsplit_s::barrier(void)
679+
qvi_hwsplit_coll_s::barrier(void)
681680
{
682681
return m_parent->group()->barrier();
683682
}
684683

685684
int
686-
qvi_coll_hwsplit_s::split(
685+
qvi_hwsplit_coll_s::split(
687686
int *colorp,
688687
qvi_hwpool_s **result
689688
) {

src/qvi-hwsplit.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
#include "qvi-map.h"
2121

2222
/**
23-
* Split aggregation: a collection of data relevant to split operations
24-
* requiring aggregated (e.g., global) knowledge to perform a split.
23+
* Hardware split aggregation: a collection of information relevant to split
24+
* operations requiring aggregated (e.g., global) knowledge to perform a split.
2525
*
2626
* NOTE: since splitting and mapping operations are performed by a single
2727
* process, this structure does not support collective operations that require
2828
* coordination between cooperating tasks. The structure for that is
29-
* qvi_scope_coll_data_s. Typically, collective operations will fill in a
30-
* qvi_scope_split_agg_s, but that isn't a requirement.
29+
* qvi_hwsplit_coll_s. Typically, collective operations will fill in a
30+
* this structure, but that isn't a requirement.
3131
*/
3232
struct qvi_hwsplit_s {
3333
//private:
@@ -47,12 +47,12 @@ struct qvi_hwsplit_s {
4747
*/
4848
qv_hw_obj_type_t m_split_at_type;
4949
/**
50-
* Vector of task IDs, one for each member of the group. Note that the
50+
* Vector of task TIDs, one for each member of the group. Note that the
5151
* number of task IDs will always match the group size and that their array
5252
* index corresponds to a task ID. It is handy to have the task IDs for
53-
* splitting so we can query task characteristics during a splitting.
53+
* splitting so we can query task characteristics during a split.
5454
*/
55-
std::vector<pid_t> m_taskids;
55+
std::vector<pid_t> m_group_tids;
5656
/**
5757
* Vector of hardware pools, one for each member of the group. Note that the
5858
* number of hardware pools will always match the group size and that their
@@ -153,7 +153,7 @@ struct qvi_hwsplit_s {
153153
* split operations requiring aggregated resource knowledge AND coordination
154154
* between tasks in the parent scope to perform a split.
155155
*/
156-
struct qvi_coll_hwsplit_s {
156+
struct qvi_hwsplit_coll_s {
157157
/**
158158
* The root task ID used for collective operations.
159159
* We use 0 as the root because 0 will always exist.
@@ -169,7 +169,7 @@ struct qvi_coll_hwsplit_s {
169169
*/
170170
qvi_hwsplit_s m_hwsplit;
171171
/** Constructor. */
172-
qvi_coll_hwsplit_s(void) = delete;
172+
qvi_hwsplit_coll_s(void) = delete;
173173
/** Constructor. */
174174
/**
175175
* Hardware resources will be split based on the provided split parameters:
@@ -179,7 +179,7 @@ struct qvi_coll_hwsplit_s {
179179
* maybe_obj_type: Potentially the object type that we are splitting at. This
180180
* value influences how the splitting algorithms perform their mapping.
181181
*/
182-
qvi_coll_hwsplit_s(
182+
qvi_hwsplit_coll_s(
183183
qv_scope_t *parent,
184184
uint_t npieces,
185185
int color,

src/qvi-omp.cc

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ int
7373
qvi_omp_group_barrier(
7474
qvi_omp_group_t *
7575
) {
76+
// TODO(skg) What should we do about barriers here? In particular, we need
77+
// to be careful about sub-groups, etc.
7678
return QV_SUCCESS;
7779
}
7880

src/qvi-scope.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ qv_scope_s::split(
244244
qvi_group_t *group = nullptr;
245245
qv_scope_t *ichild = nullptr;
246246
// Split the hardware resources based on the provided split parameters.
247-
qvi_coll_hwsplit_s chwsplit(
247+
qvi_hwsplit_coll_s chwsplit(
248248
this, npieces, color, maybe_obj_type
249249
);
250250
rc = chwsplit.split(&colorp, &hwpool);
@@ -307,7 +307,7 @@ qv_scope_s::thsplit(
307307
rc = qvi_dup(*m_hwpool, &hwsplit.m_hwpools[i]);
308308
if (rc != QV_SUCCESS) break;
309309
// Since this is called by a single task, replicate its task ID, too.
310-
hwsplit.m_taskids[i] = taskid;
310+
hwsplit.m_group_tids[i] = taskid;
311311
// Same goes for the task's affinity.
312312
hwsplit.m_affinities[i].set(task_affinity);
313313
}

src/qvi-utils.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct qvi_refc_s {
3939
void
4040
release(void) const
4141
{
42+
assert(refc > 0);
4243
if (--refc == 0) {
4344
delete this;
4445
}

0 commit comments

Comments
 (0)