Files
compute-runtime/runtime/memory_manager/host_ptr_manager.h
Zdunowski, Piotr f124d8128b Fix deadlock in allocation list cleanup.
Resolves: NEO-3582

Change-Id: Ia871adc38a9737dc57c187557573b02cc321b3e5
Signed-off-by: Zdunowski, Piotr <piotr.zdunowski@intel.com>
2019-09-25 14:43:21 +02:00

39 lines
1.4 KiB
C++

/*
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#pragma once
#include "core/memory_manager/host_ptr_defines.h"
#include <map>
#include <mutex>
namespace NEO {
using HostPtrFragmentsContainer = std::map<const void *, FragmentStorage>;
class MemoryManager;
class HostPtrManager {
public:
FragmentStorage *getFragment(const void *inputPtr);
OsHandleStorage prepareOsStorageForAllocation(MemoryManager &memoryManager, size_t size, const void *ptr);
void releaseHandleStorage(OsHandleStorage &fragments);
bool releaseHostPtr(const void *ptr);
void storeFragment(AllocationStorageData &storageData);
void storeFragment(FragmentStorage &fragment);
std::unique_lock<std::recursive_mutex> obtainOwnership();
protected:
static AllocationRequirements getAllocationRequirements(const void *inputPtr, size_t size);
OsHandleStorage populateAlreadyAllocatedFragments(AllocationRequirements &requirements);
FragmentStorage *getFragmentAndCheckForOverlaps(const void *inputPtr, size_t size, OverlapStatus &overlappingStatus);
RequirementsStatus checkAllocationsForOverlapping(MemoryManager &memoryManager, AllocationRequirements *requirements);
HostPtrFragmentsContainer::iterator findElement(const void *ptr);
HostPtrFragmentsContainer partialAllocations;
std::recursive_mutex allocationsMutex;
};
} // namespace NEO