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

UCP/PROTO: Fix RNDV_SCHEME logic #10230

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

ivankochin
Copy link
Contributor

@ivankochin ivankochin commented Oct 15, 2024

What

Change RNDV_SCHEME and RNDV_THRESH logic to work properly.

Why ?

Currently if user set certain RNDV_SCHEME without setting RNDV_THRESH this scheme would be forced on all sizes since cfg_thresh for this protocol would be 0. This change fixes that.

How ?

With this change remote variant can report only 2 values as cfg_thresh: AUTO and INF. AUTO reported for:

  • all protocols if RNDV_SCHEME=auto
  • protocol that is set in RNDV_SCHEME

INF is reported for all protocols that are not set in RNDV_SCHEME if RNDV_SCHEME is set to some certain protocol.

Manual testing cases:

RNDV_THRESH RNDV_SCHEME RESULT
AUTO AUTO All protocols are selected basing on perf comparison
AUTO GET_ZCOPY No hard thresh, but only GET_ZCOPY protocol participates in proto selection
AUTO PUT_ZCOPY No hard thresh, but only GET_ZCOPY protocol participates in proto selection
1024 AUTO Starting from 1024 RNDV is forced but which RNDV protocol would be used decided by proto selection
1024 GET_ZCOPY RNDV_GET used starting from 1024
1024 PUT_ZCOPY RNDV_PUT used starting from 1024
INF AUTO RNDV is not used
INF GET_ZCOPY RNDV is not used
INF PUT_ZCOPY RNDV is not used

@ivankochin ivankochin self-assigned this Oct 15, 2024
@ivankochin
Copy link
Contributor Author

I think it worth covering this logic by tests. If we merge #9989 it would allow to cover it by the following way:

UCS_TEST_P(test_ucp_proto_mock, rndv_thresh, "RNDV_THRESH=1024", "NET_DEVICES=mlx5_0:1")
{
    setup_mock("ib").set_mock_iface_attr("rc_mlx5/mlx5_0:1",
        [](uct_iface_attr_t &iface_attr) {
            iface_attr.dev_num_paths    = 1;
            iface_attr.cap.am.max_short = 208;
            iface_attr.bandwidth.shared = 10000000000;
            iface_attr.latency.c        = 0.000006;
            iface_attr.latency.m        = 0.000000001;
        });

    connect();

    ucp_proto_select_key_t key = any_key();
    key.param.op_id_flags      = UCP_OP_ID_AM_SEND;
    key.param.op_attr          = 0;

    check_ep_config(sender(), {
        {"0",          "200",    "short",                "rc_mlx5/mlx5_0:1"},
        {"201",        "1023",   "copy-in",              "rc_mlx5/mlx5_0:1"},
        {"1024",       "91894",  "rendezvous fragmented copy-in copy-out",
                                                         "rc_mlx5/mlx5_0:1"},
        {"91895",       "inf",   "rendezvous zero-copy read from remote",
                                                         "rc_mlx5/mlx5_0:1"},
    }, key);
}

UCS_TEST_P(test_ucp_proto_mock, rndv_thresh_and_scheme, "RNDV_THRESH=1024", "RNDV_SCHEME=get_zcopy", "NET_DEVICES=mlx5_0:1")
{
    setup_mock("ib").set_mock_iface_attr("rc_mlx5/mlx5_0:1",
        [](uct_iface_attr_t &iface_attr) {
            iface_attr.dev_num_paths    = 1;
            iface_attr.cap.am.max_short = 208;
            iface_attr.bandwidth.shared = 10000000000;
            iface_attr.latency.c        = 0.000006;
            iface_attr.latency.m        = 0.000000001;
        });

    connect();

    ucp_proto_select_key_t key = any_key();
    key.param.op_id_flags      = UCP_OP_ID_AM_SEND;
    key.param.op_attr          = 0;

    check_ep_config(sender(), {
        {"0",          "200",    "short",                "rc_mlx5/mlx5_0:1"},
        {"201",        "1023",   "copy-in",              "rc_mlx5/mlx5_0:1"},
        {"1024",       "inf",    "rendezvous zero-copy read from remote",
                                                         "rc_mlx5/mlx5_0:1"},
    }, key);
}

return UCS_MEMUNITS_INF; /* used only as last resort */
if ((context->config.ext.rndv_mode == UCP_RNDV_MODE_AUTO) ||
(rndv_modes & UCS_BIT(context->config.ext.rndv_mode))) {
return UCS_MEMUNITS_AUTO; /* used only as last resort */
Copy link
Contributor

Choose a reason for hiding this comment

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

the comment is wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

params->super.cfg_priority, remote_proto->cfg_priority);
if (remote_proto->cfg_thresh != UCS_MEMUNITS_AUTO) {
/* If RNDV_SCHEME is set, all protocols except forced one reports INF */
ucs_assert(remote_proto->cfg_thresh == UCS_MEMUNITS_INF);
Copy link
Contributor

Choose a reason for hiding this comment

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

assertv

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

brminich
brminich previously approved these changes Oct 16, 2024
src/ucp/rndv/proto_rndv.inl Outdated Show resolved Hide resolved
params->super.cfg_priority, remote_proto->cfg_priority);
if (remote_proto->cfg_thresh != UCS_MEMUNITS_AUTO) {
/* If RNDV_SCHEME is set, all protocols except forced one reports INF */
ucs_assert(remote_proto->cfg_thresh == UCS_MEMUNITS_INF);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

src/ucp/rndv/proto_rndv.c Outdated Show resolved Hide resolved
brminich
brminich previously approved these changes Oct 17, 2024
@yosefe
Copy link
Contributor

yosefe commented Oct 18, 2024

/azp run UCX PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ivankochin
Copy link
Contributor Author

ivankochin commented Oct 21, 2024

Drawback of the proposed logic is that if defined RNDV_SCHEME protocol is unavailable, other protocols can be selected only as last resort since they would have cfg_tresh==inf.

So if we set RNDV_SCHME=get_zcopy and there are no rma_bw_lanes protocols selection wouldn't be fallen back to rndv/am/bcopy/zcopy and eager will be used for all messages. That can cause many changes in tests which are relates on that fallback.

test/gtest/ucp/test_ucp_sockaddr.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_sockaddr.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_sockaddr.cc Outdated Show resolved Hide resolved
test/gtest/ucp/test_ucp_sockaddr.cc Outdated Show resolved Hide resolved
{
if (!sender().is_rndv_supported()) {
UCS_TEST_MESSAGE << "RNDV is not supported";
m_check_recv_rndv_flags = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

why? what if this is AM-based rndv?
also if rndv is not supported this test suite should be skipped

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe message confused you. That case is created to handler AM-based RNDV case. AFAIR AM RNDV doesn't set recv_attr flags.

I can change message here to "RMA is not supported" would it be better from your point of view?

Copy link
Contributor

Choose a reason for hiding this comment

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

what flag do you mean? AM-based RNDV is using generic flow RTS->RTR->data chunks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My bad, you are right. The thing here is that due to new logic if RNDV_SCHEME=get_zcopy and rndv/get/zcopy is unavailable eager can be selected instead of RNDV.

So we cannot rely on fact that UCP_AM_RECV_ATTR_FLAG_RNDV and UCP_AM_RECV_ATTR_FLAG_DATA will be set in am_data_handler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can skip these tests if RNDV not supported but I don't think that it is important

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