/home/runner/work/HiCR/HiCR/include/hicr/frontends/objectStore/dataObject.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/frontends/objectStore/dataObject.hpp Source File
HiCR
dataObject.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
29
30namespace HiCR::objectStore
31{
32
36using blockId = uint32_t;
37
45{
50
55
59 size_t size;
60
64 uint8_t serializedGlobalSlot[28 + sizeof(size_t)]; // TODO fix hard-coded size
65};
66
71
72// Ensure the struct is trivially copyable
73static_assert(std::is_trivially_copyable<serializedMetadata_t>::value, "DataObject handle must be trivially copyable");
74
79{
80 friend class ObjectStore;
81
82 public:
83
91 DataObject(Instance::instanceId_t instanceId, blockId id, std::shared_ptr<LocalMemorySlot> localSlot)
92 : _instanceId(instanceId),
93 _id(id),
94 _size(0),
95 _localSlot(localSlot),
96 _globalSlot(nullptr)
97 {
98 if (_localSlot) _size = _localSlot->getSize();
99 }
100
106 __INLINE__ Instance::instanceId_t getInstanceId() const { return _instanceId; }
107
113 __INLINE__ blockId getId() const { return _id; }
114
120 __INLINE__ LocalMemorySlot &getLocalSlot() const { return *_localSlot; }
121
122 private:
123
127 const Instance::instanceId_t _instanceId;
128
132 const blockId _id;
133
137 size_t _size;
138
142 std::shared_ptr<LocalMemorySlot> _localSlot;
143
147 std::shared_ptr<GlobalMemorySlot> _globalSlot;
148};
149
150} // namespace HiCR::objectStore
uint64_t instanceId_t
Definition instance.hpp:44
Definition localMemorySlot.hpp:44
Definition dataObject.hpp:79
__INLINE__ blockId getId() const
Definition dataObject.hpp:113
__INLINE__ Instance::instanceId_t getInstanceId() const
Definition dataObject.hpp:106
DataObject(Instance::instanceId_t instanceId, blockId id, std::shared_ptr< LocalMemorySlot > localSlot)
Definition dataObject.hpp:91
__INLINE__ LocalMemorySlot & getLocalSlot() const
Definition dataObject.hpp:120
Definition objectStore.hpp:115
Provides a definition for a HiCR Global Memory Slot class.
Provides a definition for the HiCR Instance class.
Provides a definition for a HiCR Local Memory Slot class.
uint32_t blockId
Definition dataObject.hpp:36
Definition dataObject.hpp:45
blockId id
Definition dataObject.hpp:54
uint8_t serializedGlobalSlot[28+sizeof(size_t)]
Definition dataObject.hpp:64
size_t size
Definition dataObject.hpp:59
Instance::instanceId_t instanceId
Definition dataObject.hpp:49