Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions test/gtest/common/test_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ ucx_env_cleanup::ucx_env_cleanup() {

if ((env_var.find("=") != std::string::npos) &&
(env_var.find(UCS_DEFAULT_ENV_PREFIX, 0, prefix_len) != std::string::npos)) {
ucx_env_storage.push_back(env_var);
ucx_env_storage.push_back(std::move(env_var));
}
}

Expand Down Expand Up @@ -799,7 +799,7 @@ sock_addr_storage::sock_addr_storage(const ucs_sock_addr_t &ucs_sock_addr,
m_netdev_name = "";
} else {
set_sock_addr(*ucs_sock_addr.addr, ucs_sock_addr.addrlen,
is_rdmacm_netdev, netdev_name);
is_rdmacm_netdev, std::move(netdev_name));
}
}

Expand All @@ -813,7 +813,7 @@ void sock_addr_storage::set_sock_addr(const struct sockaddr &addr,
m_size = size;
m_is_valid = true;
m_is_rdmacm_netdev = is_rdmacm_netdev;
m_netdev_name = netdev_name;
m_netdev_name = std::move(netdev_name);
}

void sock_addr_storage::reset_to_any() {
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/ucm/malloc_hook.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ UCS_TEST_SKIP_COND_F(malloc_hook_cplusplus, mmap_ptrs, RUNNING_ON_VALGRIND) {
*/
while (m_mapped_size == 0) {
std::vector<char> str(size, 'r');
ptrs.push_back(str);
ptrs.push_back(std::move(str));
++large_blocks;
}

Expand Down
2 changes: 1 addition & 1 deletion test/gtest/ucp/test_ucp_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ class test_ucp_devices_config : public ucp_test {
for (const std::string &dev_name : dev_names) {
std::string base_name;
if (get_device_base_name(dev_name, base_name)) {
base_names.insert(base_name);
base_names.insert(std::move(base_name));
}
}
return base_names;
Expand Down
32 changes: 17 additions & 15 deletions test/gtest/ucp/test_ucp_proto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ class test_proto_perf : public ucs::test {
return make_perf_ptr(perf);
}

static void add_funcs(perf_ptr_t perf, size_t start, size_t end,
static void add_funcs(const perf_ptr_t &perf, size_t start, size_t end,
const perf_factors_map_t &factors)
{
ucp_proto_perf_factors_t perf_factors =
Expand All @@ -1339,7 +1339,7 @@ class test_proto_perf : public ucs::test {
perf_factors, perf_node, NULL));
}

static void add_func(perf_ptr_t perf, size_t start, size_t end,
static void add_func(const perf_ptr_t &perf, size_t start, size_t end,
ucp_proto_perf_factor_id_t factor_id,
ucs_linear_func_t func)
{
Expand All @@ -1352,13 +1352,14 @@ class test_proto_perf : public ucs::test {
add_func(m_perf, start, end, factor_id, func);
}

static ucp_proto_perf_segment_t *find_lb(perf_ptr_t perf, size_t start)
static ucp_proto_perf_segment_t *
find_lb(const perf_ptr_t &perf, size_t start)
{
return ucp_proto_perf_find_segment_lb(perf.get(), start);
}

static const ucp_proto_flat_perf_range_t *
find_lb(flat_perf_ptr_t flat_perf, size_t start)
find_lb(const flat_perf_ptr_t &flat_perf, size_t start)
{
return ucp_proto_flat_perf_find_lb(flat_perf.get(), start);
}
Expand Down Expand Up @@ -1443,8 +1444,8 @@ class test_proto_perf : public ucs::test {
}

template<typename PerfPtrType>
void
expect_perf_empty_range(PerfPtrType perf, size_t start, size_t end) const
void expect_perf_empty_range(const PerfPtrType &perf, size_t start,
size_t end) const
{
ASSERT_NE(perf.get(), nullptr);
auto *seg = find_lb(perf, start);
Expand All @@ -1454,8 +1455,8 @@ class test_proto_perf : public ucs::test {
<< " end=" << end;
}

void expect_flat_range(flat_perf_ptr_t flat_perf, size_t start, size_t end,
ucs_linear_func_t exp_func) const
void expect_flat_range(const flat_perf_ptr_t &flat_perf, size_t start,
size_t end, ucs_linear_func_t exp_func) const
{
auto *range = find_lb(flat_perf, start);
size_t midpoint = start + (end - start) / 2;
Expand Down Expand Up @@ -1714,7 +1715,7 @@ UCS_TEST_F(test_proto_perf, agg2)
local_cpu_func);
UCS_TEST_MESSAGE << perf2.get();

m_perf = aggregate({perf1, perf2});
m_perf = aggregate({std::move(perf1), std::move(perf2)});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: the std::vector parameter is built from an initializer_list, whose elements are const, so each shared_ptr is still copied into the vector - the move here only clears perf1/perf2. Same at line 1758.


make_flat_perf();
print_perf();
Expand Down Expand Up @@ -1754,7 +1755,7 @@ UCS_TEST_F(test_proto_perf, agg3)
local_cpu_func);
UCS_TEST_MESSAGE << perf3.get();

m_perf = aggregate({perf1, perf2, perf3});
m_perf = aggregate({std::move(perf1), std::move(perf2), std::move(perf3)});

make_flat_perf();
print_perf();
Expand Down Expand Up @@ -1917,7 +1918,7 @@ class test_proto_perf_aggregate : public test_proto_perf_random {

private:
// Collect points of sampling based on perf structure segments
static std::vector<size_t> get_sample_points(perf_ptr_t perf);
static std::vector<size_t> get_sample_points(const perf_ptr_t &perf);

// Calculate the expected aggregation result at a given point. If the
// expected result is undefined, return nullptr.
Expand All @@ -1927,7 +1928,7 @@ class test_proto_perf_aggregate : public test_proto_perf_random {
};

std::vector<size_t>
test_proto_perf_aggregate::get_sample_points(perf_ptr_t perf)
test_proto_perf_aggregate::get_sample_points(const perf_ptr_t &perf)
{
std::vector<size_t> points;

Expand Down Expand Up @@ -1957,7 +1958,7 @@ test_proto_perf_aggregate::expected_aggregate_result(
const std::vector<perf_ptr_t> &perfs, size_t point)
{
perf_factors_map_t agg;
for (auto perf : perfs) {
for (const auto &perf : perfs) {
ucp_proto_perf_segment_t *seg = find_lb(perf, point);
if ((seg == NULL) || (point < ucp_proto_perf_segment_start(seg))) {
return nullptr; // Point not found in one of the perf objects
Expand All @@ -1977,7 +1978,8 @@ test_proto_perf_aggregate::expected_aggregate_result(
}
}

return std::unique_ptr<perf_factors_map_t>(new perf_factors_map_t(agg));
return std::unique_ptr<perf_factors_map_t>(
new perf_factors_map_t(std::move(agg)));
}

void test_proto_perf_aggregate::test_random_funcs(unsigned num_perfs,
Expand All @@ -1990,7 +1992,7 @@ void test_proto_perf_aggregate::test_random_funcs(unsigned num_perfs,
});

std::set<size_t> sample_points;
for (auto perf : perfs) {
for (const auto &perf : perfs) {
auto perf_points = get_sample_points(perf);
std::copy(perf_points.begin(), perf_points.end(),
std::inserter(sample_points, sample_points.begin()));
Expand Down
4 changes: 2 additions & 2 deletions test/gtest/ucp/test_ucp_proto_mock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ class test_ucp_proto_mock : public ucp_test, public mock_iface {
std::string desc, std::string config) :
range_start(range_start),
range_end(range_end),
desc(desc),
config(config){};
desc(std::move(desc)),
config(std::move(config)){};

bool operator==(const proto_select_data &other) const
{
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/ucp/test_ucp_sockaddr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,7 @@ UCS_TEST_P(test_ucp_sockaddr, listen_inaddr_any) {
/* get the actual port which was selected by listener */
test_addr.set_port(m_test_addr.get_port());
/* restore address */
m_test_addr = test_addr;
m_test_addr = std::move(test_addr);
connect_and_send_recv(false, SEND_DIRECTION_C2S);
}

Expand Down
4 changes: 2 additions & 2 deletions test/gtest/ucp/ucp_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ void ucp_test::add_variant_value(std::vector<ucp_test_variant_value>& values,
int value, const std::string& name)
{
ucp_test_variant_value entry = {value, name};
values.push_back(entry);
values.push_back(std::move(entry));
}

void ucp_test::add_variant_with_value(std::vector<ucp_test_variant>& variants,
Expand Down Expand Up @@ -549,7 +549,7 @@ ucp_test::enum_test_params(const std::vector<ucp_test_variant>& variants,
while (ss.good()) {
std::string tl_name;
std::getline(ss, tl_name, ',');
result.back().transports.push_back(tl_name);
result.back().transports.push_back(std::move(tl_name));
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/gtest/ucs/test_topo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -915,7 +915,7 @@ UCS_TEST_F(test_topo, sibling) {
auto gpu = m_gpus[0];
if (!sibling_dma.empty()) {
dma = sibling_dma;
gpu = sibling_gpu;
gpu = std::move(sibling_gpu);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: can we keep this a copy? gpu = std::move(sibling_gpu) while the line above keeps dma = sibling_dma as a copy. The copy there is mandatory because sibling_dma.empty() is tested again later (line 943), so moving only the gpu string is asymmetric, gains nothing, and hides that constraint — a later "cleanup" that also moves sibling_dma would silently flip the branch.

Comment thread
william-gallagher-nv marked this conversation as resolved.
Resolved
UCS_TEST_MESSAGE << "Found sibling "
<< "dma=" << dma << " gpu=" << gpu;
}
Expand Down
4 changes: 2 additions & 2 deletions test/gtest/ucs/test_topo_groups.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class test_topo_groups : public ucs::test {
numa.numa_node, user_value));
}

numa.gpus.push_back(gpu_devices);
numa.gpus.push_back(std::move(gpu_devices));
}
}

Expand All @@ -166,7 +166,7 @@ class test_topo_groups : public ucs::test {
UCS_SYS_DEVICE_USER_VALUE_EMPTY));
}

numa.nics.push_back(nic_ports);
numa.nics.push_back(std::move(nic_ports));
}
}

Expand Down
21 changes: 11 additions & 10 deletions test/gtest/uct/ib/test_srd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class test_srd : public uct_test {
int c = 1;
completion comp[2];

auto noop = [](void *arg, void *data, size_t length, unsigned flags) {
auto noop = [](void *arg, void *data, size_t length, unsigned) {
return UCS_OK;
};

Expand Down Expand Up @@ -329,15 +329,16 @@ UCS_TEST_P(test_srd, am_short_iov_failure)
scoped_log_handler slh(wrap_errors_logger);
char payload[64];
ucs_status_t status;
uct_iov_t iov;
uct_iov_t iov[2] = {};

status = uct_ep_am_short_iov(m_e1->ep(0), 32, &iov, 1);
status = uct_ep_am_short_iov(m_e1->ep(0), 32, iov, 1);
ASSERT_UCS_STATUS_EQ(UCS_ERR_INVALID_PARAM, status);
status = uct_ep_am_short_iov(m_e1->ep(0), 14, &iov, 2);
iov.length = sizeof(payload);
iov.buffer = payload;
iov.count = 1;
status = uct_ep_am_short_iov(m_e1->ep(0), 14, &iov, 1);
status = uct_ep_am_short_iov(m_e1->ep(0), 14, iov, 2);
ASSERT_UCS_STATUS_EQ(UCS_ERR_INVALID_PARAM, status);
iov[0].length = sizeof(payload);
iov[0].buffer = payload;
iov[0].count = 1;
status = uct_ep_am_short_iov(m_e1->ep(0), 14, iov, 1);
ASSERT_UCS_STATUS_EQ(UCS_ERR_INVALID_PARAM, status);
}

Expand All @@ -362,7 +363,7 @@ UCS_TEST_P(test_srd, am_zcopy_failure)
{
scoped_log_handler slh(wrap_errors_logger);
ucs_status_t status;
uct_iov_t iov[3];
uct_iov_t iov[3] = {};

for (auto i = 0; i < 3; ++i) {
iov[i].length = 64;
Expand Down Expand Up @@ -394,7 +395,7 @@ UCS_TEST_P(test_srd, get_bcopy_failure)
UCS_TEST_P(test_srd, get_zcopy_failure)
{
scoped_log_handler slh(wrap_errors_logger);
uct_iov_t iov[3];
uct_iov_t iov[3] = {};
ucs_status_t status;

for (auto i = 0; i < 3; ++i) {
Expand Down
5 changes: 3 additions & 2 deletions test/gtest/uct/test_amo_add_xor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ class uct_amo_add_xor_test : public uct_amo_test {
}
}

run_workers(static_cast<send_func_t>(&uct_amo_test::atomic_op<T, opcode>),
recvbuf, add_vec, true);
run_workers(static_cast<send_func_t>(
&uct_amo_test::atomic_op<T, opcode>),
recvbuf, std::move(add_vec), true);

wait_for_remote();
EXPECT_EQ(exp_result, *(T*)recvbuf.ptr());
Expand Down
5 changes: 3 additions & 2 deletions test/gtest/uct/test_amo_and_or.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ class uct_amo_and_or_test : public uct_amo_test {
}
}

run_workers(static_cast<send_func_t>(&uct_amo_test::atomic_op<T, opcode>),
recvbuf, op_vec, false);
run_workers(static_cast<send_func_t>(
&uct_amo_test::atomic_op<T, opcode>),
recvbuf, std::move(op_vec), false);

wait_for_remote();
EXPECT_EQ(exp_result, *(T*)recvbuf.ptr());
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/uct/test_amo_swap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class uct_amo_swap_test : public uct_amo_test {
}
}

run_workers(send, recvbuf, swap_vec, true);
run_workers(send, recvbuf, std::move(swap_vec), true);

wait_for_remote();
add_reply_safe(*(T*)recvbuf.ptr());
Expand Down
2 changes: 1 addition & 1 deletion test/gtest/uct/test_uct_perf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ class test_uct_loopback_cuda : public test_uct_perf {

/* gdr_copy test supports from host to GPU mem case only */
if (has_transport("gdr_copy")) {
result.push_back(input);
result.push_back(std::move(input));
} else if (has_transport("cuda_ipc")) {
/* cuda_ipc test only supports GPU-GPU case */
result.push_back({UCS_MEMORY_TYPE_CUDA, UCS_MEMORY_TYPE_CUDA});
Expand Down