VART-X  0.3.0
vart_memory_impl_base.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2024-2026 Advanced Micro Devices Inc.
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 
17 #pragma once
18 
24 #include <cstdint>
25 #include "../vart_memory_types.hpp"
26 
29 namespace vart {
30 
38  public:
40  MemoryImplBase() = delete;
41 
48  MemoryImplBase(std::shared_ptr<Device> dev) : device(std::move(dev)) {}
49 
51  virtual ~MemoryImplBase(){};
52 
64  virtual const uint8_t* map(DataMapFlags map_flags) = 0;
65 
69  virtual void unmap() = 0;
70 
78  virtual std::shared_ptr<Device> get_device_handle() = 0;
79 
86  virtual size_t get_size() = 0;
87 
96  virtual uint64_t get_physical_addr() = 0;
97 
105  virtual int export_buffer() const = 0;
106 
107  protected:
108  std::shared_ptr<Device> device;
109 };
110 } // namespace vart
Abstract interface for memory implementation used by Memory.
Definition: vart_memory_impl_base.hpp:37
virtual int export_buffer() const =0
export_buffer() - Export the underlying buffer as a dma-buf file descriptor
virtual uint64_t get_physical_addr()=0
get_physical_addr() - Retrieves the physical address of the allocated memory if applicable.
virtual std::shared_ptr< Device > get_device_handle()=0
get_device_handle() - Retrieves the device handle associated with memory allocation
virtual const uint8_t * map(DataMapFlags map_flags)=0
map() - Maps allocated memory to user space
MemoryImplBase()=delete
Default construction is disabled.
MemoryImplBase(std::shared_ptr< Device > dev)
MemoryImplBase() - Constructor that takes device instance as an input.
Definition: vart_memory_impl_base.hpp:48
virtual void unmap()=0
unmap() - Unmaps allocated memory from user space.
virtual ~MemoryImplBase()
Virtual destructor to ensure proper cleanup of derived implementations.
Definition: vart_memory_impl_base.hpp:51
std::shared_ptr< Device > device
Device handle for this implementation.
Definition: vart_memory_impl_base.hpp:108
virtual size_t get_size()=0
get_size() - Retrieves the size of the allocated memory
VART (Vitis AI Runtime) public API namespace.
DataMapFlags
Definition: vart_memory_types.hpp:30