From fdfcc6c653703b12fc52f2e3ad4915dedfdbf845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20K=2E=20Guti=C3=A9rrez?= Date: Mon, 29 Jul 2024 10:55:58 -0600 Subject: [PATCH] Cleanup some code. (#263) Signed-off-by: Samuel K. Gutierrez --- include/quo-vadis.h | 27 ++++++++++++++------------- src/CMakeLists.txt | 4 ++-- src/quo-vadis-mpi.cc | 2 +- src/quo-vadis-omp.cc | 2 +- src/quo-vadis-process.cc | 2 +- src/quo-vadis.cc | 7 +++---- src/qvi-group-mpi.cc | 12 ++++++------ src/{qvi-split.cc => qvi-hwsplit.cc} | 4 ++-- src/{qvi-split.h => qvi-hwsplit.h} | 6 +++--- src/qvi-scope.cc | 4 ++-- src/qvi-scope.h | 2 +- 11 files changed, 36 insertions(+), 36 deletions(-) rename src/{qvi-split.cc => qvi-hwsplit.cc} (99%) rename src/{qvi-split.h => qvi-hwsplit.h} (99%) diff --git a/include/quo-vadis.h b/include/quo-vadis.h index e2c551f..53138ed 100644 --- a/include/quo-vadis.h +++ b/include/quo-vadis.h @@ -163,16 +163,6 @@ qv_version( int *patch ); -/** - * - */ -int -qv_scope_nobjs( - qv_scope_t *scope, - qv_hw_obj_type_t obj, - int *nobjs -); - /** * */ @@ -188,17 +178,20 @@ qv_scope_group_rank( int qv_scope_group_size( qv_scope_t *scope, - int *ntasks + int *group_size ); /** * */ int -qv_scope_barrier( - qv_scope_t *scope +qv_scope_nobjs( + qv_scope_t *scope, + qv_hw_obj_type_t obj, + int *nobjs ); +// TODO(skg) Rename to qv_scope_device_id_get? /** * */ @@ -211,6 +204,14 @@ qv_scope_get_device_id( char **dev_id ); +/** + * + */ +int +qv_scope_barrier( + qv_scope_t *scope +); + /** * */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 84a5b0c..d9ac2a6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -34,7 +34,7 @@ add_library( qvi-subgroup.h qvi-group-pthread.h qvi-map.h - qvi-split.h + qvi-hwsplit.h qvi-scope.h qvi-log.cc qvi-utils.cc @@ -49,7 +49,7 @@ add_library( qvi-pthread.cc qvi-group-pthread.cc qvi-map.cc - qvi-split.cc + qvi-hwsplit.cc qvi-scope.cc quo-vadis.cc quo-vadis-pthread.cc diff --git a/src/quo-vadis-mpi.cc b/src/quo-vadis-mpi.cc index cab609d..eefe406 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 qv_scope_s::makei(izgroup, iscope, scope); + return qv_scope_s::make_intrinsic(izgroup, iscope, scope); } int diff --git a/src/quo-vadis-omp.cc b/src/quo-vadis-omp.cc index 986144c..73e2218 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 qv_scope_s::makei(zgroup, iscope, scope); + return qv_scope_s::make_intrinsic(zgroup, iscope, scope); } int diff --git a/src/quo-vadis-process.cc b/src/quo-vadis-process.cc index 767ad48..4815125 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 qv_scope_s::makei(zgroup, iscope, scope); + return qv_scope_s::make_intrinsic(zgroup, iscope, scope); } int diff --git a/src/quo-vadis.cc b/src/quo-vadis.cc index 4a3ac5d..708b4b1 100644 --- a/src/quo-vadis.cc +++ b/src/quo-vadis.cc @@ -119,17 +119,16 @@ qv_scope_group_rank( qvi_catch_and_return(); } -// TODO(skg) Rename to qv_scope_group_size. int qv_scope_group_size( qv_scope_t *scope, - int *ntasks + int *group_size ) { - if (qvi_unlikely(!scope || !ntasks)) { + if (qvi_unlikely(!scope || !group_size)) { return QV_ERR_INVLD_ARG; } try { - *ntasks = scope->group_size(); + *group_size = scope->group_size(); return QV_SUCCESS; } qvi_catch_and_return(); diff --git a/src/qvi-group-mpi.cc b/src/qvi-group-mpi.cc index 1de1f10..4f509b7 100644 --- a/src/qvi-group-mpi.cc +++ b/src/qvi-group-mpi.cc @@ -21,14 +21,14 @@ qvi_group_mpi_s::qvi_group_mpi_s(void) { const int rc = qvi_new(&m_task); - if (rc != QV_SUCCESS) throw qvi_runtime_error(); + if (qvi_unlikely(rc != QV_SUCCESS)) throw qvi_runtime_error(); } qvi_group_mpi_s::qvi_group_mpi_s( qvi_mpi_t *mpi_ctx ) : qvi_group_mpi_s() { - if (!mpi_ctx) throw qvi_runtime_error(); + assert(mpi_ctx); m_mpi = mpi_ctx; } @@ -72,13 +72,13 @@ qvi_group_mpi_s::self( // Create and initialize the child with the parent's MPI context. qvi_group_mpi_t *ichild = nullptr; int rc = qvi_new(&ichild, m_mpi); - if (rc != QV_SUCCESS) goto out; + if (qvi_unlikely(rc != QV_SUCCESS)) goto out; // Create the underlying group using MPI_COMM_SELF. rc = qvi_mpi_group_create_from_mpi_comm( m_mpi, MPI_COMM_SELF, &ichild->m_mpi_group ); out: - if (rc != QV_SUCCESS) { + if (qvi_unlikely(rc != QV_SUCCESS)) { qvi_delete(&ichild); } *child = ichild; @@ -94,14 +94,14 @@ qvi_group_mpi_s::split( // Create and initialize the child with the parent's MPI context. qvi_group_mpi_t *ichild = nullptr; int rc = qvi_new(&ichild, m_mpi); - if (rc != QV_SUCCESS) goto out; + if (qvi_unlikely(rc != QV_SUCCESS)) goto out; // Split this group using MPI. rc = qvi_mpi_group_create_from_split( m_mpi, m_mpi_group, color, key, &ichild->m_mpi_group ); out: - if (rc != QV_SUCCESS) { + if (qvi_unlikely(rc != QV_SUCCESS)) { qvi_delete(&ichild); } *child = ichild; diff --git a/src/qvi-split.cc b/src/qvi-hwsplit.cc similarity index 99% rename from src/qvi-split.cc rename to src/qvi-hwsplit.cc index 0b0031c..0406ef8 100644 --- a/src/qvi-split.cc +++ b/src/qvi-hwsplit.cc @@ -8,10 +8,10 @@ */ /** - * @file qvi-split.cc + * @file qvi-hwsplit.cc */ -#include "qvi-split.h" +#include "qvi-hwsplit.h" #include "qvi-bbuff.h" #include "qvi-rmi.h" #include "qvi-bbuff-rmi.h" diff --git a/src/qvi-split.h b/src/qvi-hwsplit.h similarity index 99% rename from src/qvi-split.h rename to src/qvi-hwsplit.h index bf71e05..c49ff17 100644 --- a/src/qvi-split.h +++ b/src/qvi-hwsplit.h @@ -8,11 +8,11 @@ */ /** - * @file qvi-split.h + * @file qvi-hwsplit.h */ -#ifndef QVI_SPLIT_H -#define QVI_SPLIT_H +#ifndef QVI_HWSPLIT_H +#define QVI_HWSPLIT_H #include "qvi-common.h" #include "qvi-hwloc.h" diff --git a/src/qvi-scope.cc b/src/qvi-scope.cc index 87057dc..15f0d35 100644 --- a/src/qvi-scope.cc +++ b/src/qvi-scope.cc @@ -21,7 +21,7 @@ #include "qvi-rmi.h" #include "qvi-task.h" #include "qvi-hwpool.h" -#include "qvi-split.h" +#include "qvi-hwsplit.h" #include "qvi-utils.h" qv_scope_s::qv_scope_s( @@ -67,7 +67,7 @@ scope_new( } int -qv_scope_s::makei( +qv_scope_s::make_intrinsic( qvi_group_t *group, qv_scope_intrinsic_t iscope, qv_scope_t **scope diff --git a/src/qvi-scope.h b/src/qvi-scope.h index 9f97898..4843e40 100644 --- a/src/qvi-scope.h +++ b/src/qvi-scope.h @@ -50,7 +50,7 @@ struct qv_scope_s { ); /** Takes the provided group and creates a new intrinsic scope from it. */ static int - makei( + make_intrinsic( qvi_group_t *group, qv_scope_intrinsic_t iscope, qv_scope_t **scope