Skip to content

Commit 63fe44c

Browse files
Improve RMI code. (#303)
* Improve coding style consistency. * Improve resource usage: 1 fewer thread is spawned by ZMQ. Signed-off-by: Samuel K. Gutierrez <[email protected]>
1 parent 85500df commit 63fe44c

11 files changed

+619
-678
lines changed

src/quo-vadisd.cc

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#include "qvi-rmi.h"
2626

2727
struct context_s {
28-
qvi_rmi_config_s rmic;
28+
qvi_rmi_config rmic;
2929
qvi_hwloc_t *hwloc = nullptr;
30-
qvi_rmi_server_t *rmi = nullptr;
30+
qvi_rmi_server *rmi = nullptr;
3131
bool daemonized = false;
3232
/** Constructor. */
3333
context_s(void)
@@ -37,15 +37,15 @@ struct context_s {
3737
throw qvi_runtime_error();
3838
}
3939

40-
rc = qvi_rmi_server_new(&rmi);
40+
rc = qvi_new(&rmi);
4141
if (rc != QV_SUCCESS) {
4242
throw qvi_runtime_error();
4343
}
4444
}
4545
/** Destructor */
4646
~context_s(void)
4747
{
48-
qvi_rmi_server_delete(&rmi);
48+
qvi_delete(&rmi);
4949
qvi_hwloc_delete(&hwloc);
5050
}
5151
};
@@ -114,9 +114,9 @@ rmi_config(
114114
return;
115115
}
116116

117-
rc = qvi_rmi_server_config(ctx.rmi, &ctx.rmic);
117+
rc = ctx.rmi->configure(ctx.rmic);
118118
if (rc != QV_SUCCESS) {
119-
qvi_panic_log_error("qvi_rmi_server_config() failed");
119+
qvi_panic_log_error("rmi->configure() failed");
120120
return;
121121
}
122122

@@ -132,12 +132,12 @@ rmi_start(
132132

133133
cstr_t ers = nullptr;
134134

135-
int rc = qvi_rmi_server_start(ctx.rmi);
136-
if (rc != QV_SUCCESS) {
135+
const int rc = ctx.rmi->start();
136+
if (qvi_unlikely(rc != QV_SUCCESS)) {
137137
ers = "qvi_rmi_server_start() failed";
138138
}
139139
// TODO(skg) Add flags option
140-
if (ers) {
140+
if (qvi_unlikely(ers)) {
141141
qvi_panic_log_error("{} (rc={}, {})", ers, rc, qv_strerr(rc));
142142
}
143143
}

src/qvi-common.h

+2-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
@@ -72,8 +72,7 @@ struct qvi_bbuff;
7272
struct qvi_hwloc_s;
7373
typedef struct qvi_hwloc_s qvi_hwloc_t;
7474

75-
struct qvi_rmi_client_s;
76-
typedef struct qvi_rmi_client_s qvi_rmi_client_t;
75+
struct qvi_rmi_client;
7776

7877
struct qvi_task;
7978

src/qvi-hwsplit.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ qvi_hwsplit::split_cpuset(
177177
// The cpuset that we are going to split.
178178
const qvi_hwloc_bitmap base_cpuset = cpuset();
179179
// Pointer to my hwloc instance.
180-
qvi_hwloc_t *const hwloc = qvi_rmi_client_hwloc(m_rmi);
180+
qvi_hwloc_t *const hwloc = m_rmi->hwloc();
181181
// Holds the host's split cpusets.
182182
result.resize(m_split_size);
183183
// Notice that we do not go through the RMI for this because this is just an
@@ -258,7 +258,7 @@ qvi_hwsplit::osdev_cpusets(
258258
// Get the number of devices we have available in the provided scope.
259259
int nobj = 0;
260260
int rc = m_hwpool->nobjects(
261-
qvi_rmi_client_hwloc(m_rmi), m_split_at_type, &nobj
261+
m_rmi->hwloc(), m_split_at_type, &nobj
262262
);
263263
if (rc != QV_SUCCESS) return rc;
264264
// Holds the device affinities used for the split.
@@ -470,7 +470,7 @@ qvi_hwsplit::split_user_defined(void)
470470
qvi_map_t map{};
471471
rc = qvi_map_colors(map, m_colors, cpusets);
472472
if (rc != QV_SUCCESS) return rc;
473-
qvi_hwloc_t *const hwloc = qvi_rmi_client_hwloc(m_rmi);
473+
qvi_hwloc_t *const hwloc = m_rmi->hwloc();
474474
// Update the hardware pools and colors to reflect the new mapping.
475475
rc = apply_cpuset_mapping(
476476
hwloc, map, cpusets, m_hwpools, m_colors
@@ -500,7 +500,7 @@ qvi_hwsplit::split_affinity_preserving_pass1(void)
500500
if (qvi_map_nfids_mapped(map) != m_group_size) {
501501
qvi_abort();
502502
}
503-
qvi_hwloc_t *const hwloc = qvi_rmi_client_hwloc(m_rmi);
503+
qvi_hwloc_t *const hwloc = m_rmi->hwloc();
504504
// Update the hardware pools and colors to reflect the new mapping.
505505
return apply_cpuset_mapping(
506506
hwloc, map, cpusets, m_hwpools, m_colors

src/qvi-hwsplit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ struct qvi_hwsplit {
3535
friend qvi_hwsplit_coll;
3636
private:
3737
/** A pointer to my RMI. */
38-
qvi_rmi_client_t *m_rmi = nullptr;
38+
qvi_rmi_client *m_rmi = nullptr;
3939
/** The base hardware pool we are splitting. */
4040
qvi_hwpool *m_hwpool = nullptr;
4141
/** The number of members that are part of the split. */

0 commit comments

Comments
 (0)