diff --git a/mllib-dal/src/main/native/Communicator.hpp b/mllib-dal/src/main/native/Communicator.hpp index bdd5072c9..548988432 100644 --- a/mllib-dal/src/main/native/Communicator.hpp +++ b/mllib-dal/src/main/native/Communicator.hpp @@ -21,7 +21,6 @@ #include "oneapi/ccl.hpp" #include "oneapi/dal/detail/ccl/communicator.hpp" -#include "Singleton.hpp" namespace de = oneapi::dal::detail; namespace oneapi::dal::preview::spmd { @@ -29,39 +28,22 @@ namespace oneapi::dal::preview::spmd { namespace backend { struct ccl {}; } // namespace backend -class ccl_info { - friend class de::singleton; - -private: - ccl_info(int size, int rankId, ccl::shared_ptr_class keyvs) { - rank = rankId; - rank_count = size; - kvs = keyvs; - } - -public: - ccl::shared_ptr_class kvs; - int rank; - int rank_count; -}; template communicator make_communicator(int size, int rank, const ccl::shared_ptr_class kvs) { - auto& info = de::singleton::get(size, rank, kvs); // integral cast - return oneapi::dal::detail::ccl_communicator{ info.kvs, - info.rank, - info.rank_count }; + return oneapi::dal::detail::ccl_communicator{ kvs, + rank, + size }; } template communicator make_communicator(sycl::queue& queue, int size, int rank, const ccl::shared_ptr_class kvs) { - auto& info = de::singleton::get(size, rank, kvs); return oneapi::dal::detail::ccl_communicator{ queue, - info.kvs, - oneapi::dal::detail::integral_cast(info.rank), - oneapi::dal::detail::integral_cast(info.rank_count) + kvs, + oneapi::dal::detail::integral_cast(rank), + oneapi::dal::detail::integral_cast(size) }; } diff --git a/mllib-dal/src/main/native/Singleton.hpp b/mllib-dal/src/main/native/Singleton.hpp deleted file mode 100644 index 1169feac4..000000000 --- a/mllib-dal/src/main/native/Singleton.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* -* Copyright 2020 Intel Corporation -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*******************************************************************************/ - -#pragma once - -namespace oneapi::dal::detail { - -namespace v1 { - -template -class singleton { -public: - static T& get(int size, int rank, ccl::shared_ptr_class kvs) { - static std::once_flag flag; - std::call_once(flag, [size, rank, kvs] { - get_instance(size, rank, kvs); - }); - return get_instance(size, rank, kvs); - } - -private: - static T& get_instance(int size, int rank, ccl::shared_ptr_class kvs) { - static T instance{size, rank, kvs}; - return instance; - } -}; - -} // namespace v1 - -using v1::singleton; - -} // namespace oneapi::dal::detail