Skip to content

Commit c787384

Browse files
Harden scope interfaces. (#260)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent 56e3529 commit c787384

File tree

3 files changed

+25
-14
lines changed

3 files changed

+25
-14
lines changed

src/qvi-scope.cc

+6
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,12 @@ qv_scope_s::group(void) const
148148
return m_group;
149149
}
150150

151+
qvi_hwpool_s *
152+
qv_scope_s::hwpool(void) const
153+
{
154+
return m_hwpool;
155+
}
156+
151157
int
152158
qv_scope_s::group_size(void) const
153159
{

src/qvi-scope.h

+5
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
#include "qvi-hwpool.h"
2323

2424
struct qv_scope_s {
25+
private:
2526
/** Task group associated with this scope instance. */
2627
qvi_group_t *m_group = nullptr;
2728
/** Hardware resource pool. */
2829
qvi_hwpool_s *m_hwpool = nullptr;
30+
public:
2931
/** Constructor */
3032
qv_scope_s(void) = delete;
3133
/** Constructor */
@@ -67,6 +69,9 @@ struct qv_scope_s {
6769
/** Returns a pointer to the scope's underlying group. */
6870
qvi_group_t *
6971
group(void) const;
72+
/** Returns a pointer to the scope's underlying hardware pool. */
73+
qvi_hwpool_s *
74+
hwpool(void) const;
7075
/** Returns the scope's group size. */
7176
int
7277
group_size(void) const;

src/qvi-split.cc

+14-14
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ qvi_hwsplit_s::qvi_hwsplit_s(
2626
uint_t group_size,
2727
uint_t split_size,
2828
qv_hw_obj_type_t split_at_type
29-
) : m_rmi(parent->m_group->task()->rmi())
30-
, m_hwpool(parent->m_hwpool)
29+
) : m_rmi(parent->group()->task()->rmi())
30+
, m_hwpool(parent->hwpool())
3131
, m_group_size(group_size)
3232
, m_split_size(split_size)
3333
, m_split_at_type(split_at_type)
@@ -437,7 +437,7 @@ qvi_coll_hwsplit_s::qvi_coll_hwsplit_s(
437437
) : m_parent(parent)
438438
, m_color(color)
439439
{
440-
const qvi_group_t *const pgroup = m_parent->m_group;
440+
const qvi_group_t *const pgroup = m_parent->group();
441441
if (pgroup->rank() == qvi_coll_hwsplit_s::s_rootid) {
442442
m_hwsplit = qvi_hwsplit_s(
443443
m_parent, pgroup->size(), npieces, split_at_type
@@ -456,7 +456,7 @@ qvi_coll_hwsplit_s::scatter_values(
456456
int rc = QV_SUCCESS;
457457
qvi_bbuff_t *rxbuff = nullptr;
458458

459-
qvi_group_t *const group = m_parent->m_group;
459+
qvi_group_t *const group = m_parent->group();
460460
std::vector<qvi_bbuff_t *> txbuffs(0);
461461
if (group->rank() == s_rootid) {
462462
const uint_t group_size = group->size();
@@ -494,7 +494,7 @@ qvi_coll_hwsplit_s::bcast_value(
494494
TYPE *value
495495
) {
496496
static_assert(std::is_trivially_copyable<TYPE>::value, "");
497-
qvi_group_t *const group = m_parent->m_group;
497+
qvi_group_t *const group = m_parent->group();
498498

499499
std::vector<TYPE> values;
500500
if (group->rank() == s_rootid) {
@@ -511,7 +511,7 @@ qvi_coll_hwsplit_s::gather_values(
511511
std::vector<TYPE> &outvals
512512
) {
513513
static_assert(std::is_trivially_copyable<TYPE>::value, "");
514-
qvi_group_t *const group = m_parent->m_group;
514+
qvi_group_t *const group = m_parent->group();
515515
const uint_t group_size = group->size();
516516

517517
qvi_bbuff_t *txbuff = nullptr;
@@ -558,7 +558,7 @@ qvi_coll_hwsplit_s::gather_hwpools(
558558
qvi_hwpool_s *txpool,
559559
std::vector<qvi_hwpool_s *> &rxpools
560560
) {
561-
qvi_group_t *const group = m_parent->m_group;
561+
qvi_group_t *const group = m_parent->group();
562562
const uint_t group_size = group->size();
563563
// Pack the hardware pool into a buffer.
564564
qvi_bbuff_t txbuff;
@@ -602,19 +602,19 @@ qvi_coll_hwsplit_s::gather(void)
602602
int rc = gather_values(qvi_task_t::mytid(), m_hwsplit.m_taskids);
603603
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
604604
// Note that the result hwpools are copies, so we can modify them freely.
605-
rc = gather_hwpools(m_parent->m_hwpool, m_hwsplit.m_hwpools);
605+
rc = gather_hwpools(m_parent->hwpool(), m_hwsplit.m_hwpools);
606606
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
607607

608608
rc = gather_values(m_color, m_hwsplit.m_colors);
609609
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
610610

611-
const int myid = m_parent->m_group->rank();
612-
const uint_t group_size = m_parent->m_group->size();
611+
const int myid = m_parent->group()->rank();
612+
const uint_t group_size = m_parent->group()->size();
613613
if (myid == qvi_coll_hwsplit_s::s_rootid) {
614614
m_hwsplit.m_affinities.resize(group_size);
615615
for (uint_t tid = 0; tid < group_size; ++tid) {
616616
hwloc_cpuset_t cpuset = nullptr;
617-
rc = m_parent->m_group->task()->bind_top(&cpuset);
617+
rc = m_parent->group()->task()->bind_top(&cpuset);
618618
if (qvi_unlikely(rc != QV_SUCCESS)) break;
619619
//
620620
rc = m_hwsplit.m_affinities[tid].set(cpuset);
@@ -635,7 +635,7 @@ qvi_coll_hwsplit_s::scatter_hwpools(
635635
std::vector<qvi_bbuff_t *> txbuffs(0);
636636
qvi_bbuff_t *rxbuff = nullptr;
637637

638-
qvi_group_t *const group = m_parent->m_group;
638+
qvi_group_t *const group = m_parent->group();
639639

640640
if (group->rank() == s_rootid) {
641641
const uint_t group_size = group->size();
@@ -679,7 +679,7 @@ qvi_coll_hwsplit_s::scatter(
679679
int
680680
qvi_coll_hwsplit_s::barrier(void)
681681
{
682-
return m_parent->m_group->barrier();
682+
return m_parent->group()->barrier();
683683
}
684684

685685
int
@@ -698,7 +698,7 @@ qvi_coll_hwsplit_s::split(
698698
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
699699
// The root does this calculation.
700700
int rc2 = QV_SUCCESS;
701-
if (m_parent->m_group->rank() == s_rootid) {
701+
if (m_parent->group()->rank() == s_rootid) {
702702
rc2 = m_hwsplit.split();
703703
}
704704
// Wait for the split information. Explicitly barrier here in case the

0 commit comments

Comments
 (0)