/home/runner/work/HiCR/HiCR/include/hicr/backends/mpi/instance.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/mpi/instance.hpp Source File
HiCR
instance.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
23#pragma once
24
25#include <mpi.h>
27
28namespace HiCR::backend::mpi
29{
30
35
39class Instance final : public HiCR::Instance
40{
41 public:
42
47 Instance(const int rank)
48 : HiCR::Instance((instanceId_t)rank),
49 _rank(rank)
50 {}
51
55 ~Instance() override = default;
56
57 [[nodiscard]] bool isRootInstance() const override
58 {
59 // Criterion for root rank in MPI: Rank 0 will always be the root.
61 };
62
67 [[nodiscard]] __INLINE__ int getRank() const { return _rank; }
68
72 const int _rank;
73};
74
75} // namespace HiCR::backend::mpi
constexpr int _HICR_MPI_INSTANCE_ROOT_ID
Definition instance.hpp:34
Definition instance.hpp:38
uint64_t instanceId_t
Definition instance.hpp:44
Definition instance.hpp:40
__INLINE__ int getRank() const
Definition instance.hpp:67
const int _rank
Definition instance.hpp:72
bool isRootInstance() const override
Definition instance.hpp:57
~Instance() override=default
Instance(const int rank)
Definition instance.hpp:47
Provides a definition for the HiCR Instance class.