Skip to content

Commit

Permalink
improve communicator code
Browse files Browse the repository at this point in the history
  • Loading branch information
minmingzhu committed Aug 23, 2024
1 parent 00e411a commit 26269a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 69 deletions.
30 changes: 6 additions & 24 deletions mllib-dal/src/main/native/Communicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,47 +21,29 @@

#include "oneapi/ccl.hpp"
#include "oneapi/dal/detail/ccl/communicator.hpp"
#include "Singleton.hpp"

namespace de = oneapi::dal::detail;
namespace oneapi::dal::preview::spmd {

namespace backend {
struct ccl {};
} // namespace backend
class ccl_info {
friend class de::singleton<ccl_info>;

private:
ccl_info(int size, int rankId, ccl::shared_ptr_class<ccl::kvs> keyvs) {
rank = rankId;
rank_count = size;
kvs = keyvs;
}

public:
ccl::shared_ptr_class<ccl::kvs> kvs;
int rank;
int rank_count;
};

template <typename Backend>
communicator<device_memory_access::none> make_communicator(int size, int rank, const ccl::shared_ptr_class<ccl::kvs> kvs) {
auto& info = de::singleton<ccl_info>::get(size, rank, kvs);
// integral cast
return oneapi::dal::detail::ccl_communicator<device_memory_access::none>{ info.kvs,
info.rank,
info.rank_count };
return oneapi::dal::detail::ccl_communicator<device_memory_access::none>{ kvs,
rank,
size };
}

template <typename Backend>
communicator<device_memory_access::usm> make_communicator(sycl::queue& queue, int size, int rank, const ccl::shared_ptr_class<ccl::kvs> kvs) {
auto& info = de::singleton<ccl_info>::get(size, rank, kvs);
return oneapi::dal::detail::ccl_communicator<device_memory_access::usm>{
queue,
info.kvs,
oneapi::dal::detail::integral_cast<std::int64_t>(info.rank),
oneapi::dal::detail::integral_cast<std::int64_t>(info.rank_count)
kvs,
oneapi::dal::detail::integral_cast<std::int64_t>(rank),
oneapi::dal::detail::integral_cast<std::int64_t>(size)
};
}

Expand Down
45 changes: 0 additions & 45 deletions mllib-dal/src/main/native/Singleton.hpp

This file was deleted.

0 comments on commit 26269a7

Please sign in to comment.