Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TEST/PROTO: Reset request tests for offset = 0 #9553

Merged
merged 1 commit into from
Jan 7, 2024

Conversation

shasson5
Copy link
Contributor

What

Reset request tests for offset = 0

Why ?

First phase for reset in the middle PR.

@shasson5 shasson5 requested a review from yosefe December 18, 2023 18:06
@shasson5 shasson5 changed the title UCP/PROTO: Reset request tests for offset = 0 TEST/PROTO: Reset request tests for offset = 0 Dec 19, 2023

static void flushed_cb(ucp_request_t *request)
{
test_proto_reset *self = (test_proto_reset*)request->user_data;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: C++ static_cast instead of C-cast would be more idiomatic here

ucp_request_release(request);
}

void send_nb(std::vector<char> &sbuf, std::vector<char> *rbuf_p,
Copy link
Contributor

Choose a reason for hiding this comment

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

why not to pass rbuf by reference?

Copy link
Contributor Author

@shasson5 shasson5 Dec 26, 2023

Choose a reason for hiding this comment

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

code changed (using mapped_buffer now)

ucp_request_param_t param = {0};
void *rreq = NULL;
void *sreq = NULL;
std::vector<char> &rbuf = *rbuf_p;
Copy link
Contributor

Choose a reason for hiding this comment

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

This variable seems to be redundant

return UCS_OK;
}

void *send_am(std::vector<char> &sbuf, std::vector<char> *rbuf_p)
Copy link
Contributor

Choose a reason for hiding this comment

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

better pass rbuf by reference here?

{
std::vector<char> *rbuf = (std::vector<char>*)arg;

memcpy((*rbuf).data(), data, length);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm afraid this might not be always safe, what if vector size is smaller than length?
better alternative is to use std::vector::assign(data, data + length)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rbuf was changed to be a mapped_buffer object so instead I added an assertion on the size

continue;
}

memcpy(&rbuf[roffset], rdata, length);
Copy link
Contributor

Choose a reason for hiding this comment

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

In general it's not safe to append elements to vector like that, it disrespects vector invariants.
Why not using std::vector::insert that accepts a range?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I use a different API now (ucp_stream_recv_nbx) so memcpy is not needed at all

void *rreq = NULL;
void *sreq = NULL;
std::vector<char> &rbuf = *rbuf_p;
sbuf.resize(m_msg_size);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe here we can just reserve, not resize?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

code was changed (now init the array inside a for loop).

test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/ucp_test.cc Show resolved Hide resolved
@shasson5 shasson5 requested review from yosefe and iyastreb December 26, 2023 14:06
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
@shasson5 shasson5 requested a review from yosefe December 27, 2023 12:23
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
@shasson5 shasson5 requested a review from yosefe December 28, 2023 14:28
test/gtest/uct/ib/test_ib.cc Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
@shasson5 shasson5 requested a review from yosefe December 31, 2023 12:07
yosefe
yosefe previously approved these changes Dec 31, 2023
yosefe
yosefe previously approved these changes Dec 31, 2023
test/gtest/ucp/test_ucp_request.cc Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_request.cc Outdated Show resolved Hide resolved
@yosefe yosefe enabled auto-merge January 4, 2024 10:12
@yosefe yosefe merged commit 1dbcdf0 into openucx:master Jan 7, 2024
118 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants