mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
merge changes from VILLASfpga/feature/hls-rtds2gpu
This commit is contained in:
parent
d2a97a81c0
commit
ff1a295814
2 changed files with 24 additions and 0 deletions
|
@ -85,6 +85,8 @@ public:
|
|||
MemoryAccessor(const MemoryBlock& mem) :
|
||||
translation(MemoryManager::get().getTranslationFromProcess(mem.getAddrSpaceId())) {}
|
||||
|
||||
MemoryAccessor(const MemoryTranslation& translation) :
|
||||
translation(translation) {}
|
||||
|
||||
T& operator*() const {
|
||||
return *reinterpret_cast<T*>(translation.getLocalAddr(0));
|
||||
|
@ -144,6 +146,12 @@ public:
|
|||
};
|
||||
}
|
||||
|
||||
BaseAllocator(std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn> mem) :
|
||||
BaseAllocator(mem->getAddrSpaceId())
|
||||
{
|
||||
memoryBlock = std::move(mem);
|
||||
}
|
||||
|
||||
virtual std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn>
|
||||
allocateBlock(size_t size) = 0;
|
||||
|
||||
|
@ -151,6 +159,12 @@ public:
|
|||
MemoryAccessor<T>
|
||||
allocate(size_t num)
|
||||
{
|
||||
if(num == 0) {
|
||||
// doesn't make sense to allocate an empty block
|
||||
logger->error("Trying to allocate empty memory");
|
||||
throw std::bad_alloc();
|
||||
}
|
||||
|
||||
const size_t size = num * sizeof(T);
|
||||
auto mem = allocateBlock(size);
|
||||
|
||||
|
@ -195,6 +209,9 @@ protected:
|
|||
MemoryBlock::deallocator_fn free;
|
||||
SpdLogger logger;
|
||||
|
||||
// optional, if allocator should own the memory block
|
||||
std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn> memoryBlock;
|
||||
|
||||
private:
|
||||
MemoryManager::AddressSpaceId memoryAddrSpaceId;
|
||||
DerivedAllocator* derivedAlloc;
|
||||
|
@ -216,6 +233,12 @@ public:
|
|||
size_t memorySize,
|
||||
size_t internalOffset = 0);
|
||||
|
||||
LinearAllocator(std::unique_ptr<MemoryBlock, MemoryBlock::deallocator_fn> mem) :
|
||||
LinearAllocator(mem->getAddrSpaceId(), mem->getSize())
|
||||
{
|
||||
memoryBlock = std::move(mem);
|
||||
}
|
||||
|
||||
size_t getAvailableMemory() const
|
||||
{ return memorySize - nextFreeAddress; }
|
||||
|
||||
|
|
|
@ -754,6 +754,7 @@ VfioGroup::attach(VfioContainer& container, int groupIndex)
|
|||
<< (container.isIommuEnabled() ? "" : "noiommu-")
|
||||
<< groupIndex;
|
||||
|
||||
logger->debug("path: {}", groupPath.str().c_str());
|
||||
group->fd = open(groupPath.str().c_str(), O_RDWR);
|
||||
if (group->fd < 0) {
|
||||
logger->error("Failed to open VFIO group {}", group->index);
|
||||
|
|
Loading…
Add table
Reference in a new issue