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

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/hwloc/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 <mutex>
28#include <utility>
29
30namespace HiCR::backend::hwloc
31{
32
39{
40 public:
41
50 const HiCR::GlobalMemorySlot::globalKey_t globalKey = 0,
51 std::shared_ptr<HiCR::LocalMemorySlot> sourceLocalMemorySlot = nullptr)
52 : HiCR::GlobalMemorySlot(globalTag, globalKey, std::move(sourceLocalMemorySlot))
53 {}
54
55 ~GlobalMemorySlot() override = default;
56
64 __INLINE__ bool trylock() { return _mutex.try_lock(); }
65
71 __INLINE__ void lock() { _mutex.lock(); }
72
76 __INLINE__ void unlock() { _mutex.unlock(); }
77
78 private:
79
83 std::mutex _mutex;
84};
85
86} // namespace HiCR::backend::hwloc
Definition globalMemorySlot.hpp:38
uint64_t tag_t
Definition globalMemorySlot.hpp:49
uint64_t globalKey_t
Definition globalMemorySlot.hpp:44
Definition globalMemorySlot.hpp:39
__INLINE__ void lock()
Definition globalMemorySlot.hpp:71
__INLINE__ void unlock()
Definition globalMemorySlot.hpp:76
__INLINE__ bool trylock()
Definition globalMemorySlot.hpp:64
GlobalMemorySlot(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
Provides a definition for a HiCR Global Memory Slot class.
Provides a definition for a HiCR Local Memory Slot class.