okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge branch 'f-139b-arc' into f-139-relad33b8074

main
1.1 KiB37 linesraw
1//==---- ccl_utils_detail.hpp----------------------------*- C++ -*----------==//
2//
3// Copyright (C) Intel Corporation
4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5// See https://llvm.org/LICENSE.txt for license information.
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef __DPCT_CCL_UTILS_DETAIL_HPP__
10#define __DPCT_CCL_UTILS_DETAIL_HPP__
11
12namespace dpct::ccl::detail {
13
14/// Get stored kvs with specified kvs address.
15inline std::shared_ptr<oneapi::ccl::kvs> &
16get_kvs(const oneapi::ccl::kvs::address_type &addr) {
17  struct hash {
18    std::size_t operator()(const oneapi::ccl::kvs::address_type &in) const {
19      return std::hash<std::string_view>()(
20          std::string_view(in.data(), in.size()));
21    }
22  };
23  static std::unordered_map<oneapi::ccl::kvs::address_type,
24                            std::shared_ptr<oneapi::ccl::kvs>, hash>
25      kvs_map;
26  return kvs_map[addr];
27}
28
29/// Help class to init ccl environment.
30class ccl_init_helper {
31public:
32  ccl_init_helper() { oneapi::ccl::init(); }
33};
34
35} // namespace dpct::ccl::detail
36
37#endif // __DPCT_CCL_UTILS_DETAIL_HPP__