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

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/mpi/globalMemorySlot.hpp Source File
HiCR
globalMemorySlot.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 <memory>
26#include <mpi.h>
29#include <utility>
30
31namespace HiCR::backend::mpi
32{
33
38{
39 public:
40
50 const HiCR::GlobalMemorySlot::tag_t globalTag = 0,
51 const HiCR::GlobalMemorySlot::globalKey_t globalKey = 0,
52 std::shared_ptr<HiCR::LocalMemorySlot> sourceLocalMemorySlot = nullptr)
53 : HiCR::GlobalMemorySlot(globalTag, globalKey, std::move(sourceLocalMemorySlot)),
54 _rank(rank)
55 {}
56
60 ~GlobalMemorySlot() override = default;
61
67 __INLINE__ const int getRank() { return _rank; }
68
74 __INLINE__ std::unique_ptr<MPI_Win> &getDataWindow() { return _dataWindow; }
75
81 __INLINE__ std::unique_ptr<MPI_Win> &getRecvMessageCountWindow() { return _recvMessageCountWindow; }
82
88 __INLINE__ std::unique_ptr<MPI_Win> &getSentMessageCountWindow() { return _sentMessageCountWindow; }
89
95 [[nodiscard]] __INLINE__ bool getLockAcquiredValue() const { return _lockAcquired; }
96
102 __INLINE__ void setLockAcquiredValue(const bool value) { _lockAcquired = value; }
103
104 private:
105
109 bool _lockAcquired = false;
110
114 int _rank;
115
119 std::unique_ptr<MPI_Win> _dataWindow = nullptr;
120
124 std::unique_ptr<MPI_Win> _recvMessageCountWindow = nullptr;
125
129 std::unique_ptr<MPI_Win> _sentMessageCountWindow = nullptr;
130};
131
132} // namespace HiCR::backend::mpi
Definition globalMemorySlot.hpp:38
uint64_t tag_t
Definition globalMemorySlot.hpp:49
uint64_t globalKey_t
Definition globalMemorySlot.hpp:44
Definition globalMemorySlot.hpp:38
__INLINE__ bool getLockAcquiredValue() const
Definition globalMemorySlot.hpp:95
__INLINE__ std::unique_ptr< MPI_Win > & getRecvMessageCountWindow()
Definition globalMemorySlot.hpp:81
__INLINE__ std::unique_ptr< MPI_Win > & getSentMessageCountWindow()
Definition globalMemorySlot.hpp:88
__INLINE__ void setLockAcquiredValue(const bool value)
Definition globalMemorySlot.hpp:102
GlobalMemorySlot(int rank, const HiCR::GlobalMemorySlot::tag_t globalTag=0, const HiCR::GlobalMemorySlot::globalKey_t globalKey=0, std::shared_ptr< HiCR::LocalMemorySlot > sourceLocalMemorySlot=nullptr)
Definition globalMemorySlot.hpp:49
__INLINE__ const int getRank()
Definition globalMemorySlot.hpp:67
__INLINE__ std::unique_ptr< MPI_Win > & getDataWindow()
Definition globalMemorySlot.hpp:74
Provides a definition for a HiCR Global Memory Slot class.
Provides a definition for a HiCR Local Memory Slot class.