mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-06 19:32:25 +08:00
[1/n] Log allocation placement.
Change-Id: I9ab61e10dcb0fcbbaf859c077a64ce7a4f2c213c
This commit is contained in:
committed by
sys_ocldev
parent
e987d41dd6
commit
75a635fdc5
@@ -7,8 +7,15 @@
|
|||||||
|
|
||||||
#include "runtime/helpers/aligned_memory.h"
|
#include "runtime/helpers/aligned_memory.h"
|
||||||
#include "runtime/memory_manager/graphics_allocation.h"
|
#include "runtime/memory_manager/graphics_allocation.h"
|
||||||
|
#include "runtime/os_interface/debug_settings_manager.h"
|
||||||
|
|
||||||
namespace OCLRT {
|
namespace OCLRT {
|
||||||
|
|
||||||
|
void GraphicsAllocation::setAllocationType(AllocationType allocationType) {
|
||||||
|
DebugManager.logAllocation(this);
|
||||||
|
this->allocationType = allocationType;
|
||||||
|
}
|
||||||
|
|
||||||
bool GraphicsAllocation::isL3Capable() {
|
bool GraphicsAllocation::isL3Capable() {
|
||||||
auto ptr = ptrOffset(cpuPtr, static_cast<size_t>(this->allocationOffset));
|
auto ptr = ptrOffset(cpuPtr, static_cast<size_t>(this->allocationOffset));
|
||||||
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && alignUp(this->size, MemoryConstants::cacheLineSize) == this->size) {
|
if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && alignUp(this->size, MemoryConstants::cacheLineSize) == this->size) {
|
||||||
@@ -42,6 +49,11 @@ void GraphicsAllocation::updateTaskCount(uint32_t newTaskCount, uint32_t context
|
|||||||
}
|
}
|
||||||
usageInfos[contextId].taskCount = newTaskCount;
|
usageInfos[contextId].taskCount = newTaskCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GraphicsAllocation::getAllocationInfoString() const {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
constexpr uint32_t GraphicsAllocation::objectNotUsed;
|
||||||
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
constexpr uint32_t GraphicsAllocation::objectNotResident;
|
||||||
} // namespace OCLRT
|
} // namespace OCLRT
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||||||
void setSize(size_t size) { this->size = size; }
|
void setSize(size_t size) { this->size = size; }
|
||||||
osHandle peekSharedHandle() { return sharedHandle; }
|
osHandle peekSharedHandle() { return sharedHandle; }
|
||||||
|
|
||||||
void setAllocationType(AllocationType allocationType) { this->allocationType = allocationType; }
|
void setAllocationType(AllocationType allocationType);
|
||||||
AllocationType getAllocationType() const { return allocationType; }
|
AllocationType getAllocationType() const { return allocationType; }
|
||||||
|
|
||||||
void setAubWritable(bool writable) { aubWritable = writable; }
|
void setAubWritable(bool writable) { aubWritable = writable; }
|
||||||
@@ -117,7 +117,7 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||||||
void incReuseCount() { reuseCount++; }
|
void incReuseCount() { reuseCount++; }
|
||||||
void decReuseCount() { reuseCount--; }
|
void decReuseCount() { reuseCount--; }
|
||||||
uint32_t peekReuseCount() const { return reuseCount; }
|
uint32_t peekReuseCount() const { return reuseCount; }
|
||||||
MemoryPool::Type getMemoryPool() {
|
MemoryPool::Type getMemoryPool() const {
|
||||||
return memoryPool;
|
return memoryPool;
|
||||||
}
|
}
|
||||||
bool isUsed() const { return registeredContextsNum > 0; }
|
bool isUsed() const { return registeredContextsNum > 0; }
|
||||||
@@ -136,6 +136,8 @@ class GraphicsAllocation : public IDNode<GraphicsAllocation> {
|
|||||||
bool isMultiOsContextCapable() const { return multiOsContextCapable; }
|
bool isMultiOsContextCapable() const { return multiOsContextCapable; }
|
||||||
bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; }
|
bool isUsedByManyOsContexts() const { return registeredContextsNum > 1u; }
|
||||||
|
|
||||||
|
virtual std::string getAllocationInfoString() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
constexpr static uint32_t objectNotResident = (uint32_t)-1;
|
constexpr static uint32_t objectNotResident = (uint32_t)-1;
|
||||||
constexpr static uint32_t objectNotUsed = (uint32_t)-1;
|
constexpr static uint32_t objectNotUsed = (uint32_t)-1;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2018 Intel Corporation
|
* Copyright (C) 2017-2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -34,7 +34,7 @@ DebugSettingsManager<DebugLevel>::DebugSettingsManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::remove(logFileName.c_str());
|
std::remove(logFileName.c_str());
|
||||||
} // namespace OCLRT
|
}
|
||||||
|
|
||||||
template <DebugFunctionalityLevel DebugLevel>
|
template <DebugFunctionalityLevel DebugLevel>
|
||||||
void DebugSettingsManager<DebugLevel>::writeToFile(std::string filename, const char *str, size_t length, std::ios_base::openmode mode) {
|
void DebugSettingsManager<DebugLevel>::writeToFile(std::string filename, const char *str, size_t length, std::ios_base::openmode mode) {
|
||||||
@@ -94,6 +94,29 @@ void DebugSettingsManager<DebugLevel>::logApiCall(const char *function, bool ent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <DebugFunctionalityLevel DebugLevel>
|
||||||
|
void DebugSettingsManager<DebugLevel>::logAllocation(GraphicsAllocation const *graphicsAllocation) {
|
||||||
|
if (false == debugLoggingAvailable()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags.LogAllocationMemoryPool.get()) {
|
||||||
|
std::thread::id thisThread = std::this_thread::get_id();
|
||||||
|
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << " ThreadID: " << thisThread;
|
||||||
|
ss << " AllocationType: " << getAllocationTypeString(graphicsAllocation);
|
||||||
|
ss << " MemoryPool: " << graphicsAllocation->getMemoryPool();
|
||||||
|
ss << graphicsAllocation->getAllocationInfoString();
|
||||||
|
ss << std::endl;
|
||||||
|
|
||||||
|
auto str = ss.str();
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> theLock(mtx);
|
||||||
|
writeToFile(logFileName, str.c_str(), str.size(), std::ios::app);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template <DebugFunctionalityLevel DebugLevel>
|
template <DebugFunctionalityLevel DebugLevel>
|
||||||
size_t DebugSettingsManager<DebugLevel>::getInput(const size_t *input, int32_t index) {
|
size_t DebugSettingsManager<DebugLevel>::getInput(const size_t *input, int32_t index) {
|
||||||
if (debugLoggingAvailable() == false)
|
if (debugLoggingAvailable() == false)
|
||||||
@@ -239,6 +262,66 @@ void DebugSettingsManager<DebugLevel>::injectSettingsFromReader() {
|
|||||||
#include "debug_variables.inl"
|
#include "debug_variables.inl"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <DebugFunctionalityLevel DebugLevel>
|
||||||
|
const char *DebugSettingsManager<DebugLevel>::getAllocationTypeString(GraphicsAllocation const *graphicsAllocation) {
|
||||||
|
if (false == debugLoggingAvailable()) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto type = graphicsAllocation->getAllocationType();
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::UNKNOWN:
|
||||||
|
return "UNKNOWN";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::BUFFER_COMPRESSED:
|
||||||
|
return "BUFFER_COMPRESSED";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY:
|
||||||
|
return "BUFFER_HOST_MEMORY";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::BUFFER:
|
||||||
|
return "BUFFER";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::IMAGE:
|
||||||
|
return "IMAGE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::TAG_BUFFER:
|
||||||
|
return "TAG_BUFFER";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::LINEAR_STREAM:
|
||||||
|
return "LINEAR_STREAM";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::FILL_PATTERN:
|
||||||
|
return "FILL_PATTERN";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::PIPE:
|
||||||
|
return "PIPE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER:
|
||||||
|
return "TIMESTAMP_TAG_BUFFER";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::COMMAND_BUFFER:
|
||||||
|
return "COMMAND_BUFFER";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::PRINTF_SURFACE:
|
||||||
|
return "PRINTF_SURFACE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::GLOBAL_SURFACE:
|
||||||
|
return "GLOBAL_SURFACE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::PRIVATE_SURFACE:
|
||||||
|
return "PRIVATE_SURFACE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::CONSTANT_SURFACE:
|
||||||
|
return "CONSTANT_SURFACE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::SCRATCH_SURFACE:
|
||||||
|
return "SCRATCH_SURFACE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::INSTRUCTION_HEAP:
|
||||||
|
return "INSTRUCTION_HEAP";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP:
|
||||||
|
return "INDIRECT_OBJECT_HEAP";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP:
|
||||||
|
return "SURFACE_STATE_HEAP";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP:
|
||||||
|
return "DYNAMIC_STATE_HEAP";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::SHARED_RESOURCE:
|
||||||
|
return "SHARED_RESOURCE";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::SVM:
|
||||||
|
return "SVM";
|
||||||
|
case OCLRT::GraphicsAllocation::AllocationType::UNDECIDED:
|
||||||
|
return "UNDECIDED";
|
||||||
|
default:
|
||||||
|
return "ILLEGAL_VALUE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template class DebugSettingsManager<DebugFunctionalityLevel::None>;
|
template class DebugSettingsManager<DebugFunctionalityLevel::None>;
|
||||||
template class DebugSettingsManager<DebugFunctionalityLevel::Full>;
|
template class DebugSettingsManager<DebugFunctionalityLevel::Full>;
|
||||||
template class DebugSettingsManager<DebugFunctionalityLevel::RegKeys>;
|
template class DebugSettingsManager<DebugFunctionalityLevel::RegKeys>;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2018 Intel Corporation
|
* Copyright (C) 2017-2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -42,6 +42,7 @@ void printDebugString(bool showDebugLogs, Args &&... args) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Kernel;
|
class Kernel;
|
||||||
|
class GraphicsAllocation;
|
||||||
struct MultiDispatchInfo;
|
struct MultiDispatchInfo;
|
||||||
class SettingsReader;
|
class SettingsReader;
|
||||||
|
|
||||||
@@ -108,6 +109,7 @@ class DebugSettingsManager {
|
|||||||
void getHardwareInfoOverride(std::string &hwInfoConfig);
|
void getHardwareInfoOverride(std::string &hwInfoConfig);
|
||||||
void dumpKernel(const std::string &name, const std::string &src);
|
void dumpKernel(const std::string &name, const std::string &src);
|
||||||
void logApiCall(const char *function, bool enter, int32_t errorCode);
|
void logApiCall(const char *function, bool enter, int32_t errorCode);
|
||||||
|
void logAllocation(GraphicsAllocation const *graphicsAllocation);
|
||||||
size_t getInput(const size_t *input, int32_t index);
|
size_t getInput(const size_t *input, int32_t index);
|
||||||
const std::string getEvents(const uintptr_t *input, uint32_t numOfEvents);
|
const std::string getEvents(const uintptr_t *input, uint32_t numOfEvents);
|
||||||
const std::string getMemObjects(const uintptr_t *input, uint32_t numOfObjects);
|
const std::string getMemObjects(const uintptr_t *input, uint32_t numOfObjects);
|
||||||
@@ -219,6 +221,8 @@ class DebugSettingsManager {
|
|||||||
return readerImpl.get();
|
return readerImpl.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *getAllocationTypeString(GraphicsAllocation const *graphicsAllocation);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::unique_ptr<SettingsReader> readerImpl;
|
std::unique_ptr<SettingsReader> readerImpl;
|
||||||
std::mutex mtx;
|
std::mutex mtx;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ DECLARE_DEBUG_VARIABLE(bool, LogApiCalls, false, "Enables logging api function c
|
|||||||
DECLARE_DEBUG_VARIABLE(bool, LogPatchTokens, false, "Enables logging patch tokens, inputs and outputs to file")
|
DECLARE_DEBUG_VARIABLE(bool, LogPatchTokens, false, "Enables logging patch tokens, inputs and outputs to file")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, LogTaskCounts, false, "Enables logging taskCounts and taskLevels to file")
|
DECLARE_DEBUG_VARIABLE(bool, LogTaskCounts, false, "Enables logging taskCounts and taskLevels to file")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, LogAlignedAllocations, false, "Logs alignedMalloc and alignedFree allocations")
|
DECLARE_DEBUG_VARIABLE(bool, LogAlignedAllocations, false, "Logs alignedMalloc and alignedFree allocations")
|
||||||
|
DECLARE_DEBUG_VARIABLE(bool, LogAllocationMemoryPool, false, "Logs memory pool for allocations")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, LogMemoryObject, false, "Logs memory object ptrs, sizes and operations")
|
DECLARE_DEBUG_VARIABLE(bool, LogMemoryObject, false, "Logs memory object ptrs, sizes and operations")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, ResidencyDebugEnable, 0, "enables debug messages and checks for Residency Model")
|
DECLARE_DEBUG_VARIABLE(bool, ResidencyDebugEnable, 0, "enables debug messages and checks for Residency Model")
|
||||||
DECLARE_DEBUG_VARIABLE(bool, EventsDebugEnable, 0, "enables debug messages for events, virtual events, blocked enqueues, events trees etc.")
|
DECLARE_DEBUG_VARIABLE(bool, EventsDebugEnable, 0, "enables debug messages for events, virtual events, blocked enqueues, events trees etc.")
|
||||||
|
|||||||
@@ -81,6 +81,13 @@ class WddmAllocation : public GraphicsAllocation {
|
|||||||
}
|
}
|
||||||
void setGpuAddress(uint64_t graphicsAddress) { this->gpuAddress = graphicsAddress; }
|
void setGpuAddress(uint64_t graphicsAddress) { this->gpuAddress = graphicsAddress; }
|
||||||
|
|
||||||
|
std::string getAllocationInfoString() const {
|
||||||
|
std::stringstream ss;
|
||||||
|
ss << " Handle: " << handle;
|
||||||
|
ss << std::endl;
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ResidencyData residency;
|
ResidencyData residency;
|
||||||
std::vector<size_t> trimCandidateListPositions;
|
std::vector<size_t> trimCandidateListPositions;
|
||||||
|
|||||||
@@ -59,7 +59,10 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForImage(ImageInfo
|
|||||||
if (!WddmMemoryManager::createWddmAllocation(allocation.get(), AllocationOrigin::EXTERNAL_ALLOCATION)) {
|
if (!WddmMemoryManager::createWddmAllocation(allocation.get(), AllocationOrigin::EXTERNAL_ALLOCATION)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
gmm.release();
|
gmm.release();
|
||||||
|
|
||||||
|
DebugManager.logAllocation(allocation.get());
|
||||||
return allocation.release();
|
return allocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +88,7 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory64kb(AllocationData
|
|||||||
DEBUG_BREAK_IF(!status);
|
DEBUG_BREAK_IF(!status);
|
||||||
wddmAllocation->setCpuPtrAndGpuAddress(cpuPtr, (uint64_t)wddmAllocation->gpuPtr);
|
wddmAllocation->setCpuPtrAndGpuAddress(cpuPtr, (uint64_t)wddmAllocation->gpuPtr);
|
||||||
|
|
||||||
|
DebugManager.logAllocation(wddmAllocation.get());
|
||||||
return wddmAllocation.release();
|
return wddmAllocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,6 +114,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryWithAlignment(const
|
|||||||
freeSystemMemory(pSysMem);
|
freeSystemMemory(pSysMem);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugManager.logAllocation(wddmAllocation.get());
|
||||||
return wddmAllocation.release();
|
return wddmAllocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,6 +135,8 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemoryForNonSvmHostPtr(si
|
|||||||
delete gmm;
|
delete gmm;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DebugManager.logAllocation(wddmAllocation.get());
|
||||||
return wddmAllocation.release();
|
return wddmAllocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,13 +164,16 @@ GraphicsAllocation *WddmMemoryManager::allocateGraphicsMemory(const AllocationPr
|
|||||||
Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false);
|
Gmm *gmm = new Gmm(ptrAligned, sizeAligned, false);
|
||||||
allocation->gmm = gmm;
|
allocation->gmm = gmm;
|
||||||
if (createWddmAllocation(allocation, AllocationOrigin::EXTERNAL_ALLOCATION)) {
|
if (createWddmAllocation(allocation, AllocationOrigin::EXTERNAL_ALLOCATION)) {
|
||||||
|
DebugManager.logAllocation(allocation);
|
||||||
return allocation;
|
return allocation;
|
||||||
}
|
}
|
||||||
freeGraphicsMemory(allocation);
|
freeGraphicsMemory(allocation);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return MemoryManager::allocateGraphicsMemory(properties, ptr);
|
auto allocation = MemoryManager::allocateGraphicsMemory(properties, ptr);
|
||||||
|
DebugManager.logAllocation(allocation);
|
||||||
|
return allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size, const void *ptr, AllocationOrigin allocationOrigin) {
|
||||||
@@ -204,6 +215,7 @@ GraphicsAllocation *WddmMemoryManager::allocate32BitGraphicsMemory(size_t size,
|
|||||||
auto baseAddress = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : this->wddm->getGfxPartition().Heap32[1].Base;
|
auto baseAddress = allocationOrigin == AllocationOrigin::EXTERNAL_ALLOCATION ? allocator32Bit->getBase() : this->wddm->getGfxPartition().Heap32[1].Base;
|
||||||
wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress);
|
wddmAllocation->gpuBaseAddress = GmmHelper::canonize(baseAddress);
|
||||||
|
|
||||||
|
DebugManager.logAllocation(wddmAllocation.get());
|
||||||
return wddmAllocation.release();
|
return wddmAllocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,6 +248,8 @@ GraphicsAllocation *WddmMemoryManager::createAllocationFromHandle(osHandle handl
|
|||||||
status = wddm->mapGpuVirtualAddress(allocation.get(), ptr, is32BitAllocation, false, false);
|
status = wddm->mapGpuVirtualAddress(allocation.get(), ptr, is32BitAllocation, false, false);
|
||||||
DEBUG_BREAK_IF(!status);
|
DEBUG_BREAK_IF(!status);
|
||||||
allocation->setGpuAddress(allocation->gpuPtr);
|
allocation->setGpuAddress(allocation->gpuPtr);
|
||||||
|
|
||||||
|
DebugManager.logAllocation(allocation.get());
|
||||||
return allocation.release();
|
return allocation.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
117
unit_tests/os_interface/debug_settings_manager_fixture.h
Normal file
117
unit_tests/os_interface/debug_settings_manager_fixture.h
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
#include "gmock/gmock.h"
|
||||||
|
#include "runtime/helpers/file_io.h"
|
||||||
|
#include "runtime/helpers/string_helpers.h"
|
||||||
|
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
||||||
|
#include "runtime/os_interface/debug_settings_manager.h"
|
||||||
|
#include "runtime/utilities/directory.h"
|
||||||
|
|
||||||
|
using namespace OCLRT;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
#undef DECLARE_DEBUG_VARIABLE
|
||||||
|
|
||||||
|
class SettingsFileCreator {
|
||||||
|
public:
|
||||||
|
SettingsFileCreator(string &content) {
|
||||||
|
bool settingsFileExists = fileExists(fileName);
|
||||||
|
if (settingsFileExists) {
|
||||||
|
remove(fileName.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
writeDataToFile(fileName.c_str(), content.c_str(), content.size());
|
||||||
|
};
|
||||||
|
|
||||||
|
~SettingsFileCreator() {
|
||||||
|
remove(fileName.c_str());
|
||||||
|
};
|
||||||
|
|
||||||
|
private:
|
||||||
|
string fileName = "igdrcl.config";
|
||||||
|
};
|
||||||
|
|
||||||
|
class TestDebugFlagsChecker {
|
||||||
|
public:
|
||||||
|
static bool isEqual(int32_t returnedValue, bool defaultValue) {
|
||||||
|
if (returnedValue == 0) {
|
||||||
|
return !defaultValue;
|
||||||
|
} else {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isEqual(int32_t returnedValue, int32_t defaultValue) {
|
||||||
|
return returnedValue == defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isEqual(string returnedValue, string defaultValue) {
|
||||||
|
return returnedValue == defaultValue;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <DebugFunctionalityLevel DebugLevel>
|
||||||
|
class TestDebugSettingsManager : public DebugSettingsManager<DebugLevel> {
|
||||||
|
public:
|
||||||
|
~TestDebugSettingsManager() {
|
||||||
|
remove(DebugSettingsManager<DebugLevel>::logFileName.c_str());
|
||||||
|
}
|
||||||
|
SettingsReader *getSettingsReader() {
|
||||||
|
return DebugSettingsManager<DebugLevel>::readerImpl.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void useRealFiles(bool value) {
|
||||||
|
mockFileSystem = !value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void writeToFile(std::string filename,
|
||||||
|
const char *str,
|
||||||
|
size_t length,
|
||||||
|
std::ios_base::openmode mode) override {
|
||||||
|
|
||||||
|
savedFiles[filename] << std::string(str, str + length);
|
||||||
|
if (mockFileSystem == false) {
|
||||||
|
DebugSettingsManager<DebugLevel>::writeToFile(filename, str, length, mode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int32_t createdFilesCount() {
|
||||||
|
return static_cast<int32_t>(savedFiles.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wasFileCreated(std::string filename) {
|
||||||
|
return savedFiles.find(filename) != savedFiles.end();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string getFileString(std::string filename) {
|
||||||
|
return savedFiles[filename].str();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool mockFileSystem = true;
|
||||||
|
std::map<std::string, std::stringstream> savedFiles;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <bool DebugFunctionality>
|
||||||
|
class TestDebugSettingsApiEnterWrapper : public DebugSettingsApiEnterWrapper<DebugFunctionality> {
|
||||||
|
public:
|
||||||
|
TestDebugSettingsApiEnterWrapper(const char *functionName, int *errCode) : DebugSettingsApiEnterWrapper<DebugFunctionality>(functionName, errCode), loggedEnter(false) {
|
||||||
|
if (DebugFunctionality) {
|
||||||
|
loggedEnter = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool loggedEnter;
|
||||||
|
};
|
||||||
|
|
||||||
|
using FullyEnabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::Full>;
|
||||||
|
using FullyDisabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::None>;
|
||||||
@@ -1,18 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2017-2018 Intel Corporation
|
* Copyright (C) 2017-2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "test.h"
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
#include "gmock/gmock.h"
|
|
||||||
#include "runtime/helpers/file_io.h"
|
|
||||||
#include "runtime/helpers/string_helpers.h"
|
|
||||||
#include "unit_tests/helpers/debug_manager_state_restore.h"
|
|
||||||
#include "runtime/os_interface/debug_settings_manager.h"
|
|
||||||
#include "runtime/utilities/directory.h"
|
|
||||||
#include "unit_tests/mocks/mock_kernel.h"
|
#include "unit_tests/mocks/mock_kernel.h"
|
||||||
#include "unit_tests/mocks/mock_program.h"
|
#include "unit_tests/mocks/mock_program.h"
|
||||||
#include "unit_tests/mocks/mock_buffer.h"
|
#include "unit_tests/mocks/mock_buffer.h"
|
||||||
@@ -21,112 +13,13 @@
|
|||||||
#include "unit_tests/fixtures/buffer_fixture.h"
|
#include "unit_tests/fixtures/buffer_fixture.h"
|
||||||
#include "unit_tests/fixtures/image_fixture.h"
|
#include "unit_tests/fixtures/image_fixture.h"
|
||||||
#include "unit_tests/helpers/memory_management.h"
|
#include "unit_tests/helpers/memory_management.h"
|
||||||
|
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
using namespace OCLRT;
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#undef DECLARE_DEBUG_VARIABLE
|
|
||||||
|
|
||||||
class SettingsFileCreator {
|
|
||||||
public:
|
|
||||||
SettingsFileCreator(string &content) {
|
|
||||||
bool settingsFileExists = fileExists(fileName);
|
|
||||||
if (settingsFileExists) {
|
|
||||||
remove(fileName.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
writeDataToFile(fileName.c_str(), content.c_str(), content.size());
|
|
||||||
};
|
|
||||||
|
|
||||||
~SettingsFileCreator() {
|
|
||||||
remove(fileName.c_str());
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
string fileName = "igdrcl.config";
|
|
||||||
};
|
|
||||||
|
|
||||||
class TestDebugFlagsChecker {
|
|
||||||
public:
|
|
||||||
static bool isEqual(int32_t returnedValue, bool defaultValue) {
|
|
||||||
if (returnedValue == 0) {
|
|
||||||
return !defaultValue;
|
|
||||||
} else {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isEqual(int32_t returnedValue, int32_t defaultValue) {
|
|
||||||
return returnedValue == defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isEqual(string returnedValue, string defaultValue) {
|
|
||||||
return returnedValue == defaultValue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <DebugFunctionalityLevel DebugLevel>
|
|
||||||
class TestDebugSettingsManager : public DebugSettingsManager<DebugLevel> {
|
|
||||||
public:
|
|
||||||
~TestDebugSettingsManager() {
|
|
||||||
remove(DebugSettingsManager<DebugLevel>::logFileName.c_str());
|
|
||||||
}
|
|
||||||
SettingsReader *getSettingsReader() {
|
|
||||||
return DebugSettingsManager<DebugLevel>::readerImpl.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
void useRealFiles(bool value) {
|
|
||||||
mockFileSystem = !value;
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeToFile(std::string filename,
|
|
||||||
const char *str,
|
|
||||||
size_t length,
|
|
||||||
std::ios_base::openmode mode) override {
|
|
||||||
|
|
||||||
savedFiles[filename] << std::string(str, str + length);
|
|
||||||
if (mockFileSystem == false) {
|
|
||||||
DebugSettingsManager<DebugLevel>::writeToFile(filename, str, length, mode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int32_t createdFilesCount() {
|
|
||||||
return static_cast<int32_t>(savedFiles.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wasFileCreated(std::string filename) {
|
|
||||||
return savedFiles.find(filename) != savedFiles.end();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string getFileString(std::string filename) {
|
|
||||||
return savedFiles[filename].str();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool mockFileSystem = true;
|
|
||||||
std::map<std::string, std::stringstream> savedFiles;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <bool DebugFunctionality>
|
|
||||||
class TestDebugSettingsApiEnterWrapper : public DebugSettingsApiEnterWrapper<DebugFunctionality> {
|
|
||||||
public:
|
|
||||||
TestDebugSettingsApiEnterWrapper(const char *functionName, int *errCode) : DebugSettingsApiEnterWrapper<DebugFunctionality>(functionName, errCode), loggedEnter(false) {
|
|
||||||
if (DebugFunctionality) {
|
|
||||||
loggedEnter = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool loggedEnter;
|
|
||||||
};
|
|
||||||
|
|
||||||
using FullyEnabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::Full>;
|
|
||||||
using FullyDisabledTestDebugManager = TestDebugSettingsManager<DebugFunctionalityLevel::None>;
|
|
||||||
|
|
||||||
TEST(DebugSettingsManager, WithDebugFunctionality) {
|
TEST(DebugSettingsManager, WithDebugFunctionality) {
|
||||||
FullyEnabledTestDebugManager debugManager;
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
@@ -967,3 +860,73 @@ TEST(DebugSettingsManager, givenReaderImplInDebugManagerWhenSettingDifferentRead
|
|||||||
debugManager.setReaderImpl(readerImpl2);
|
debugManager.setReaderImpl(readerImpl2);
|
||||||
EXPECT_EQ(readerImpl2, debugManager.getReaderImpl());
|
EXPECT_EQ(readerImpl2, debugManager.getReaderImpl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct AllocationTypeTestCase {
|
||||||
|
OCLRT::GraphicsAllocation::AllocationType type;
|
||||||
|
const char *str;
|
||||||
|
};
|
||||||
|
|
||||||
|
AllocationTypeTestCase allocationTypeValues[] = {
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::UNKNOWN, "UNKNOWN"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::BUFFER_COMPRESSED, "BUFFER_COMPRESSED"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY, "BUFFER_HOST_MEMORY"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::BUFFER, "BUFFER"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::IMAGE, "IMAGE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::TAG_BUFFER, "TAG_BUFFER"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::LINEAR_STREAM, "LINEAR_STREAM"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::FILL_PATTERN, "FILL_PATTERN"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::PIPE, "PIPE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::TIMESTAMP_TAG_BUFFER, "TIMESTAMP_TAG_BUFFER"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::COMMAND_BUFFER, "COMMAND_BUFFER"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::PRINTF_SURFACE, "PRINTF_SURFACE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::GLOBAL_SURFACE, "GLOBAL_SURFACE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::PRIVATE_SURFACE, "PRIVATE_SURFACE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::CONSTANT_SURFACE, "CONSTANT_SURFACE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::SCRATCH_SURFACE, "SCRATCH_SURFACE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::INSTRUCTION_HEAP, "INSTRUCTION_HEAP"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP, "INDIRECT_OBJECT_HEAP"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP, "SURFACE_STATE_HEAP"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP, "DYNAMIC_STATE_HEAP"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::SHARED_RESOURCE, "SHARED_RESOURCE"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::SVM, "SVM"},
|
||||||
|
{OCLRT::GraphicsAllocation::AllocationType::UNDECIDED, "UNDECIDED"}};
|
||||||
|
|
||||||
|
class AllocationTypeLogging : public ::testing::TestWithParam<AllocationTypeTestCase> {};
|
||||||
|
|
||||||
|
TEST_P(AllocationTypeLogging, givenGraphicsAllocationTypeWhenConvertingToStringThenCorrectStringIsReturned) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
auto input = GetParam();
|
||||||
|
|
||||||
|
MockGraphicsAllocation graphicsAllocation;
|
||||||
|
graphicsAllocation.setAllocationType(input.type);
|
||||||
|
|
||||||
|
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||||
|
|
||||||
|
EXPECT_STREQ(result, input.str);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(AllAllocationTypes,
|
||||||
|
AllocationTypeLogging,
|
||||||
|
::testing::ValuesIn(allocationTypeValues));
|
||||||
|
|
||||||
|
TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenConvertingToStringIllegalValueThenILLEGAL_VALUEIsReturned) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
MockGraphicsAllocation graphicsAllocation;
|
||||||
|
graphicsAllocation.setAllocationType(static_cast<OCLRT::GraphicsAllocation::AllocationType>(999));
|
||||||
|
|
||||||
|
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||||
|
|
||||||
|
EXPECT_STREQ(result, "ILLEGAL_VALUE");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(AllocationTypeLoggingSingle, givenGraphicsAllocationTypeWhenDebugManagerDisabledThennullptrReturned) {
|
||||||
|
FullyDisabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
MockGraphicsAllocation graphicsAllocation;
|
||||||
|
graphicsAllocation.setAllocationType(OCLRT::GraphicsAllocation::AllocationType::BUFFER);
|
||||||
|
|
||||||
|
auto result = debugManager.getAllocationTypeString(&graphicsAllocation);
|
||||||
|
|
||||||
|
EXPECT_STREQ(result, nullptr);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2018 Intel Corporation
|
# Copyright (C) 2018-2019 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
@@ -8,6 +8,7 @@ set(IGDRCL_SRCS_tests_os_interface_linux
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/allocator_helper_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/debug_env_reader.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_linux_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.h
|
${CMAKE_CURRENT_SOURCE_DIR}/device_factory_tests.h
|
||||||
|
|||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
#include "runtime/os_interface/debug_settings_manager.h"
|
||||||
|
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
|
||||||
|
#include "unit_tests/mocks/mock_graphics_allocation.h"
|
||||||
|
|
||||||
|
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCorrectInfo) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
// Log file not created
|
||||||
|
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(logFileCreated);
|
||||||
|
|
||||||
|
debugManager.flags.LogAllocationMemoryPool.set(true);
|
||||||
|
|
||||||
|
MockGraphicsAllocation allocation;
|
||||||
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||||
|
allocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||||
|
|
||||||
|
debugManager.logAllocation(&allocation);
|
||||||
|
|
||||||
|
std::thread::id thisThread = std::this_thread::get_id();
|
||||||
|
|
||||||
|
std::stringstream threadIDCheck;
|
||||||
|
threadIDCheck << " ThreadID: " << thisThread;
|
||||||
|
|
||||||
|
std::stringstream memoryPoolCheck;
|
||||||
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||||
|
|
||||||
|
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||||
|
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||||
|
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAllocationIsNotLogged) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
// Log file not created
|
||||||
|
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(logFileCreated);
|
||||||
|
|
||||||
|
debugManager.flags.LogAllocationMemoryPool.set(false);
|
||||||
|
|
||||||
|
MockGraphicsAllocation allocation;
|
||||||
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||||
|
allocation.overrideMemoryPool(MemoryPool::System64KBPages);
|
||||||
|
|
||||||
|
debugManager.logAllocation(&allocation);
|
||||||
|
|
||||||
|
std::thread::id thisThread = std::this_thread::get_id();
|
||||||
|
|
||||||
|
std::stringstream threadIDCheck;
|
||||||
|
threadIDCheck << " ThreadID: " << thisThread;
|
||||||
|
|
||||||
|
std::stringstream memoryPoolCheck;
|
||||||
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||||
|
|
||||||
|
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||||
|
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
#
|
#
|
||||||
# Copyright (C) 2018 Intel Corporation
|
# Copyright (C) 2018-2019 Intel Corporation
|
||||||
#
|
#
|
||||||
# SPDX-License-Identifier: MIT
|
# SPDX-License-Identifier: MIT
|
||||||
#
|
#
|
||||||
|
|
||||||
set(IGDRCL_SRCS_tests_os_interface_windows
|
set(IGDRCL_SRCS_tests_os_interface_windows
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/debug_settings_manager_win_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/deferrable_deletion_win_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device_command_stream_tests.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/device_os_tests.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/device_os_tests.cpp
|
||||||
|
|||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Intel Corporation
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "test.h"
|
||||||
|
#include "runtime/os_interface/debug_settings_manager.h"
|
||||||
|
#include "unit_tests/os_interface/debug_settings_manager_fixture.h"
|
||||||
|
#include "unit_tests/os_interface/windows/mock_wddm_allocation.h"
|
||||||
|
#include "runtime/gmm_helper/gmm.h"
|
||||||
|
|
||||||
|
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithLogAllocationsThenLogsCorrectInfo) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
// Log file not created
|
||||||
|
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(logFileCreated);
|
||||||
|
|
||||||
|
debugManager.flags.LogAllocationMemoryPool.set(true);
|
||||||
|
|
||||||
|
MockWddmAllocation allocation;
|
||||||
|
allocation.handle = 4;
|
||||||
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||||
|
allocation.setMemoryPool(MemoryPool::System64KBPages);
|
||||||
|
auto gmm = std::make_unique<Gmm>(nullptr, 0, false);
|
||||||
|
allocation.gmm = gmm.get();
|
||||||
|
allocation.gmm->resourceParams.Flags.Info.NonLocalOnly = 0;
|
||||||
|
|
||||||
|
debugManager.logAllocation(&allocation);
|
||||||
|
|
||||||
|
std::thread::id thisThread = std::this_thread::get_id();
|
||||||
|
|
||||||
|
std::stringstream threadIDCheck;
|
||||||
|
threadIDCheck << " ThreadID: " << thisThread;
|
||||||
|
|
||||||
|
std::stringstream memoryPoolCheck;
|
||||||
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||||
|
|
||||||
|
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||||
|
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||||
|
EXPECT_TRUE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_TRUE(str.find("Handle: 4") != std::string::npos);
|
||||||
|
EXPECT_TRUE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_TRUE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DebugSettingsManager, GivenDebugSettingsManagerWithoutLogAllocationsThenAllocationIsNotLogged) {
|
||||||
|
FullyEnabledTestDebugManager debugManager;
|
||||||
|
|
||||||
|
// Log file not created
|
||||||
|
bool logFileCreated = fileExists(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(logFileCreated);
|
||||||
|
|
||||||
|
debugManager.flags.LogAllocationMemoryPool.set(false);
|
||||||
|
|
||||||
|
MockWddmAllocation allocation;
|
||||||
|
allocation.handle = 4;
|
||||||
|
allocation.setAllocationType(GraphicsAllocation::AllocationType::BUFFER);
|
||||||
|
allocation.setMemoryPool(MemoryPool::System64KBPages);
|
||||||
|
auto gmm = std::make_unique<Gmm>(nullptr, 0, false);
|
||||||
|
allocation.gmm = gmm.get();
|
||||||
|
allocation.gmm->resourceParams.Flags.Info.NonLocalOnly = 0;
|
||||||
|
|
||||||
|
debugManager.logAllocation(&allocation);
|
||||||
|
|
||||||
|
std::thread::id thisThread = std::this_thread::get_id();
|
||||||
|
|
||||||
|
std::stringstream threadIDCheck;
|
||||||
|
threadIDCheck << " ThreadID: " << thisThread;
|
||||||
|
|
||||||
|
std::stringstream memoryPoolCheck;
|
||||||
|
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||||
|
|
||||||
|
if (debugManager.wasFileCreated(debugManager.getLogFileName())) {
|
||||||
|
auto str = debugManager.getFileString(debugManager.getLogFileName());
|
||||||
|
EXPECT_FALSE(str.find(threadIDCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find("Handle: 4") != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find(memoryPoolCheck.str()) != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find("AllocationType: BUFFER") != std::string::npos);
|
||||||
|
EXPECT_FALSE(str.find("NonLocalOnly: 0") != std::string::npos);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2018 Intel Corporation
|
* Copyright (C) 2018-2019 Intel Corporation
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
@@ -14,6 +14,10 @@ class MockWddmAllocation : public WddmAllocation {
|
|||||||
public:
|
public:
|
||||||
MockWddmAllocation() : WddmAllocation(nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false) {
|
MockWddmAllocation() : WddmAllocation(nullptr, 0, nullptr, MemoryPool::MemoryNull, 1u, false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setMemoryPool(MemoryPool::Type pool) {
|
||||||
|
memoryPool = pool;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OCLRT
|
} // namespace OCLRT
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ LogApiCalls = 0
|
|||||||
LogPatchTokens = 0
|
LogPatchTokens = 0
|
||||||
LogTaskCounts = 0
|
LogTaskCounts = 0
|
||||||
LogAlignedAllocations = 0
|
LogAlignedAllocations = 0
|
||||||
|
LogAllocationMemoryPool = 0
|
||||||
LogMemoryObject = 0
|
LogMemoryObject = 0
|
||||||
ForceLinearImages = 0
|
ForceLinearImages = 0
|
||||||
ForceSLML3Config = 0
|
ForceSLML3Config = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user