Skip to content

API/UCP/UCT/IODEMO: Add functions to query the ucp and uct endpoints - #7020

Merged
yosefe merged 1 commit into
openucx:masterfrom
leibin2014:qpn
Aug 3, 2021
Merged

yosefe merged 1 commit into
openucx:masterfrom
leibin2014:qpn

Conversation

@leibin2014

Copy link
Copy Markdown
Contributor

What

Add functions to query the ucp and uct endpoints

Why ?

Sometimes users need API to get remote and local IP/port per endpoint

How ?

Get the remote and local IP/port through RDMA_CM

@leibin2014

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 2 pipeline(s).

@leibin2014

Copy link
Copy Markdown
Contributor Author

bot:pipe:retest

@leibin2014
leibin2014 requested a review from yosefe July 5, 2021 16:48

@yosefe yosefe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pls also add gtest for UCP and UCT query

Comment thread src/ucp/api/ucp.h Resolved
Comment thread src/ucp/api/ucp.h Resolved
Comment thread src/ucp/api/ucp.h Resolved
Comment thread src/ucp/core/ucp_ep.c Resolved
Comment thread src/ucs/sys/sock.c Outdated
Comment on lines +858 to +863
if (!ucs_sockaddr_is_known_af(src_addr)) {
memset(dst_addr, 0, sizeof(*dst_addr));
} else {
status = ucs_sockaddr_copy(dst_addr, src_addr);
ucs_assert_always(status == UCS_OK);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

if AF not known ucs_sockaddr_copy would fail anyway

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yosefe Yes, so ucs_sockaddr_copy is called only when AF is known. What we should change here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yosefe Or do you mean no need to check the condition ucs_sockaddr_is_known_af(src_addr), just do ucs_sockaddr_copy() anyway?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, no need to define ucp_sockaddr_copy_always() function
also it's ucs function so should have been ucs_sockaddr_copy_always

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@yosefe Done

Comment thread src/uct/tcp/tcp_sockcm.c Resolved
Comment thread test/apps/iodemo/ucx_wrapper.cc Resolved
Comment thread test/apps/iodemo/ucx_wrapper.cc Resolved
Comment thread test/apps/iodemo/ucx_wrapper.cc Resolved
Comment thread test/apps/iodemo/ucx_wrapper.cc Resolved
@yosefe yosefe added the API label Jul 6, 2021
@leibin2014

Copy link
Copy Markdown
Contributor Author

bot:pipe:retest

Comment thread src/ucp/core/ucp_ep.c Resolved
Comment thread src/ucp/core/ucp_ep.c Resolved
Comment thread src/ucs/sys/sock.c Outdated
Comment on lines +858 to +863
if (!ucs_sockaddr_is_known_af(src_addr)) {
memset(dst_addr, 0, sizeof(*dst_addr));
} else {
status = ucs_sockaddr_copy(dst_addr, src_addr);
ucs_assert_always(status == UCS_OK);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

yes, no need to define ucp_sockaddr_copy_always() function
also it's ucs function so should have been ucs_sockaddr_copy_always

Comment thread src/uct/api/tl.h Resolved
Comment thread src/uct/api/v2/uct_v2.h Resolved
Comment thread test/apps/iodemo/ucx_wrapper.cc Resolved
Comment thread test/gtest/ucp/test_ucp_sockaddr.cc Resolved
Comment thread test/gtest/ucp/test_ucp_sockaddr.cc Resolved
Comment thread test/gtest/ucp/test_ucp_sockaddr.cc Resolved
Comment thread test/gtest/uct/ib/test_sockaddr.cc Resolved
Comment thread src/ucp/core/ucp_ep.c Resolved
Comment thread test/gtest/ucp/test_ucp_sockaddr.cc Resolved
@leibin2014

Copy link
Copy Markdown
Contributor Author

bot:pipe:retest

@yosefe

yosefe commented Jul 27, 2021

Copy link
Copy Markdown
Member

@shamisp @tonycurtis can you pls take a look?

Comment thread src/ucs/sys/sock.h Outdated
Comment on lines +438 to +439
* @return ip_str if the sock_addr has a valid IP address or 'Invalid address'
* otherwise.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

minor: it returns UCS_OK if sock_addr has a valid IP address

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brminich Fixed.

Comment thread src/uct/base/uct_cm.c Outdated
Comment on lines +289 to +301
self->ops = ops;
self->component = component;
self->iface.super.ops = *iface_ops;
self->iface.internal_ops = internal_ops;
self->iface.worker = ucs_derived_of(worker, uct_priv_worker_t);

self->iface.md = NULL;
self->iface.am->arg = NULL;
self->iface.am->flags = 0;
self->iface.am->cb = (uct_am_callback_t)ucs_empty_function_return_unsupported;
self->iface.am_tracer = NULL;
self->iface.am_tracer_arg = NULL;
self->iface.err_handler = NULL;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this whole block can be moved one space left, as it was before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@brminich Good catch. Thanks!

Comment thread src/ucp/api/ucp.h
* Local socket address for this endpoint. Valid only for endpoints created
* by connecting to a socket address.
*/
struct sockaddr_storage local_sockaddr;

@shamisp shamisp Jul 27, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what happens if ep is not connected to a socket address ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shamisp Return UCS_ERR_NOT_CONNECTED

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So the API is valid for all endpoint and if the socket was not connected using socket cm UCS_ERR_NOT_CONNECTED is not returned. This has to be properly documented.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shamisp I guess there is some misunderstanding here. We always use socket address to connect. But the EP's status can have two cases:

  1. If the EP is connected, then the API is valid to get local sockaddr and remote sockaddr as documented above, and return UCS_OK.
  2. If the EP is not connected, then return UCS_ERR_NOT_CONNECTED as the error status.

I added this description according to @yosefe 's comment #7020 (comment).
@yosefe Please correct me if I made any misunderstanding about the description.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

there are cases when ep is connecting to worker address (not socket address) so there is no CM lane and we are returning UCS_ERR_NOT_CONNECTED. That's why we wrote "Valid only for endpoints created by connecting to a socket address." Perhaps should add "If this field is specified for an endpoint not connected to a socket address, the behavior is undefined" or ".. UCS_ERR_NOT_CONNECTED will be returned"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shamisp @yosefe Added. Thanks for the comments!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yosefe "behavior is undefined" is the worse ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shamisp I added "If this field is specified for an endpoint not connected to a socket address, UCS_ERR_NOT_CONNECTED will be returned."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@shamisp Could please approve this PR? Let me know please if you have any more comments. Thanks!

@shamisp

shamisp commented Jul 27, 2021

Copy link
Copy Markdown
Contributor

I'm a bit concerned that we are exposing an API that is only useful for "some" endpoints connected using CM or sockets. Can you please clarify your use case beyond: Sometimes users need API to get remote and local IP/port per endpoint. thanks

@leibin2014

leibin2014 commented Jul 28, 2021 •

Copy link
Copy Markdown
Contributor Author

I'm a bit concerned that we are exposing an API that is only useful for "some" endpoints connected using CM or sockets. Can you please clarify your use case beyond: Sometimes users need API to get remote and local IP/port per endpoint. thanks

@shamisp We provided this API to one customer in an separate branch before. Recently another Chinese customer also needs this API. Their argument is that socket has similar API getsockname(). Generally, I agree this API is useful for most of users.

@shamisp
shamisp self-requested a review July 30, 2021 16:13
@shamisp

shamisp commented Jul 30, 2021

Copy link
Copy Markdown
Contributor

@tonycurtis can you please review documentation. thanks

@yosefe yosefe left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pls squash

@leibin2014
leibin2014 force-pushed the qpn branch 3 times, most recently from ad5a4e6 to 62cde3a Compare August 2, 2021 04:31
@leibin2014

Copy link
Copy Markdown
Contributor Author

pls squash

@yosefe Done

@yosefe
yosefe merged commit fdad746 into openucx:master Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants