Fixing gcc warnig in DECLARE_COMMAND_BUFFER

Signed-off-by: Jaroslaw Chodor <jaroslaw.chodor@intel.com>
This commit is contained in:
Jaroslaw Chodor
2021-06-09 13:53:41 +00:00
committed by Compute-Runtime-Automation
parent 09afa895d4
commit 53ce391eb8
10 changed files with 40 additions and 37 deletions

View File

@@ -32,16 +32,8 @@
namespace NEO { namespace NEO {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wbraced-scalar-init"
#endif
// Initialize COMMAND_BUFFER_HEADER Type PatchList Streamer Perf Tag // Initialize COMMAND_BUFFER_HEADER Type PatchList Streamer Perf Tag
DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL); DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL);
#if __clang__
#pragma clang diagnostic pop
#endif
template <typename GfxFamily> template <typename GfxFamily>
WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment, WddmCommandStreamReceiver<GfxFamily>::WddmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment,

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2020 Intel Corporation * Copyright (C) 2019-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -20,7 +20,6 @@ class MockWddmResidentAllocationsContainer : public WddmResidentAllocationsConta
using WddmResidentAllocationsContainer::resourcesLock; using WddmResidentAllocationsContainer::resourcesLock;
MockWddmResidentAllocationsContainer(Wddm *wddm) : WddmResidentAllocationsContainer(wddm) {} MockWddmResidentAllocationsContainer(Wddm *wddm) : WddmResidentAllocationsContainer(wddm) {}
virtual ~MockWddmResidentAllocationsContainer() = default;
MemoryOperationsStatus makeResidentResource(const D3DKMT_HANDLE &handle, size_t size) override { MemoryOperationsStatus makeResidentResource(const D3DKMT_HANDLE &handle, size_t size) override {
makeResidentResult.called++; makeResidentResult.called++;

View File

@@ -19,16 +19,8 @@
namespace NEO { namespace NEO {
#if __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wbraced-scalar-init"
#endif
// Initialize COMMAND_BUFFER_HEADER Type PatchList Streamer Perf Tag // Initialize COMMAND_BUFFER_HEADER Type PatchList Streamer Perf Tag
DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL); DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL);
#if __clang__
#pragma clang diagnostic pop
#endif
template <typename GfxFamily, typename Dispatcher> template <typename GfxFamily, typename Dispatcher>
WddmDirectSubmission<GfxFamily, Dispatcher>::WddmDirectSubmission(Device &device, WddmDirectSubmission<GfxFamily, Dispatcher>::WddmDirectSubmission(Device &device,

View File

@@ -9,13 +9,13 @@
#include "shared/source/os_interface/windows/windows_wrapper.h" #include "shared/source/os_interface/windows/windows_wrapper.h"
#if __clang__ #if defined(__clang__)
#pragma clang diagnostic push #pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-braces" #pragma clang diagnostic ignored "-Wmissing-braces"
#pragma clang diagnostic ignored "-Wbraced-scalar-init" #pragma clang diagnostic ignored "-Wbraced-scalar-init"
#endif #endif
#include "umKmInc/sharedata.h" #include "umKmInc/sharedata.h"
#if __clang__ #if defined(__clang__)
#pragma clang diagnostic pop #pragma clang diagnostic pop
#endif #endif
@@ -30,6 +30,22 @@ using ADAPTER_INFO_KMD = ADAPTER_INFO_GMM;
inline void propagateData(ADAPTER_INFO_KMD &) { inline void propagateData(ADAPTER_INFO_KMD &) {
} }
#if defined(__clang__) || defined(__GNUC__)
static constexpr COMMAND_BUFFER_HEADER initCommandBufferHeader(uint32_t umdContextType, uint32_t umdPatchList, uint32_t usesResourceStreamer, uint32_t perfTag) {
COMMAND_BUFFER_HEADER ret = {};
ret.UmdContextType = umdContextType;
ret.UmdPatchList = umdPatchList;
ret.UsesResourceStreamer = usesResourceStreamer;
ret.PerfTag = perfTag;
return ret;
}
#undef DECLARE_COMMAND_BUFFER
#define DECLARE_COMMAND_BUFFER(VARNAME, CONTEXTTYPE, PATCHLIST, STREAMER, PERFTAG) \
static constexpr COMMAND_BUFFER_HEADER VARNAME = initCommandBufferHeader(CONTEXTTYPE, PATCHLIST, STREAMER, PERFTAG);
#endif
#else #else
struct SKU_FEATURE_TABLE_KMD : SKU_FEATURE_TABLE_GMM { struct SKU_FEATURE_TABLE_KMD : SKU_FEATURE_TABLE_GMM {
bool FtrDesktop : 1; bool FtrDesktop : 1;

View File

@@ -80,7 +80,7 @@ class WslComputeHelperUmKmDataTranslator : public UmKmDataTranslator {
this->isEnabled = true; this->isEnabled = true;
} }
~WslComputeHelperUmKmDataTranslator() = default; ~WslComputeHelperUmKmDataTranslator() override = default;
size_t getSizeForAdapterInfoInternalRepresentation() override { size_t getSizeForAdapterInfoInternalRepresentation() override {
return adapterInfoStructSize; return adapterInfoStructSize;

View File

@@ -229,12 +229,11 @@ bool Wddm::createDevice(PreemptionMode preemptionMode) {
} }
bool Wddm::destroyDevice() { bool Wddm::destroyDevice() {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_DESTROYDEVICE DestroyDevice = {}; D3DKMT_DESTROYDEVICE DestroyDevice = {};
if (device) { if (device) {
DestroyDevice.hDevice = device; DestroyDevice.hDevice = device;
status = getGdi()->destroyDevice(&DestroyDevice); [[maybe_unused]] NTSTATUS status = getGdi()->destroyDevice(&DestroyDevice);
DEBUG_BREAK_IF(status != STATUS_SUCCESS); DEBUG_BREAK_IF(status != STATUS_SUCCESS);
device = 0; device = 0;
} }
@@ -688,7 +687,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) {
D3DKMT_QUERYRESOURCEINFO QueryResourceInfo = {}; D3DKMT_QUERYRESOURCEINFO QueryResourceInfo = {};
QueryResourceInfo.hDevice = device; QueryResourceInfo.hDevice = device;
QueryResourceInfo.hGlobalShare = handle; QueryResourceInfo.hGlobalShare = handle;
auto status = getGdi()->queryResourceInfo(&QueryResourceInfo); [[maybe_unused]] auto status = getGdi()->queryResourceInfo(&QueryResourceInfo);
DEBUG_BREAK_IF(status != STATUS_SUCCESS); DEBUG_BREAK_IF(status != STATUS_SUCCESS);
if (QueryResourceInfo.NumAllocations == 0) { if (QueryResourceInfo.NumAllocations == 0) {
@@ -737,7 +736,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) {
D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {}; D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {};
queryResourceInfoFromNtHandle.hDevice = device; queryResourceInfoFromNtHandle.hDevice = device;
queryResourceInfoFromNtHandle.hNtHandle = handle; queryResourceInfoFromNtHandle.hNtHandle = handle;
auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle); [[maybe_unused]] auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle);
DEBUG_BREAK_IF(status != STATUS_SUCCESS); DEBUG_BREAK_IF(status != STATUS_SUCCESS);
std::unique_ptr<char[]> allocPrivateData(new char[queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize]); std::unique_ptr<char[]> allocPrivateData(new char[queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize]);
@@ -776,13 +775,12 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio
temporaryResources->makeResidentResource(handle, size); temporaryResources->makeResidentResource(handle, size);
} }
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_LOCK2 lock2 = {}; D3DKMT_LOCK2 lock2 = {};
lock2.hAllocation = handle; lock2.hAllocation = handle;
lock2.hDevice = this->device; lock2.hDevice = this->device;
status = getGdi()->lock2(&lock2); [[maybe_unused]] NTSTATUS status = getGdi()->lock2(&lock2);
DEBUG_BREAK_IF(status != STATUS_SUCCESS); DEBUG_BREAK_IF(status != STATUS_SUCCESS);
kmDafLock(handle); kmDafLock(handle);
@@ -790,13 +788,12 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio
} }
void Wddm::unlockResource(const D3DKMT_HANDLE &handle) { void Wddm::unlockResource(const D3DKMT_HANDLE &handle) {
NTSTATUS status = STATUS_UNSUCCESSFUL;
D3DKMT_UNLOCK2 unlock2 = {}; D3DKMT_UNLOCK2 unlock2 = {};
unlock2.hAllocation = handle; unlock2.hAllocation = handle;
unlock2.hDevice = this->device; unlock2.hDevice = this->device;
status = getGdi()->unlock2(&unlock2); [[maybe_unused]] NTSTATUS status = getGdi()->unlock2(&unlock2);
DEBUG_BREAK_IF(status != STATUS_SUCCESS); DEBUG_BREAK_IF(status != STATUS_SUCCESS);
kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, getAdapter(), device, &handle, 1, getGdi()->escape); kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, getAdapter(), device, &handle, 1, getGdi()->escape);

View File

@@ -33,10 +33,9 @@ bool WddmInterface::createMonitoredFence(MonitoredFence &monitorFence) {
return status == STATUS_SUCCESS; return status == STATUS_SUCCESS;
} }
void WddmInterface::destroyMonitorFence(D3DKMT_HANDLE fenceHandle) { void WddmInterface::destroyMonitorFence(D3DKMT_HANDLE fenceHandle) {
NTSTATUS status = STATUS_SUCCESS;
D3DKMT_DESTROYSYNCHRONIZATIONOBJECT destroySyncObject = {0}; D3DKMT_DESTROYSYNCHRONIZATIONOBJECT destroySyncObject = {0};
destroySyncObject.hSyncObject = fenceHandle; destroySyncObject.hSyncObject = fenceHandle;
status = wddm.getGdi()->destroySynchronizationObject(&destroySyncObject); [[maybe_unused]] NTSTATUS status = wddm.getGdi()->destroySynchronizationObject(&destroySyncObject);
DEBUG_BREAK_IF(STATUS_SUCCESS != status); DEBUG_BREAK_IF(STATUS_SUCCESS != status);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2020 Intel Corporation * Copyright (C) 2019-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -14,7 +14,7 @@
namespace NEO { namespace NEO {
WddmResidentAllocationsContainer::~WddmResidentAllocationsContainer() { WddmResidentAllocationsContainer::~WddmResidentAllocationsContainer() {
evictAllResources(); evictAllResourcesNoLock();
} }
MemoryOperationsStatus WddmResidentAllocationsContainer::isAllocationResident(const D3DKMT_HANDLE &handle) { MemoryOperationsStatus WddmResidentAllocationsContainer::isAllocationResident(const D3DKMT_HANDLE &handle) {
@@ -24,8 +24,12 @@ MemoryOperationsStatus WddmResidentAllocationsContainer::isAllocationResident(co
} }
MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResources() { MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResources() {
decltype(resourceHandles) resourcesToEvict;
auto lock = acquireLock(resourcesLock); auto lock = acquireLock(resourcesLock);
return evictAllResourcesNoLock();
}
MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResourcesNoLock() {
decltype(resourceHandles) resourcesToEvict;
resourceHandles.swap(resourcesToEvict); resourceHandles.swap(resourcesToEvict);
if (resourcesToEvict.empty()) { if (resourcesToEvict.empty()) {
return MemoryOperationsStatus::MEMORY_NOT_FOUND; return MemoryOperationsStatus::MEMORY_NOT_FOUND;

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2019-2020 Intel Corporation * Copyright (C) 2019-2021 Intel Corporation
* *
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
* *
@@ -19,7 +19,7 @@ class Wddm;
class WddmResidentAllocationsContainer { class WddmResidentAllocationsContainer {
public: public:
WddmResidentAllocationsContainer(Wddm *wddm) : wddm(wddm) {} WddmResidentAllocationsContainer(Wddm *wddm) : wddm(wddm) {}
virtual ~WddmResidentAllocationsContainer(); MOCKABLE_VIRTUAL ~WddmResidentAllocationsContainer();
MemoryOperationsStatus isAllocationResident(const D3DKMT_HANDLE &handle); MemoryOperationsStatus isAllocationResident(const D3DKMT_HANDLE &handle);
MOCKABLE_VIRTUAL MemoryOperationsStatus evictAllResources(); MOCKABLE_VIRTUAL MemoryOperationsStatus evictAllResources();
@@ -34,6 +34,8 @@ class WddmResidentAllocationsContainer {
return std::unique_lock<SpinLock>{lock}; return std::unique_lock<SpinLock>{lock};
} }
MemoryOperationsStatus evictAllResourcesNoLock();
Wddm *wddm; Wddm *wddm;
std::vector<D3DKMT_HANDLE> resourceHandles; std::vector<D3DKMT_HANDLE> resourceHandles;
SpinLock resourcesLock; SpinLock resourcesLock;

View File

@@ -188,11 +188,13 @@ bool WddmResidencyController::makeResidentResidencyAllocations(const ResidencyCo
for (uint32_t i = 0; i < residencyCount; i++) { for (uint32_t i = 0; i < residencyCount; i++) {
WddmAllocation *allocation = static_cast<WddmAllocation *>(allocationsForResidency[i]); WddmAllocation *allocation = static_cast<WddmAllocation *>(allocationsForResidency[i]);
ResidencyData &residencyData = allocation->getResidencyData(); ResidencyData &residencyData = allocation->getResidencyData();
bool fragmentResidency[3] = {false, false, false}; static constexpr int maxFragments = 3;
bool fragmentResidency[maxFragments] = {false, false, false};
totalSize += allocation->getAlignedSize(); totalSize += allocation->getAlignedSize();
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", allocation, residencyData.resident[osContextId] ? "resident" : "not resident"); DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", allocation, residencyData.resident[osContextId] ? "resident" : "not resident");
UNRECOVERABLE_IF(allocation->fragmentsStorage.fragmentCount > maxFragments);
if (allocation->getTrimCandidateListPosition(this->osContextId) != trimListUnusedPosition) { if (allocation->getTrimCandidateListPosition(this->osContextId) != trimListUnusedPosition) {
DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", allocation, "on trimCandidateList"); DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", allocation, "on trimCandidateList");
this->removeFromTrimCandidateList(allocation, false); this->removeFromTrimCandidateList(allocation, false);