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

Support Boost Fibers #41

Open
mdemoret-nv opened this issue Apr 28, 2023 · 0 comments
Open

Support Boost Fibers #41

mdemoret-nv opened this issue Apr 28, 2023 · 0 comments

Comments

@mdemoret-nv
Copy link
Contributor

mdemoret-nv commented Apr 28, 2023

In the MRC library, we are using Boost Fibers to allow for async processing. Our library currently has it's own C++ wrapper to UCX that works well with Boost Fibers since we can yield the thread during any network I/O stalls.

We would love to switch to using UCXX to replace our current C++ wrapper around UCX but we would need the ability to use boost threading primitives instead of the standard library ones.

If you havent worked with Boost Fibers before, there are a couple of things to be aware of:

  1. Instead of using any of the standard library threading primitives, use the equivalent in boost::fibers namespace
    1. i.e. Instead of std::mutex, use boost::fibers::mutex. And instead of std::thread, use boost::fibers::fiber
    2. The interface is nearly identical between the two namespaces. We just use a typedef in MRC to make this easier
    3. This is really only needed for the public facing API. Internally, if you create any threads, you wouldnt want to change that.
  2. Avoid using thread local storage
    1. Thread local storage doesnt work in Boost Fibers because multiple fibers will all see the same thread local value. Instead they have fiber local storage, boost::fibers::fiber_specific_ptr
    2. Other libraries that I have modified to work with fibers have a method of specifying how to get/set from TLS. See this example in pybind11: https://github.com/pybind/pybind11/blob/6de6191a0c56a9b0d31ac1c32778081a9e2b0311/include/pybind11/detail/internals.h#L82-L85
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

No branches or pull requests

1 participant