Skip to content

Commit ad45a42

Browse files
Cleanup some code. (#293)
Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent f887804 commit ad45a42

16 files changed

+56
-54
lines changed

include/quo-vadis-pthread.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2022-2024 Triad National Security, LLC
3+
* Copyright (c) 2022-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2022-2024 Inria
@@ -37,7 +37,7 @@ extern "C" {
3737
// - scatter: threads are distributed as evenly as possible across the entire system.
3838
// (opposite of compact).
3939
// - explicit: threads are placed according to a list of OS proc IDs (required)
40-
typedef enum qv_policy_s {
40+
typedef enum {
4141
QV_POLICY_PACKED = 1,
4242
QV_POLICY_COMPACT = 1,
4343
QV_POLICY_CLOSE = 1,
@@ -48,6 +48,8 @@ typedef enum qv_policy_s {
4848
QV_POLICY_SCATTER = 4,
4949
QV_POLICY_CHOOSE = 5,
5050
} qv_policy_t;
51+
// TODO(skg) Consider updating prefix to qv_pthread_ if this is only used for
52+
// Pthread code.
5153

5254
/**
5355
* Similar to pthread_create(3).

src/qvi-bbuff.h

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -21,6 +21,12 @@
2121

2222
#include "qvi-common.h"
2323

24+
typedef enum {
25+
QVI_BBUFF_ALLOC_SHARED = 0,
26+
QVI_BBUFF_ALLOC_SHARED_GLOBAL,
27+
QVI_BBUFF_ALLOC_PRIVATE
28+
} qvi_bbuff_alloc_type_t;
29+
2430
struct qvi_bbuff {
2531
private:
2632
/** Minimum growth in bytes for resizes, etc. */
@@ -84,14 +90,6 @@ qvi_bbuff_delete(
8490
qvi_bbuff **buff
8591
);
8692

87-
enum qvi_alloc_s {
88-
ALLOC_SHARED = 0,
89-
ALLOC_SHARED_GLOBAL,
90-
ALLOC_PRIVATE,
91-
};
92-
93-
typedef enum qvi_alloc_s qvi_alloc_type_t;
94-
9593
#endif
9694

9795
/*

src/qvi-group-mpi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -85,11 +85,11 @@ struct qvi_group_mpi : public qvi_group {
8585
gather(
8686
qvi_bbuff *txbuff,
8787
int root,
88-
qvi_alloc_type_t *shared,
88+
qvi_bbuff_alloc_type_t *alloc_type,
8989
qvi_bbuff ***rxbuffs
9090
) {
9191
return qvi_mpi_group_gather_bbuffs(
92-
m_mpi_group, txbuff, root, shared, rxbuffs
92+
m_mpi_group, txbuff, root, alloc_type, rxbuffs
9393
);
9494
}
9595

src/qvi-group-omp.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2022 Inria
@@ -91,10 +91,10 @@ struct qvi_group_omp : public qvi_group {
9191
gather(
9292
qvi_bbuff *txbuff,
9393
int root,
94-
qvi_alloc_type_t *shared,
94+
qvi_bbuff_alloc_type_t *alloc_type,
9595
qvi_bbuff ***rxbuffs
9696
) {
97-
return m_ompgroup->gather(txbuff, root, shared, rxbuffs);
97+
return m_ompgroup->gather(txbuff, root, alloc_type, rxbuffs);
9898
}
9999

100100
virtual int

src/qvi-group-process.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -86,11 +86,11 @@ struct qvi_group_process : public qvi_group {
8686
gather(
8787
qvi_bbuff *txbuff,
8888
int root,
89-
qvi_alloc_type_t *shared,
89+
qvi_bbuff_alloc_type_t *alloc_type,
9090
qvi_bbuff ***rxbuffs
9191
) {
9292
return qvi_process_group_gather_bbuffs(
93-
m_proc_group, txbuff, root, shared, rxbuffs
93+
m_proc_group, txbuff, root, alloc_type, rxbuffs
9494
);
9595
}
9696

src/qvi-group-pthread.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -88,11 +88,11 @@ struct qvi_group_pthread : public qvi_group {
8888
gather(
8989
qvi_bbuff *txbuff,
9090
int root,
91-
qvi_alloc_type_t *shared,
91+
qvi_bbuff_alloc_type_t *alloc_type,
9292
qvi_bbuff ***rxbuffs
9393
) {
9494
return thgroup->gather(
95-
txbuff, root, shared, rxbuffs
95+
txbuff, root, alloc_type, rxbuffs
9696
);
9797
}
9898

src/qvi-group.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2021-2024 Triad National Security, LLC
3+
* Copyright (c) 2021-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2021 Lawrence Livermore National Security, LLC
@@ -83,7 +83,7 @@ struct qvi_group : qvi_refc {
8383
gather(
8484
qvi_bbuff *txbuff,
8585
int root,
86-
qvi_alloc_type_t *shared,
86+
qvi_bbuff_alloc_type_t *alloc_type,
8787
qvi_bbuff ***rxbuffs
8888
) = 0;
8989
/** Scatters bbuffs from specified root. */

src/qvi-hwsplit.cc

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2021-2024 Triad National Security, LLC
3+
* Copyright (c) 2021-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -694,9 +694,9 @@ qvi_hwsplit_coll::gather_values(
694694
return rc;
695695
}
696696
// Gather the values to the root.
697-
qvi_alloc_type_t shared = ALLOC_PRIVATE;
697+
qvi_bbuff_alloc_type_t alloc_type = QVI_BBUFF_ALLOC_PRIVATE;
698698
qvi_bbuff **bbuffs = nullptr;
699-
rc = group->gather(txbuff, rootid, &shared, &bbuffs);
699+
rc = group->gather(txbuff, rootid, &alloc_type, &bbuffs);
700700
if (qvi_unlikely(rc != QV_SUCCESS)) goto out;
701701
// The root fills in the output.
702702
if (group->rank() == rootid) {
@@ -707,7 +707,8 @@ qvi_hwsplit_coll::gather_values(
707707
}
708708
}
709709
out:
710-
if ((ALLOC_PRIVATE == shared) || ((ALLOC_SHARED == shared) && (group->rank() == rootid))) {
710+
if ((QVI_BBUFF_ALLOC_PRIVATE == alloc_type) ||
711+
((QVI_BBUFF_ALLOC_SHARED == alloc_type) && (group->rank() == rootid))) {
711712
if (bbuffs) {
712713
for (uint_t i = 0; i < group_size; ++i) {
713714
qvi_bbuff_delete(&bbuffs[i]);
@@ -736,9 +737,9 @@ qvi_hwsplit_coll::gather_hwpools(
736737
int rc = txpool->packinto(&txbuff);
737738
if (qvi_unlikely(rc != QV_SUCCESS)) return rc;
738739
// Gather the values to the root.
739-
qvi_alloc_type_t shared = ALLOC_PRIVATE;
740+
qvi_bbuff_alloc_type_t alloc_type = QVI_BBUFF_ALLOC_PRIVATE;
740741
qvi_bbuff **bbuffs = nullptr;
741-
rc = group->gather(&txbuff, rootid, &shared, &bbuffs);
742+
rc = group->gather(&txbuff, rootid, &alloc_type, &bbuffs);
742743
if (rc != QV_SUCCESS) goto out;
743744

744745
if (group->rank() == rootid) {
@@ -752,7 +753,8 @@ qvi_hwsplit_coll::gather_hwpools(
752753
}
753754
}
754755
out:
755-
if ((ALLOC_PRIVATE == shared) || ((ALLOC_SHARED == shared) && (group->rank() == rootid))) {
756+
if ((QVI_BBUFF_ALLOC_PRIVATE == alloc_type) ||
757+
((QVI_BBUFF_ALLOC_SHARED == alloc_type) && (group->rank() == rootid))) {
756758
if (bbuffs) {
757759
for (uint_t i = 0; i < group_size; ++i) {
758760
qvi_bbuff_delete(&bbuffs[i]);

src/qvi-mpi.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -365,7 +365,7 @@ qvi_mpi_group_gather_bbuffs(
365365
qvi_mpi_group_t *group,
366366
qvi_bbuff *txbuff,
367367
int root,
368-
qvi_alloc_type_t *shared_alloc,
368+
qvi_bbuff_alloc_type_t *alloc_type,
369369
qvi_bbuff ***rxbuffs
370370
) {
371371
const int send_count = (int)txbuff->size();
@@ -386,7 +386,7 @@ qvi_mpi_group_gather_bbuffs(
386386
rxcounts.data(), 1, MPI_INT,
387387
root, group->qvcomm.mpi_comm
388388
);
389-
if (mpirc != MPI_SUCCESS) {
389+
if (qvi_unlikely(mpirc != MPI_SUCCESS)) {
390390
rc = QV_ERR_MPI;
391391
goto out;
392392
}
@@ -407,7 +407,7 @@ qvi_mpi_group_gather_bbuffs(
407407
allbytes.data(), rxcounts.data(), displs.data(), MPI_UINT8_T,
408408
root, group->qvcomm.mpi_comm
409409
);
410-
if (mpirc != MPI_SUCCESS) {
410+
if (qvi_unlikely(mpirc != MPI_SUCCESS)) {
411411
rc = QV_ERR_MPI;
412412
goto out;
413413
}
@@ -424,7 +424,7 @@ qvi_mpi_group_gather_bbuffs(
424424
}
425425
}
426426
out:
427-
if (rc != QV_SUCCESS) {
427+
if (qvi_unlikely(rc != QV_SUCCESS)) {
428428
if (bbuffs) {
429429
for (int i = 0; i < group_size; ++i) {
430430
qvi_bbuff_delete(&bbuffs[i]);
@@ -434,7 +434,7 @@ qvi_mpi_group_gather_bbuffs(
434434
bbuffs = nullptr;
435435
}
436436
*rxbuffs = bbuffs;
437-
*shared_alloc = ALLOC_PRIVATE;
437+
*alloc_type = QVI_BBUFF_ALLOC_PRIVATE;
438438
return rc;
439439
}
440440

src/qvi-mpi.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC
@@ -152,7 +152,7 @@ qvi_mpi_group_gather_bbuffs(
152152
qvi_mpi_group_t *group,
153153
qvi_bbuff *txbuff,
154154
int root,
155-
qvi_alloc_type_t *shared_alloc,
155+
qvi_bbuff_alloc_type_t *alloc_type,
156156
qvi_bbuff ***rxbuffs
157157
);
158158

src/qvi-omp.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2022-2024 Triad National Security, LLC
3+
* Copyright (c) 2022-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2022-2024 Inria
@@ -159,7 +159,7 @@ int
159159
qvi_omp_group::gather(
160160
qvi_bbuff *txbuff,
161161
int,
162-
qvi_alloc_type_t *shared_alloc,
162+
qvi_bbuff_alloc_type_t *alloc_type,
163163
qvi_bbuff ***rxbuffs
164164
) {
165165
qvi_bbuff **bbuffs = nullptr;
@@ -180,7 +180,7 @@ qvi_omp_group::gather(
180180
bbuffs = nullptr;
181181
}
182182
*rxbuffs = bbuffs;
183-
*shared_alloc = ALLOC_SHARED;
183+
*alloc_type = QVI_BBUFF_ALLOC_SHARED;
184184
return rc;
185185
}
186186

src/qvi-omp.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* Copyright (c) 2022 Inria
@@ -105,7 +105,7 @@ struct qvi_omp_group {
105105
gather(
106106
qvi_bbuff *txbuff,
107107
int root,
108-
qvi_alloc_type_t*shared,
108+
qvi_bbuff_alloc_type_t *alloc_type,
109109
qvi_bbuff ***rxbuffs
110110
);
111111

src/qvi-process.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ qvi_process_group_gather_bbuffs(
6363
qvi_process_group_t *group,
6464
qvi_bbuff *txbuff,
6565
int root,
66-
qvi_alloc_type_t *shared,
66+
qvi_bbuff_alloc_type_t *shared,
6767
qvi_bbuff ***rxbuffs
6868
) {
6969
const int group_size = qvi_process_group_size(group);
@@ -84,7 +84,7 @@ qvi_process_group_gather_bbuffs(
8484
bbuffs = nullptr;
8585
}
8686
*rxbuffs = bbuffs;
87-
*shared = ALLOC_PRIVATE;
87+
*shared = QVI_BBUFF_ALLOC_PRIVATE;
8888
return rc;
8989
}
9090

src/qvi-process.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2020-2024 Triad National Security, LLC
3+
* Copyright (c) 2020-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -69,7 +69,7 @@ qvi_process_group_gather_bbuffs(
6969
qvi_process_group_t *group,
7070
qvi_bbuff *txbuff,
7171
int root,
72-
qvi_alloc_type_t *shared,
72+
qvi_bbuff_alloc_type_t *alloc_type,
7373
qvi_bbuff ***rxbuffs
7474
);
7575

src/qvi-pthread.cc

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */
22
/*
3-
* Copyright (c) 2024 Triad National Security, LLC
3+
* Copyright (c) 2024-2025 Triad National Security, LLC
44
* All rights reserved.
55
*
66
* This file is part of the quo-vadis project. See the LICENSE file at the
@@ -224,13 +224,13 @@ int
224224
qvi_pthread_group::gather(
225225
qvi_bbuff *txbuff,
226226
int,
227-
qvi_alloc_type_t *shared_alloc,
227+
qvi_bbuff_alloc_type_t *alloc_type,
228228
qvi_bbuff ***rxbuffs
229229
) {
230230
const int rc = qvi_bbuff_copy(*txbuff, m_data_g[rank()]);
231231
// Need to ensure that all threads have contributed to m_data_g
232232
pthread_barrier_wait(&m_barrier);
233-
*shared_alloc = ALLOC_SHARED_GLOBAL;
233+
*alloc_type = QVI_BBUFF_ALLOC_SHARED_GLOBAL;
234234

235235
if (qvi_unlikely(rc != QV_SUCCESS)) {
236236
*rxbuffs = nullptr;

0 commit comments

Comments
 (0)