diff --git a/include/quo-vadis.h b/include/quo-vadis.h index c4e9d0f..fb847ca 100644 --- a/include/quo-vadis.h +++ b/include/quo-vadis.h @@ -179,7 +179,7 @@ qv_scope_nobjs( int qv_scope_taskid( qv_scope_t *scope, - int *taskid + int *rank ); /** diff --git a/src/quo-vadis-mpi.cc b/src/quo-vadis-mpi.cc index 27e7eb5..cab609d 100644 --- a/src/quo-vadis-mpi.cc +++ b/src/quo-vadis-mpi.cc @@ -64,7 +64,7 @@ qvi_mpi_scope_get( const int rc = qvi_new(&izgroup, comm); if (qvi_unlikely(rc != QV_SUCCESS)) return rc; - return qvi_scope_get(izgroup, iscope, scope); + return qv_scope_s::makei(izgroup, iscope, scope); } int @@ -87,10 +87,7 @@ qvi_mpi_scope_comm_dup( qv_scope_t *scope, MPI_Comm *comm ) { - qvi_group_mpi_t *const mpi_group = dynamic_cast( - qvi_scope_group(scope) - ); - return mpi_group->comm_dup(comm); + return dynamic_cast(scope->group())->comm_dup(comm); } int diff --git a/src/quo-vadis-omp.cc b/src/quo-vadis-omp.cc index 158f793..986144c 100644 --- a/src/quo-vadis-omp.cc +++ b/src/quo-vadis-omp.cc @@ -35,7 +35,7 @@ qvi_omp_scope_get( *scope = nullptr; return rc; } - return qvi_scope_get(zgroup, iscope, scope); + return qv_scope_s::makei(zgroup, iscope, scope); } int diff --git a/src/quo-vadis-process.cc b/src/quo-vadis-process.cc index 110524b..767ad48 100644 --- a/src/quo-vadis-process.cc +++ b/src/quo-vadis-process.cc @@ -28,7 +28,7 @@ qvi_process_scope_get( *scope = nullptr; return rc; } - return qvi_scope_get(zgroup, iscope, scope); + return qv_scope_s::makei(zgroup, iscope, scope); } int diff --git a/src/quo-vadis-pthread.cc b/src/quo-vadis-pthread.cc index e05ec8d..99543cd 100644 --- a/src/quo-vadis-pthread.cc +++ b/src/quo-vadis-pthread.cc @@ -45,7 +45,8 @@ qvi_pthread_routine( void *arg ) { qvi_pthread_args_s *arg_ptr = (qvi_pthread_args_s *)arg; - qvi_scope_bind_push(arg_ptr->scope); + // TODO(skg) Check return code. + arg_ptr->scope->bind_push(); void *const ret = arg_ptr->th_routine(arg_ptr->th_routine_argp); qvi_delete(&arg_ptr); @@ -66,9 +67,8 @@ qv_pthread_scope_split( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_thsplit( - scope, npieces, color_array, nthreads, - QV_HW_OBJ_LAST, subscope + return scope->thsplit( + npieces, color_array, nthreads, QV_HW_OBJ_LAST, subscope ); } qvi_catch_and_return(); @@ -86,8 +86,8 @@ qv_pthread_scope_split_at( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_thsplit_at( - scope, type, color_array, nthreads, subscopes + return scope->thsplit_at( + type, color_array, nthreads, subscopes ); } qvi_catch_and_return(); @@ -108,7 +108,7 @@ qv_pthread_create( // pthread_create(), return a reasonable errno. if (qvi_unlikely(rc != QV_SUCCESS)) return ENOMEM; - auto group = dynamic_cast(qvi_scope_group(scope)); + auto group = dynamic_cast(scope->group()); qvi_pthread_group_pthread_create_args_s *cargs = nullptr; rc = qvi_new(&cargs, group->thgroup, qvi_pthread_routine, arg_ptr); if (qvi_unlikely(rc != QV_SUCCESS)) { @@ -129,7 +129,7 @@ qv_pthread_scopes_free( return QV_ERR_INVLD_ARG; } try { - qvi_scope_thdelete(&scopes, nscopes); + qv_scope_s::thdel(&scopes, nscopes); return QV_SUCCESS; } qvi_catch_and_return(); diff --git a/src/quo-vadis.cc b/src/quo-vadis.cc index 15f6034..452de8b 100644 --- a/src/quo-vadis.cc +++ b/src/quo-vadis.cc @@ -41,7 +41,7 @@ qv_scope_bind_push( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_bind_push(scope); + return scope->bind_push(); } qvi_catch_and_return(); } @@ -54,7 +54,7 @@ qv_scope_bind_pop( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_bind_pop(scope); + return scope->bind_pop(); } qvi_catch_and_return(); } @@ -69,7 +69,7 @@ qv_scope_bind_string( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_bind_string(scope, format, str); + return scope->bind_string(format, str); } qvi_catch_and_return(); } @@ -82,7 +82,7 @@ qv_scope_free( return QV_ERR_INVLD_ARG; } try { - qvi_scope_delete(&scope); + qv_scope_s::del(&scope); return QV_SUCCESS; } qvi_catch_and_return(); @@ -98,7 +98,8 @@ qv_scope_nobjs( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_nobjects(scope, obj, nobjs); + *nobjs = scope->nobjects(obj); + return QV_SUCCESS; } qvi_catch_and_return(); } @@ -107,13 +108,14 @@ qv_scope_nobjs( int qv_scope_taskid( qv_scope_t *scope, - int *taskid + int *rank ) { - if (qvi_unlikely(!scope || !taskid)) { + if (qvi_unlikely(!scope || !rank)) { return QV_ERR_INVLD_ARG; } try { - return qvi_scope_group_rank(scope, taskid); + *rank = scope->group_rank(); + return QV_SUCCESS; } qvi_catch_and_return(); } @@ -128,7 +130,8 @@ qv_scope_ntasks( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_group_size(scope, ntasks); + *ntasks = scope->group_size(); + return QV_SUCCESS; } qvi_catch_and_return(); } @@ -141,7 +144,7 @@ qv_scope_barrier( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_barrier(scope); + return scope->barrier(); } qvi_catch_and_return(); } @@ -159,9 +162,7 @@ qv_scope_create( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_create( - scope, type, nobjs, hints, subscope - ); + return scope->create(type, nobjs, hints, subscope); } qvi_catch_and_return(); } @@ -180,9 +181,7 @@ qv_scope_split( // We use the sentinel value QV_HW_OBJ_LAST to differentiate between // calls from split() and split_at(). Since this call doesn't have a // hardware type argument, we use QV_HW_OBJ_LAST as the hardware type. - return qvi_scope_split( - scope, npieces, color, QV_HW_OBJ_LAST, subscope - ); + return scope->split(npieces, color, QV_HW_OBJ_LAST, subscope); } qvi_catch_and_return(); } @@ -198,9 +197,7 @@ qv_scope_split_at( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_split_at( - scope, type, group_id, subscope - ); + return scope->split_at(type, group_id, subscope); } qvi_catch_and_return(); } @@ -217,9 +214,7 @@ qv_scope_get_device_id( return QV_ERR_INVLD_ARG; } try { - return qvi_scope_device_id( - scope, dev_obj, dev_index, id_type, dev_id - ); + return scope->device_id(dev_obj, dev_index, id_type, dev_id); } qvi_catch_and_return(); } diff --git a/src/qvi-scope.cc b/src/qvi-scope.cc index 72ca6dd..61be5cf 100644 --- a/src/qvi-scope.cc +++ b/src/qvi-scope.cc @@ -25,15 +25,36 @@ #include "qvi-utils.h" qv_scope_s::qv_scope_s( - qvi_group_t *group_a, - qvi_hwpool_s *hwpool_a -) : group(group_a) - , hwpool(hwpool_a) { } + qvi_group_t *group, + qvi_hwpool_s *hwpool +) : m_group(group) + , m_hwpool(hwpool) { } qv_scope_s::~qv_scope_s(void) { - qvi_delete(&hwpool); - group->release(); + qvi_delete(&m_hwpool); + m_group->release(); +} + +void +qv_scope_s::del( + qv_scope_t **scope +) { + qvi_delete(scope); +} + +void +qv_scope_s::thdel( + qv_scope_t ***kscopes, + uint_t k +) { + if (!kscopes) return; + qv_scope_t **ikscopes = *kscopes; + for (uint_t i = 0; i < k; ++i) { + qv_scope_s::del(&ikscopes[i]); + } + delete[] ikscopes; + *kscopes = nullptr; } static int @@ -46,7 +67,7 @@ scope_new( } int -qvi_scope_get( +qv_scope_s::makei( qvi_group_t *group, qv_scope_intrinsic_t iscope, qv_scope_t **scope @@ -64,15 +85,14 @@ qvi_scope_get( // Create and initialize the scope. rc = scope_new(group, hwpool, scope); if (qvi_unlikely(rc != QV_SUCCESS)) { - qvi_scope_delete(scope); + qv_scope_s::del(scope); } return rc; } // TODO(skg) Implement use of hints. int -qvi_scope_create( - qv_scope_t *parent, +qv_scope_s::create( qv_hw_obj_type_t type, int nobjs, qv_scope_create_hints_t, @@ -81,7 +101,7 @@ qvi_scope_create( *child = nullptr; // Create underlying group. Notice the use of self here. qvi_group_t *group = nullptr; - int rc = parent->group->self(&group); + int rc = m_group->self(&group); if (rc != QV_SUCCESS) return rc; // Create the hardware pool. qvi_hwpool_s *hwpool = nullptr; @@ -93,8 +113,8 @@ qvi_scope_create( // Get the appropriate cpuset based on the caller's request. hwloc_cpuset_t cpuset = nullptr; rc = qvi_rmi_get_cpuset_for_nobjs( - parent->group->task()->rmi(), - parent->hwpool->cpuset().cdata(), + m_group->task()->rmi(), + m_hwpool->cpuset().cdata(), type, nobjs, &cpuset ); if (rc != QV_SUCCESS) { @@ -104,7 +124,7 @@ qvi_scope_create( } // Now that we have the desired cpuset, // initialize the new hardware pool. - rc = hwpool->initialize(parent->group->hwloc(), cpuset); + rc = hwpool->initialize(m_group->hwloc(), cpuset); if (rc != QV_SUCCESS) { qvi_delete(&group); qvi_delete(&hwpool); @@ -116,85 +136,51 @@ qvi_scope_create( qv_scope_t *ichild = nullptr; rc = scope_new(group, hwpool, &ichild); if (rc != QV_SUCCESS) { - qvi_scope_delete(&ichild); + qv_scope_s::del(&ichild); } *child = ichild; return rc; } -void -qvi_scope_delete( - qv_scope_t **scope -) { - qvi_delete(scope); -} - -void -qvi_scope_thdelete( - qv_scope_t ***kscopes, - uint_t k -) { - if (!kscopes) return; - qv_scope_t **ikscopes = *kscopes; - for (uint_t i = 0; i < k; ++i) { - qvi_scope_delete(&ikscopes[i]); - } - delete[] ikscopes; - *kscopes = nullptr; -} - qvi_group_t * -qvi_scope_group( - qv_scope_t *scope -) { - assert(scope); - return scope->group; +qv_scope_s::group(void) const +{ + return m_group; } int -qvi_scope_group_size( - qv_scope_t *scope, - int *ntasks -) { - assert(scope); - *ntasks = scope->group->size(); - return QV_SUCCESS; +qv_scope_s::group_size(void) const +{ + return m_group->size(); } int -qvi_scope_group_rank( - qv_scope_t *scope, - int *taskid -) { - assert(scope); - *taskid = scope->group->rank(); - return QV_SUCCESS; +qv_scope_s::group_rank(void) const +{ + return m_group->rank(); } int -qvi_scope_nobjects( - qv_scope_t *scope, - qv_hw_obj_type_t obj, - int *result -) { - return scope->hwpool->nobjects( - scope->group->hwloc(), obj, result - ); +qv_scope_s::nobjects( + qv_hw_obj_type_t obj +) const { + int result = 0; + m_hwpool->nobjects(m_group->hwloc(), obj, &result); + return result; } int -qvi_scope_device_id( - qv_scope_t *scope, +qv_scope_s::device_id( qv_hw_obj_type_t dev_type, int dev_index, qv_device_id_type_t format, char **result -) { +) const { *result = nullptr; // Look for the requested device. int id = 0; qvi_hwpool_dev_s *finfo = nullptr; - for (const auto &dinfo : scope->hwpool->devices()) { + for (const auto &dinfo : m_hwpool->devices()) { if (dev_type != dinfo.first) continue; if (id++ == dev_index) { finfo = dinfo.second.get(); @@ -207,37 +193,32 @@ qvi_scope_device_id( } int -qvi_scope_barrier( - qv_scope_t *scope -) { - assert(scope); - return scope->group->barrier(); +qv_scope_s::barrier(void) +{ + return m_group->barrier(); } int -qvi_scope_bind_push( - qv_scope_t *scope -) { - return scope->group->task()->bind_push( - scope->hwpool->cpuset().cdata() +qv_scope_s::bind_push(void) +{ + return m_group->task()->bind_push( + m_hwpool->cpuset().cdata() ); } int -qvi_scope_bind_pop( - qv_scope_t *scope -) { - return scope->group->task()->bind_pop(); +qv_scope_s::bind_pop(void) +{ + return m_group->task()->bind_pop(); } int -qvi_scope_bind_string( - qv_scope_t *scope, +qv_scope_s::bind_string( qv_bind_string_format_t format, char **result ) { hwloc_cpuset_t bitmap = nullptr; - int rc = scope->group->task()->bind_top(&bitmap); + int rc = m_group->task()->bind_top(&bitmap); if (qvi_unlikely(rc != QV_SUCCESS)) return rc; rc = qvi_hwloc_bitmap_string(bitmap, format, result); @@ -246,8 +227,7 @@ qvi_scope_bind_string( } int -qvi_scope_split( - qv_scope_t *parent, +qv_scope_s::split( int npieces, int color, qv_hw_obj_type_t maybe_obj_type, @@ -259,13 +239,13 @@ qvi_scope_split( qv_scope_t *ichild = nullptr; // Split the hardware resources based on the provided split parameters. qvi_coll_hwsplit_s chwsplit( - parent, npieces, color, maybe_obj_type + this, npieces, color, maybe_obj_type ); rc = chwsplit.split(&colorp, &hwpool); if (rc != QV_SUCCESS) goto out; // Split underlying group. Notice the use of colorp here. - rc = parent->group->split( - colorp, parent->group->rank(), &group + rc = m_group->split( + colorp, m_group->rank(), &group ); if (rc != QV_SUCCESS) goto out; // Create and initialize the new scope. @@ -274,15 +254,23 @@ qvi_scope_split( if (rc != QV_SUCCESS) { qvi_delete(&hwpool); qvi_delete(&group); - qvi_scope_delete(&ichild); + qv_scope_s::del(&ichild); } *child = ichild; return rc; } int -qvi_scope_thsplit( - qv_scope_t *parent, +qv_scope_s::split_at( + qv_hw_obj_type_t type, + int color, + qv_scope_t **child +) { + return split(nobjects(type), color, type, child); +} + +int +qv_scope_s::thsplit( uint_t npieces, int *kcolors, uint_t k, @@ -291,10 +279,9 @@ qvi_scope_thsplit( ) { *thchildren = nullptr; - qvi_group_t *const pgroup = parent->group; const uint_t group_size = k; // Construct the hardware split. - qvi_hwsplit_s hwsplit(parent, group_size, npieces, maybe_obj_type); + qvi_hwsplit_s hwsplit(this, group_size, npieces, maybe_obj_type); // Eagerly make room for the group member information. hwsplit.reserve(); // Since this is called by a single task, get its ID and associated @@ -304,14 +291,14 @@ qvi_scope_thsplit( const pid_t taskid = qvi_task_t::mytid(); hwloc_cpuset_t task_affinity = nullptr; // Get the task's current affinity. - int rc = pgroup->task()->bind_top(&task_affinity); + int rc = m_group->task()->bind_top(&task_affinity); if (rc != QV_SUCCESS) return rc; for (uint_t i = 0; i < group_size; ++i) { // Store requested colors in aggregate. hwsplit.m_colors[i] = kcolors[i]; // Since the parent hardware pool is the resource we are splitting and // agg_split_* calls expect |group_size| elements, replicate by dups. - rc = qvi_dup(*parent->hwpool, &hwsplit.m_hwpools[i]); + rc = qvi_dup(*m_hwpool, &hwsplit.m_hwpools[i]); if (rc != QV_SUCCESS) break; // Since this is called by a single task, replicate its task ID, too. hwsplit.m_taskids[i] = taskid; @@ -328,7 +315,7 @@ qvi_scope_thsplit( // which a process is splitting its resources across threads, so create a // new thread group for each child. qvi_group_t *thgroup = nullptr; - rc = pgroup->thsplit(group_size, &thgroup); + rc = m_group->thsplit(group_size, &thgroup); if (rc != QV_SUCCESS) return rc; // Now create and populate the children. qv_scope_t **ithchildren = new qv_scope_t *[group_size]; @@ -345,7 +332,7 @@ qvi_scope_thsplit( ithchildren[i] = child; } if (rc != QV_SUCCESS) { - qvi_scope_thdelete(&ithchildren, k); + qv_scope_s::thdel(&ithchildren, k); } else { // Subtract one to account for the parent's @@ -357,32 +344,13 @@ qvi_scope_thsplit( } int -qvi_scope_thsplit_at( - qv_scope_t *parent, +qv_scope_s::thsplit_at( qv_hw_obj_type_t type, int *kgroup_ids, uint_t k, qv_scope_t ***kchildren ) { - int nobj = 0; - const int rc = qvi_scope_nobjects(parent, type, &nobj); - if (qvi_unlikely(rc != QV_SUCCESS)) return rc; - - return qvi_scope_thsplit(parent, nobj, kgroup_ids, k, type, kchildren); -} - -int -qvi_scope_split_at( - qv_scope_t *parent, - qv_hw_obj_type_t type, - int color, - qv_scope_t **child -) { - int nobj = 0; - const int rc = qvi_scope_nobjects(parent, type, &nobj); - if (qvi_unlikely(rc != QV_SUCCESS)) return rc; - - return qvi_scope_split(parent, nobj, color, type, child); + return thsplit(nobjects(type), kgroup_ids, k, type, kchildren); } /* diff --git a/src/qvi-scope.h b/src/qvi-scope.h index 41d339e..0eb0ba1 100644 --- a/src/qvi-scope.h +++ b/src/qvi-scope.h @@ -23,175 +23,120 @@ struct qv_scope_s { /** Task group associated with this scope instance. */ - qvi_group_t *group = nullptr; + qvi_group_t *m_group = nullptr; /** Hardware resource pool. */ - qvi_hwpool_s *hwpool = nullptr; + qvi_hwpool_s *m_hwpool = nullptr; /** Constructor */ qv_scope_s(void) = delete; /** Constructor */ qv_scope_s( - qvi_group_t *group_a, - qvi_hwpool_s *hwpool_a + qvi_group_t *group, + qvi_hwpool_s *hwpool ); /** Destructor */ ~qv_scope_s(void); -}; - -/** - * Returns a new intrinsic scope. - */ -int -qvi_scope_get( - qvi_group_t *group, - qv_scope_intrinsic_t iscope, - qv_scope_t **scope -); - -/** - * Creates a new scope based on the specified hardare type, number of resources, - * and creation hints. - */ -int -qvi_scope_create( - qv_scope_t *parent, - qv_hw_obj_type_t type, - int nobjs, - qv_scope_create_hints_t hints, - qv_scope_t **child -); - -/** - * Destroys a scope. - */ -void -qvi_scope_delete( - qv_scope_t **scope -); - -/** - * Frees scope resources and container created by qvi_scope_thsplit*. - */ -void -qvi_scope_thdelete( - qv_scope_t ***kscopes, - uint_t k -); - -/** - * Returns a pointer to the scope's underlying group. - */ -qvi_group_t * -qvi_scope_group( - qv_scope_t *scope -); - -/** - * Returns the scope's group size. - */ -int -qvi_scope_group_size( - qv_scope_t *scope, - int *ntasks -); - -/** - * Returns the caller's group rank in the provided scope. - */ -int -qvi_scope_group_rank( - qv_scope_t *scope, - int *taskid -); - -/** - * Returns the number of hardware objects in the provided scope. - */ -int -qvi_scope_nobjects( - qv_scope_t *scope, - qv_hw_obj_type_t obj, - int *result -); - -/** - * Returns the device ID string according to the ID type for the requested - * device type and index. - */ -int -qvi_scope_device_id( - qv_scope_t *scope, - qv_hw_obj_type_t dev_type, - int dev_index, - qv_device_id_type_t format, - char **result -); - -/** - * Performs a scope-level barrier. - */ -int -qvi_scope_barrier( - qv_scope_t *scope -); - -int -qvi_scope_bind_push( - qv_scope_t *scope -); - -int -qvi_scope_bind_pop( - qv_scope_t *scope -); - -int -qvi_scope_bind_string( - qv_scope_t *scope, - qv_bind_string_format_t format, - char **result -); + /** Destroys a scope. */ + static void + del( + qv_scope_t **scope + ); + /** Frees scope resources and container created by thsplit*. */ + static void + thdel( + qv_scope_t ***kscopes, + uint_t k + ); + /** Takes the provided group and creates a new intrinsic scope from it. */ + static int + makei( + qvi_group_t *group, + qv_scope_intrinsic_t iscope, + qv_scope_t **scope + ); + /** + * Creates a new scope based on the specified hardware + * type, number of resources, and creation hints. + */ + int + create( + qv_hw_obj_type_t type, + int nobjs, + qv_scope_create_hints_t hints, + qv_scope_t **child + ); + /** Returns a pointer to the scope's underlying group. */ + qvi_group_t * + group(void) const; + /** Returns the scope's group size. */ + int + group_size(void) const; + /** Returns the caller's group rank in the provided scope. */ + int + group_rank(void) const; + /** Returns the number of hardware objects in the provided scope. */ + int + nobjects( + qv_hw_obj_type_t obj + ) const; + /** + * Returns the device ID string according to the ID + * type for the requested device type and index. + */ + int + device_id( + qv_hw_obj_type_t dev_type, + int dev_index, + qv_device_id_type_t format, + char **result + ) const; + /** Performs a scope-level barrier. */ + int + barrier(void); + + int + bind_push(void); + + int + bind_pop(void); + + int + bind_string( + qv_bind_string_format_t format, + char **result + ); -int -qvi_scope_thsplit( - qv_scope_t *parent, - uint_t npieces, - int *kcolors, - uint_t k, - qv_hw_obj_type_t maybe_obj_type, - qv_scope_t ***kchildren -); + int + thsplit( + uint_t npieces, + int *kcolors, + uint_t k, + qv_hw_obj_type_t maybe_obj_type, + qv_scope_t ***kchildren + ); -int -qvi_scope_thsplit_at( - qv_scope_t *parent, - qv_hw_obj_type_t type, - int *kgroup_ids, - uint_t k, - qv_scope_t ***kchildren -); + int + thsplit_at( + qv_hw_obj_type_t type, + int *kgroup_ids, + uint_t k, + qv_scope_t ***kchildren + ); -/** - * - */ -int -qvi_scope_split( - qv_scope_t *parent, - int ncolors, - int color, - qv_hw_obj_type_t maybe_obj_type, - qv_scope_t **child -); + int + split( + int ncolors, + int color, + qv_hw_obj_type_t maybe_obj_type, + qv_scope_t **child + ); -/** - * - */ -int -qvi_scope_split_at( - qv_scope_t *parent, - qv_hw_obj_type_t type, - int group_id, - qv_scope_t **child -); + int + split_at( + qv_hw_obj_type_t type, + int group_id, + qv_scope_t **child + ); +}; #endif diff --git a/src/qvi-split.cc b/src/qvi-split.cc index fe536ef..7f05512 100644 --- a/src/qvi-split.cc +++ b/src/qvi-split.cc @@ -26,8 +26,8 @@ qvi_hwsplit_s::qvi_hwsplit_s( uint_t group_size, uint_t split_size, qv_hw_obj_type_t split_at_type -) : m_rmi(parent->group->task()->rmi()) - , m_hwpool(parent->hwpool) +) : m_rmi(parent->m_group->task()->rmi()) + , m_hwpool(parent->m_hwpool) , m_group_size(group_size) , m_split_size(split_size) , m_split_at_type(split_at_type) @@ -437,7 +437,7 @@ qvi_coll_hwsplit_s::qvi_coll_hwsplit_s( ) : m_parent(parent) , m_color(color) { - const qvi_group_t *const pgroup = m_parent->group; + const qvi_group_t *const pgroup = m_parent->m_group; if (pgroup->rank() == qvi_coll_hwsplit_s::s_rootid) { m_hwsplit = qvi_hwsplit_s( m_parent, pgroup->size(), npieces, split_at_type @@ -456,7 +456,7 @@ qvi_coll_hwsplit_s::scatter_values( int rc = QV_SUCCESS; qvi_bbuff_t *rxbuff = nullptr; - qvi_group_t *const group = m_parent->group; + qvi_group_t *const group = m_parent->m_group; std::vector txbuffs(0); if (group->rank() == s_rootid) { const uint_t group_size = group->size(); @@ -494,7 +494,7 @@ qvi_coll_hwsplit_s::bcast_value( TYPE *value ) { static_assert(std::is_trivially_copyable::value, ""); - qvi_group_t *const group = m_parent->group; + qvi_group_t *const group = m_parent->m_group; std::vector values; if (group->rank() == s_rootid) { @@ -511,7 +511,7 @@ qvi_coll_hwsplit_s::gather_values( std::vector &outvals ) { static_assert(std::is_trivially_copyable::value, ""); - qvi_group_t *const group = m_parent->group; + qvi_group_t *const group = m_parent->m_group; const uint_t group_size = group->size(); qvi_bbuff_t *txbuff = nullptr; @@ -558,7 +558,7 @@ qvi_coll_hwsplit_s::gather_hwpools( qvi_hwpool_s *txpool, std::vector &rxpools ) { - qvi_group_t *const group = m_parent->group; + qvi_group_t *const group = m_parent->m_group; const uint_t group_size = group->size(); // Pack the hardware pool into a buffer. qvi_bbuff_t txbuff; @@ -602,19 +602,19 @@ qvi_coll_hwsplit_s::gather(void) int rc = gather_values(qvi_task_t::mytid(), m_hwsplit.m_taskids); if (qvi_unlikely(rc != QV_SUCCESS)) return rc; // Note that the result hwpools are copies, so we can modify them freely. - rc = gather_hwpools(m_parent->hwpool, m_hwsplit.m_hwpools); + rc = gather_hwpools(m_parent->m_hwpool, m_hwsplit.m_hwpools); if (qvi_unlikely(rc != QV_SUCCESS)) return rc; rc = gather_values(m_color, m_hwsplit.m_colors); if (qvi_unlikely(rc != QV_SUCCESS)) return rc; - const int myid = m_parent->group->rank(); - const uint_t group_size = m_parent->group->size(); + const int myid = m_parent->m_group->rank(); + const uint_t group_size = m_parent->m_group->size(); if (myid == qvi_coll_hwsplit_s::s_rootid) { m_hwsplit.m_affinities.resize(group_size); for (uint_t tid = 0; tid < group_size; ++tid) { hwloc_cpuset_t cpuset = nullptr; - rc = m_parent->group->task()->bind_top(&cpuset); + rc = m_parent->m_group->task()->bind_top(&cpuset); if (qvi_unlikely(rc != QV_SUCCESS)) break; // rc = m_hwsplit.m_affinities[tid].set(cpuset); @@ -635,7 +635,7 @@ qvi_coll_hwsplit_s::scatter_hwpools( std::vector txbuffs(0); qvi_bbuff_t *rxbuff = nullptr; - qvi_group_t *const group = m_parent->group; + qvi_group_t *const group = m_parent->m_group; if (group->rank() == s_rootid) { const uint_t group_size = group->size(); @@ -679,7 +679,7 @@ qvi_coll_hwsplit_s::scatter( int qvi_coll_hwsplit_s::barrier(void) { - return m_parent->group->barrier(); + return m_parent->m_group->barrier(); } int @@ -698,7 +698,7 @@ qvi_coll_hwsplit_s::split( if (qvi_unlikely(rc != QV_SUCCESS)) return rc; // The root does this calculation. int rc2 = QV_SUCCESS; - if (m_parent->group->rank() == s_rootid) { + if (m_parent->m_group->rank() == s_rootid) { rc2 = m_hwsplit.split(); } // Wait for the split information. Explicitly barrier here in case the diff --git a/tests/test-mpi-scopes.c b/tests/test-mpi-scopes.c index fcfd714..2f21937 100644 --- a/tests/test-mpi-scopes.c +++ b/tests/test-mpi-scopes.c @@ -181,6 +181,8 @@ main( qvi_test_scope_report(create_scope, "create_scope"); + qvi_test_bind_push(create_scope); + rc = qv_scope_free(create_scope); if (rc != QV_SUCCESS) { ers = "qv_scope_free() failed";