/home/runner/work/HiCR/HiCR/include/hicr/backends/hwloc/instanceManager.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/hwloc/instanceManager.hpp Source File
HiCR
instanceManager.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 Huawei Technologies Co., Ltd.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
24#pragma once
25
26#include <memory>
27#include <hicr/core/definitions.hpp>
30
31namespace HiCR::backend::hwloc
32{
33
38{
39 public:
40
45 : HiCR::InstanceManager()
46 {
47 // A single instance (the currently running) is created and is deemed as the root
48 auto currentInstance = std::make_shared<HiCR::backend::hwloc::Instance>();
49 setCurrentInstance(currentInstance);
50 addInstance(currentInstance);
51 }
52
53 ~InstanceManager() override = default;
54
55 __INLINE__ void finalize() override {}
56
57 __INLINE__ void abort(int errorCode) override { std::abort(); }
58
66 __INLINE__ static std::unique_ptr<HiCR::InstanceManager> createDefault(int *argc, char ***argv)
67 {
68 // Creating instance manager
69 return std::make_unique<HiCR::backend::hwloc::InstanceManager>();
70 }
71
72 [[nodiscard]] __INLINE__ HiCR::Instance::instanceId_t getRootInstanceId() const override { return 0; }
73
74 private:
75
79 void *_returnValueBuffer{};
80};
81
82} // namespace HiCR::backend::hwloc
Provides a definition for the instance class for the HWLoc-based backend.
Definition instanceManager.hpp:57
__INLINE__ void addInstance(HiCR::Instance::instanceId_t instanceId)
Definition instanceManager.hpp:139
__INLINE__ void setCurrentInstance(const std::shared_ptr< HiCR::Instance > &instance)
Definition instanceManager.hpp:203
uint64_t instanceId_t
Definition instance.hpp:44
Definition instanceManager.hpp:38
__INLINE__ void finalize() override
Definition instanceManager.hpp:55
InstanceManager()
Definition instanceManager.hpp:44
__INLINE__ void abort(int errorCode) override
Definition instanceManager.hpp:57
static __INLINE__ std::unique_ptr< HiCR::InstanceManager > createDefault(int *argc, char ***argv)
Definition instanceManager.hpp:66
__INLINE__ HiCR::Instance::instanceId_t getRootInstanceId() const override
Definition instanceManager.hpp:72
Provides a definition for the abstract instance manager class.