cpp/include/raft/comms/helper.hpp
void build_comms_nccl_ucx(
  handle_t* handle, ncclComm_t nccl_comm, void* ucp_worker, void* eps, int num_ranks, int rank)
{
  auto eps_sp = std::make_shared<ucp_ep_h*>(new ucp_ep_h[num_ranks]);

  auto size_t_ep_arr = reinterpret_cast<size_t*>(eps);

  for (int i = 0; i < num_ranks; i++) {
    size_t ptr    = size_t_ep_arr[i];
    auto ucp_ep_v = reinterpret_cast<ucp_ep_h*>(*eps_sp);

    if (ptr != 0) {
      auto eps_ptr = reinterpret_cast<ucp_ep_h>(size_t_ep_arr[i]);
      ucp_ep_v[i]  = eps_ptr;
    } else {
      ucp_ep_v[i] = nullptr;
    }
  }

  cudaStream_t stream = handle->get_stream();

  auto communicator =
    std::make_shared<comms_t>(std::unique_ptr<comms_iface>(new raft::comms::std_comms(
      nccl_comm, (ucp_worker_h)ucp_worker, eps_sp, num_ranks, rank, stream)));
  handle->set_comms(communicator);
}
/**
 * Function to construct comms_t and inject it on a handle_t. This
 * is used for convenience in the Python layer.
 *
 * @param handle raft::handle_t for injecting the comms
 * @param nccl_comm initialized NCCL communicator to use for collectives
 * @param ucp_worker of local process
 *        Note: This is purposefully left as void* so that the ucp_worker_h
 *        doesn't need to be exposed through the cython layer
 * @param eps array of ucp_ep_h instances.
 *        Note: This is purposefully left as void* so that
 *        the ucp_ep_h doesn't need to be exposed through the cython layer.
 * @param num_ranks number of ranks in communicator clique
 * @param rank rank of local instance
 */
Function to construct comms_t and inject it on a handle_t. This
is used for convenience in the Python layer.

@param handle raft::handle_t for injecting the comms
@param nccl_comm initialized NCCL communicator to use for collectives
@param ucp_worker of local process
Note: This is purposefully left as void* so that the ucp_worker_h
doesn't need to be exposed through the cython layer
@param eps array of ucp_ep_h instances.
Note: This is purposefully left as void* so that
the ucp_ep_h doesn't need to be exposed through the cython layer.
@param num_ranks number of ranks in communicator clique
@param rank rank of local instance
Function to construct comms_t and inject it on a handle_t . This is used for convenience in the Python layer . @param handle raft :: handle_t for injecting the comms @param nccl_comm initialized NCCL communicator to use for collectives @param ucp_worker of local process Note : This is purposefully left as void * so that the ucp_worker_h doesn ' t need to be exposed through the cython layer @param eps array of ucp_ep_h instances . Note : This is purposefully left as void * so that the ucp_ep_h doesn ' t need to be exposed through the cython layer . @param num_ranks number of ranks in communicator clique @param rank rank of local instance
void build_comms_nccl_ucx(
  handle_t* handle, ncclComm_t nccl_comm, void* ucp_worker, void* eps, int num_ranks, int rank)
{
  auto eps_sp = std::make_shared<ucp_ep_h*>(new ucp_ep_h[num_ranks]);
  auto size_t_ep_arr = reinterpret_cast<size_t*>(eps);
  for (int i = 0; i < num_ranks; i++) {
    size_t ptr    = size_t_ep_arr[i];
    auto ucp_ep_v = reinterpret_cast<ucp_ep_h*>(*eps_sp);
    if (ptr != 0) {
      auto eps_ptr = reinterpret_cast<ucp_ep_h>(size_t_ep_arr[i]);
      ucp_ep_v[i]  = eps_ptr;
    } else {
      ucp_ep_v[i] = nullptr;
    }
  }
  cudaStream_t stream = handle->get_stream();
  auto communicator =
    std::make_shared<comms_t>(std::unique_ptr<comms_iface>(new raft::comms::std_comms(
      nccl_comm, (ucp_worker_h)ucp_worker, eps_sp, num_ranks, rank, stream)));
  handle->set_comms(communicator);
}
void build_comms_nccl_ucx ( handle_t * handle , ncclComm_t nccl_comm , void * ucp_worker , void * eps , int num_ranks , int rank ) { auto eps_sp = std :: make_shared < ucp_ep_h * > ( new ucp_ep_h [ num_ranks ] ) ; auto size_t_ep_arr = reinterpret_cast < size_t * > ( eps ) ; for ( int i = 0 ; i < num_ranks ; i ++ ) { size_t ptr = size_t_ep_arr [ i ] ; auto ucp_ep_v = reinterpret_cast < ucp_ep_h * > ( * eps_sp ) ; if ( ptr != 0 ) { auto eps_ptr = reinterpret_cast < ucp_ep_h > ( size_t_ep_arr [ i ] ) ; ucp_ep_v [ i ] = eps_ptr ; } else { ucp_ep_v [ i ] = nullptr ; } } cudaStream_t stream = handle -> get_stream ( ) ; auto communicator = std :: make_shared < comms_t > ( std :: unique_ptr < comms_iface > ( new raft :: comms :: std_comms ( nccl_comm , ( ucp_worker_h ) ucp_worker , eps_sp , num_ranks , rank , stream ) ) ) ; handle -> set_comms ( communicator ) ; }
Function to construct comms_t and inject it on a handle_t.
Function to construct comms_t and inject it on a handle_t .