compute-runtime/runtime/memory_manager/host_ptr_manager.h

41 lines
1.6 KiB
C
Raw Normal View History

/*
* Copyright (C) 2017-2018 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include <map>
#include "runtime/helpers/aligned_memory.h"
#include "runtime/memory_manager/graphics_allocation.h"
#include "runtime/memory_manager/host_ptr_defines.h"
namespace OCLRT {
typedef std::map<const void *, FragmentStorage> HostPtrFragmentsContainer;
class MemoryManager;
class HostPtrManager {
public:
static AllocationRequirements getAllocationRequirements(const void *inputPtr, size_t size);
OsHandleStorage populateAlreadyAllocatedFragments(AllocationRequirements &requirements, CheckedFragments *checkedFragments);
void storeFragment(FragmentStorage &fragment);
void storeFragment(AllocationStorageData &storageData);
void releaseHandleStorage(OsHandleStorage &fragments);
bool releaseHostPtr(const void *ptr);
FragmentStorage *getFragment(const void *inputPtr);
size_t getFragmentCount() { return partialAllocations.size(); }
FragmentStorage *getFragmentAndCheckForOverlaps(const void *inputPtr, size_t size, OverlapStatus &overlappingStatus);
OsHandleStorage prepareOsStorageForAllocation(MemoryManager &memoryManager, size_t size, const void *ptr);
RequirementsStatus checkAllocationsForOverlapping(MemoryManager &memoryManager, AllocationRequirements *requirements, CheckedFragments *checkedFragments);
private:
std::map<const void *, FragmentStorage>::iterator findElement(const void *ptr);
HostPtrFragmentsContainer partialAllocations;
std::recursive_mutex allocationsMutex;
};
} // namespace OCLRT