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

ch4/ucx: Use UCX active message API #4934

Merged
merged 6 commits into from
Apr 13, 2021
Merged

ch4/ucx: Use UCX active message API #4934

merged 6 commits into from
Apr 13, 2021

Conversation

raffenet
Copy link
Contributor

@raffenet raffenet commented Nov 19, 2020

Pull Request Description

Replace layering of active messages over tagged send/recv interface
with UCP active messages. This is an initial, functional
implementation. It should work the same as before, but eliminates a
probe operation in netmod progress that can slowdown applications
significantly when there is a buildup of unexpected messages.

Expected Impact

Author Checklist

  • Reference appropriate issues (with "Fixes" or "See" as appropriate)
  • Remove xfail from the test suite when fixing a test
  • Commits are self-contained and do not do two things at once
  • Commit message is of the form: module: short description and follows good practice
  • Passes whitespace checkers
  • Passes warning tests
  • Passes all tests
  • Add comments such that someone without knowledge of the code could understand
  • You or your company has a signed contributor's agreement on file with Argonne
  • For non-Argonne authors, request an explicit comment from your companies PR approval manager

@raffenet
Copy link
Contributor Author

test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

Manual testing is showing an odd failure in alltoall1 and nballtoall1 tests, but otherwise is mostly working. I will continue to investigate.

@raffenet
Copy link
Contributor Author

Manual testing is showing an odd failure in alltoall1 and nballtoall1 tests, but otherwise is mostly working. I will continue to investigate.

I should note this is in the am-only configuration.

@hzhou
Copy link
Contributor

hzhou commented Nov 20, 2020

I think at some point jenkins server crashed. Rerun-the tests:

test:mpich/ch4/ucx

Copy link
Contributor

@hzhou hzhou left a comment

Choose a reason for hiding this comment

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

This PR looks fine to me. Just a minor comment.

src/mpid/ch4/netmod/ucx/ucx_init.c Outdated Show resolved Hide resolved
@raffenet
Copy link
Contributor Author

test:mpich/ch4/ucx
test:mpich/warnings

@raffenet
Copy link
Contributor Author

Just for info, the AM APIs were added in UCX 1.7.0.

@raffenet
Copy link
Contributor Author

There also might be a bug when using the AM API and sending to self. Need to see if it consistent with other versions of the library.

@raffenet
Copy link
Contributor Author

test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

So this version copies all the data to a temporary buffer before calling the ch4 level callback. That fixes the alignment issues from ubsan, but it adds some significant overhead.

Regardless of how we decide to move forward, this is a useful proof-of-concept to use for my talk later this month. Maybe I can convince them to make AM buffers well-aligned, unlike the libfabric folks and FI_MULTI_RECV...

@hzhou
Copy link
Contributor

hzhou commented Nov 20, 2020

Regardless of how we decide to move forward, this is a useful proof-of-concept to use for my talk later this month. Maybe I can convince them to make AM buffers well-aligned, unlike the libfabric folks and FI_MULTI_RECV...

Yes! Do that 😃

@raffenet
Copy link
Contributor Author

A new AM API was added recently that is worth some investigation, too. openucx/ucx#5125

They even have an rdnv + am_recv concept that could map well to ch4-level interfaces.

@hzhou
Copy link
Contributor

hzhou commented Mar 2, 2021

@raffenet Did you tried to talk to the folks in the last ucx meeting? Should we move forward?

Refresh test --
test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

raffenet commented Mar 2, 2021

They suggested a minimum version check like we do for other libraries. I'll add an autoconf patch to the PR, then we can more forward with it.

@raffenet raffenet force-pushed the ucx-am branch 2 times, most recently from 99505eb to c6567a8 Compare March 2, 2021 15:18
@raffenet
Copy link
Contributor Author

raffenet commented Mar 2, 2021

test:mpich/ch4/ucx

@raffenet raffenet force-pushed the ucx-am branch 2 times, most recently from 9b7aa2f to fac1afc Compare March 2, 2021 15:36
@raffenet
Copy link
Contributor Author

raffenet commented Mar 2, 2021

test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

raffenet commented Mar 2, 2021

Updated external UCX lib in Jenkins.
test:mpich/ch4/ucx

@raffenet raffenet force-pushed the ucx-am branch 3 times, most recently from 4854d68 to 0e6f071 Compare March 2, 2021 18:48
@raffenet
Copy link
Contributor Author

raffenet commented Mar 2, 2021

test:mpich/ch4/ucx

@raffenet
Copy link
Contributor Author

raffenet commented Apr 7, 2021

That being said - for performance reasons it would be better to switch to new AM API ucp_worker_set_am_recv_handler, which supports rndv, by passing UCP_AM_RECV_ATTR_FLAG_RNDV in ucp_am_recv_param_t.recv_attr. This means the callback has to call ucp_am_recv_data_nbx in order to receive the message.

I guess you need re-do this PR with the new AM API as they suggested.

Yup. Working on it. It means we'll be tied to the newest version of UCX (released ~30 days ago), but that's probably not a big issue for MPICH 4.0.

@hzhou
Copy link
Contributor

hzhou commented Apr 7, 2021

It means we'll be tied to the newest version of UCX (released ~30 days ago), but that's probably not a big issue for MPICH 4.0.

Ideally, we can consider both implementations and do a runtime selection. But probably it is not worth the trouble considering we have an embedded version and the default is to pick OFI -- oops, I guess that's not true, but it really makes sense for us to pick OFI as default. So another impact is we need to add more logic in configure that we need to check the versions of external ucx, and when they are too old, we need to use embedded ucx (but still pick ucx as a preference).

@raffenet
Copy link
Contributor Author

raffenet commented Apr 8, 2021

Ideally, we can consider both implementations and do a runtime selection.

To be more specific, the UCX AM interfaces didn't actually change. But the way they work changed in between versions WHILE STILL CLAIMING TO BE COMPATIBLE. There is no documentation about the change in semantics. There is no way to know how to deal with the new behavior. The old AM interface is unusable. It would have been better if they just deleted it from the library altogether.

@raffenet raffenet force-pushed the ucx-am branch 3 times, most recently from be2ac88 to e76f47d Compare April 12, 2021 20:43
@raffenet
Copy link
Contributor Author

While testing a fix from the UCX folks for the backward compatibility issue, I confirmed there was still a bug in the AM code, which the last patch should hopefully fix.
test:mpich/ch4/most

Copy link
Contributor

@hzhou hzhou left a comment

Choose a reason for hiding this comment

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

Looks good. A couple of minor comments. I am eager to merge this.

AC_MSG_RESULT([$pac_have_ucx])

# if an old ucx was specified by the user, throw an error
if test "$pac_have_ucx" = "no" -a -n "$with_ucx" -a "$with_ucx" != "yes" ; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we need to move this check into the "non-embedded" branch later.

I think we always need an error message in this case ($pack_have_ucx = no). For better error messages, we may have to run two tests, one just probe ucx header, the second one check versions and we need tell the user what is the required minimum version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You think throw an error when system UCX is found but is not new enough? That is, tell the user to provide embedded rather than fallback automatically? Obviously we want to throw an error if they specify an old installation. I am thinking of the --with-ucx case.

(char *) msg_hdr->payload + (info->length - msg_hdr->data_sz - sizeof(*msg_hdr));
/* need to copy the message data for alignment purposes */
tmp = MPL_malloc(length, MPL_MEM_BUFFER);
MPIR_Memcpy(tmp, 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.

So UCX also doesn't guarantee any minimum alignment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right. With the new API (>= 1.10.0) there is RNDV support for AMs so that we can save an extra copy. I think we can work on integrating that, but it is still quite new so this PR is probably a good starting point for now.

@hzhou
Copy link
Contributor

hzhou commented Apr 12, 2021

FYI: the ofi asan fix #5210 just merged

@raffenet
Copy link
Contributor Author

raffenet commented Apr 13, 2021

test:mpich/ch4/most ✅


# if a too old UCX was found, throw an error
if test "$ucx_happy" = "no" ; then
AC_MSG_ERROR([UCXinstallation does not meet minimum version requirement (v1.7.0). Please upgrade your installation, or use --with-ucx=embedded.])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

missing a space here 🤦. will fixup before merge if approved.

@@ -46,6 +46,19 @@ AM_COND_IF([BUILD_CH4_NETMOD_UCX],[
else
dnl PAC_PROBE_HEADER_LIB must've been successful
AC_MSG_NOTICE([CH4 UCX Netmod: Using an external ucx])

AC_MSG_CHECKING([if UCX meets minimum version requirement])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved version check to this block, which will throw an error if the external lib is not new enough, regardless of whether the user specified it or not.

Copy link
Contributor

@hzhou hzhou left a comment

Choose a reason for hiding this comment

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

Looks good to me.

I am going to run a custom asan test to see where we stand.

@hzhou
Copy link
Contributor

hzhou commented Apr 13, 2021

test:mpich/custom --enable-g=asan
netmod: ch4:ucx
compiler: gcc-9

@raffenet
Copy link
Contributor Author

I am going to run a custom asan test to see where we stand.

Looks like dtpools data corruption + 1 slow test failure. I'm curious what is happening in the dtpools cases. I wonder if disabling the UCX memory hooks will change anything. Will try a quick experiment. Will merge this in the meantime.

Require UCX version 1.7.0 or later. This ensures atomic and active
message APIs utilized by MPICH are provided.
Replace layering of active messages over tagged send/recv interface
with UCP active messages. This is an initial, functional
implementation. It should work the same as before, but eliminates a
probe operation in netmod progress that can slowdown applications
significantly when there is a buildup of unexpected messages.
We now require UCX v1.7.0 to build MPICH. These RMA API checks from
versions < v1.4.0 are no longer needed.
In the case of ch4/ucx self transport, active messages are sent and
handled immediately by the target.  In the case of rendezvous, it
means message data is copied immediately upon CTS issue. Make sure the
recv request is fully setup before CTS to avoid unexpected crashes.
@raffenet
Copy link
Contributor Author

@hzhou I also added a commit to note the UCX version requirement in CHANGES.

@raffenet raffenet merged commit 340b256 into pmodels:main Apr 13, 2021
@raffenet raffenet deleted the ucx-am branch April 13, 2021 19:10
@raffenet
Copy link
Contributor Author

I am going to run a custom asan test to see where we stand.

Looks like dtpools data corruption + 1 slow test failure. I'm curious what is happening in the dtpools cases. I wonder if disabling the UCX memory hooks will change anything. Will try a quick experiment. Will merge this in the meantime.

I can reproduce the failures with the embedded module. Disabling hooks (UCX_MEM_MMAP_HOOK_MODE=none) does fix them. Oddly enough, I could not reproduce them with an external library. Need to double check versions.

@hzhou
Copy link
Contributor

hzhou commented Apr 14, 2021

Disabling hooks (UCX_MEM_MMAP_HOOK_MODE=none) does fix them.

👍

Is that an environment variable that we can set for the asan test?

@raffenet
Copy link
Contributor Author

Disabling hooks (UCX_MEM_MMAP_HOOK_MODE=none) does fix them.

👍

Is that an environment variable that we can set for the asan test?

Yes.

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.

2 participants