diff --git a/opencl/source/os_interface/windows/wddm_device_command_stream.inl b/opencl/source/os_interface/windows/wddm_device_command_stream.inl index f7e7e5409d..d14a162bfa 100644 --- a/opencl/source/os_interface/windows/wddm_device_command_stream.inl +++ b/opencl/source/os_interface/windows/wddm_device_command_stream.inl @@ -32,16 +32,8 @@ 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 DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL); -#if __clang__ -#pragma clang diagnostic pop -#endif template WddmCommandStreamReceiver::WddmCommandStreamReceiver(ExecutionEnvironment &executionEnvironment, diff --git a/opencl/test/unit_test/mocks/mock_wddm_residency_allocations_container.h b/opencl/test/unit_test/mocks/mock_wddm_residency_allocations_container.h index 67a8a66de4..92c6e31d88 100644 --- a/opencl/test/unit_test/mocks/mock_wddm_residency_allocations_container.h +++ b/opencl/test/unit_test/mocks/mock_wddm_residency_allocations_container.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -20,7 +20,6 @@ class MockWddmResidentAllocationsContainer : public WddmResidentAllocationsConta using WddmResidentAllocationsContainer::resourcesLock; MockWddmResidentAllocationsContainer(Wddm *wddm) : WddmResidentAllocationsContainer(wddm) {} - virtual ~MockWddmResidentAllocationsContainer() = default; MemoryOperationsStatus makeResidentResource(const D3DKMT_HANDLE &handle, size_t size) override { makeResidentResult.called++; diff --git a/shared/source/direct_submission/windows/wddm_direct_submission.inl b/shared/source/direct_submission/windows/wddm_direct_submission.inl index 9e0cb7f605..8cf90c618d 100644 --- a/shared/source/direct_submission/windows/wddm_direct_submission.inl +++ b/shared/source/direct_submission/windows/wddm_direct_submission.inl @@ -19,16 +19,8 @@ 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 DECLARE_COMMAND_BUFFER(CommandBufferHeader, UMD_OCL, FALSE, FALSE, PERFTAG_OCL); -#if __clang__ -#pragma clang diagnostic pop -#endif template WddmDirectSubmission::WddmDirectSubmission(Device &device, diff --git a/shared/source/os_interface/windows/sharedata_wrapper.h b/shared/source/os_interface/windows/sharedata_wrapper.h index 73c3b05219..0d0588bbd9 100644 --- a/shared/source/os_interface/windows/sharedata_wrapper.h +++ b/shared/source/os_interface/windows/sharedata_wrapper.h @@ -9,13 +9,13 @@ #include "shared/source/os_interface/windows/windows_wrapper.h" -#if __clang__ +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wmissing-braces" #pragma clang diagnostic ignored "-Wbraced-scalar-init" #endif #include "umKmInc/sharedata.h" -#if __clang__ +#if defined(__clang__) #pragma clang diagnostic pop #endif @@ -30,6 +30,22 @@ using ADAPTER_INFO_KMD = ADAPTER_INFO_GMM; 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 struct SKU_FEATURE_TABLE_KMD : SKU_FEATURE_TABLE_GMM { bool FtrDesktop : 1; diff --git a/shared/source/os_interface/windows/wddm/create_um_km_data_translator.cpp b/shared/source/os_interface/windows/wddm/create_um_km_data_translator.cpp index 4fa2bb18d9..1d4d7b4b37 100644 --- a/shared/source/os_interface/windows/wddm/create_um_km_data_translator.cpp +++ b/shared/source/os_interface/windows/wddm/create_um_km_data_translator.cpp @@ -80,7 +80,7 @@ class WslComputeHelperUmKmDataTranslator : public UmKmDataTranslator { this->isEnabled = true; } - ~WslComputeHelperUmKmDataTranslator() = default; + ~WslComputeHelperUmKmDataTranslator() override = default; size_t getSizeForAdapterInfoInternalRepresentation() override { return adapterInfoStructSize; diff --git a/shared/source/os_interface/windows/wddm/wddm.cpp b/shared/source/os_interface/windows/wddm/wddm.cpp index 3a1719c903..559d83cf59 100644 --- a/shared/source/os_interface/windows/wddm/wddm.cpp +++ b/shared/source/os_interface/windows/wddm/wddm.cpp @@ -229,12 +229,11 @@ bool Wddm::createDevice(PreemptionMode preemptionMode) { } bool Wddm::destroyDevice() { - NTSTATUS status = STATUS_UNSUCCESSFUL; D3DKMT_DESTROYDEVICE DestroyDevice = {}; if (device) { DestroyDevice.hDevice = device; - status = getGdi()->destroyDevice(&DestroyDevice); + [[maybe_unused]] NTSTATUS status = getGdi()->destroyDevice(&DestroyDevice); DEBUG_BREAK_IF(status != STATUS_SUCCESS); device = 0; } @@ -688,7 +687,7 @@ bool Wddm::openSharedHandle(D3DKMT_HANDLE handle, WddmAllocation *alloc) { D3DKMT_QUERYRESOURCEINFO QueryResourceInfo = {}; QueryResourceInfo.hDevice = device; QueryResourceInfo.hGlobalShare = handle; - auto status = getGdi()->queryResourceInfo(&QueryResourceInfo); + [[maybe_unused]] auto status = getGdi()->queryResourceInfo(&QueryResourceInfo); DEBUG_BREAK_IF(status != STATUS_SUCCESS); if (QueryResourceInfo.NumAllocations == 0) { @@ -737,7 +736,7 @@ bool Wddm::openNTHandle(HANDLE handle, WddmAllocation *alloc) { D3DKMT_QUERYRESOURCEINFOFROMNTHANDLE queryResourceInfoFromNtHandle = {}; queryResourceInfoFromNtHandle.hDevice = device; queryResourceInfoFromNtHandle.hNtHandle = handle; - auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle); + [[maybe_unused]] auto status = getGdi()->queryResourceInfoFromNtHandle(&queryResourceInfoFromNtHandle); DEBUG_BREAK_IF(status != STATUS_SUCCESS); std::unique_ptr allocPrivateData(new char[queryResourceInfoFromNtHandle.TotalPrivateDriverDataSize]); @@ -776,13 +775,12 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio temporaryResources->makeResidentResource(handle, size); } - NTSTATUS status = STATUS_UNSUCCESSFUL; D3DKMT_LOCK2 lock2 = {}; lock2.hAllocation = handle; lock2.hDevice = this->device; - status = getGdi()->lock2(&lock2); + [[maybe_unused]] NTSTATUS status = getGdi()->lock2(&lock2); DEBUG_BREAK_IF(status != STATUS_SUCCESS); kmDafLock(handle); @@ -790,13 +788,12 @@ void *Wddm::lockResource(const D3DKMT_HANDLE &handle, bool applyMakeResidentPrio } void Wddm::unlockResource(const D3DKMT_HANDLE &handle) { - NTSTATUS status = STATUS_UNSUCCESSFUL; D3DKMT_UNLOCK2 unlock2 = {}; unlock2.hAllocation = handle; unlock2.hDevice = this->device; - status = getGdi()->unlock2(&unlock2); + [[maybe_unused]] NTSTATUS status = getGdi()->unlock2(&unlock2); DEBUG_BREAK_IF(status != STATUS_SUCCESS); kmDafListener->notifyUnlock(featureTable->ftrKmdDaf, getAdapter(), device, &handle, 1, getGdi()->escape); diff --git a/shared/source/os_interface/windows/wddm/wddm_interface.cpp b/shared/source/os_interface/windows/wddm/wddm_interface.cpp index 53dd84ccc7..f5c7a1d58c 100644 --- a/shared/source/os_interface/windows/wddm/wddm_interface.cpp +++ b/shared/source/os_interface/windows/wddm/wddm_interface.cpp @@ -33,10 +33,9 @@ bool WddmInterface::createMonitoredFence(MonitoredFence &monitorFence) { return status == STATUS_SUCCESS; } void WddmInterface::destroyMonitorFence(D3DKMT_HANDLE fenceHandle) { - NTSTATUS status = STATUS_SUCCESS; D3DKMT_DESTROYSYNCHRONIZATIONOBJECT destroySyncObject = {0}; destroySyncObject.hSyncObject = fenceHandle; - status = wddm.getGdi()->destroySynchronizationObject(&destroySyncObject); + [[maybe_unused]] NTSTATUS status = wddm.getGdi()->destroySynchronizationObject(&destroySyncObject); DEBUG_BREAK_IF(STATUS_SUCCESS != status); } diff --git a/shared/source/os_interface/windows/wddm_residency_allocations_container.cpp b/shared/source/os_interface/windows/wddm_residency_allocations_container.cpp index 0124587e35..922550311a 100644 --- a/shared/source/os_interface/windows/wddm_residency_allocations_container.cpp +++ b/shared/source/os_interface/windows/wddm_residency_allocations_container.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -14,7 +14,7 @@ namespace NEO { WddmResidentAllocationsContainer::~WddmResidentAllocationsContainer() { - evictAllResources(); + evictAllResourcesNoLock(); } MemoryOperationsStatus WddmResidentAllocationsContainer::isAllocationResident(const D3DKMT_HANDLE &handle) { @@ -24,8 +24,12 @@ MemoryOperationsStatus WddmResidentAllocationsContainer::isAllocationResident(co } MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResources() { - decltype(resourceHandles) resourcesToEvict; auto lock = acquireLock(resourcesLock); + return evictAllResourcesNoLock(); +} + +MemoryOperationsStatus WddmResidentAllocationsContainer::evictAllResourcesNoLock() { + decltype(resourceHandles) resourcesToEvict; resourceHandles.swap(resourcesToEvict); if (resourcesToEvict.empty()) { return MemoryOperationsStatus::MEMORY_NOT_FOUND; diff --git a/shared/source/os_interface/windows/wddm_residency_allocations_container.h b/shared/source/os_interface/windows/wddm_residency_allocations_container.h index 628332daf1..aec6eebdfa 100644 --- a/shared/source/os_interface/windows/wddm_residency_allocations_container.h +++ b/shared/source/os_interface/windows/wddm_residency_allocations_container.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019-2020 Intel Corporation + * Copyright (C) 2019-2021 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -19,7 +19,7 @@ class Wddm; class WddmResidentAllocationsContainer { public: WddmResidentAllocationsContainer(Wddm *wddm) : wddm(wddm) {} - virtual ~WddmResidentAllocationsContainer(); + MOCKABLE_VIRTUAL ~WddmResidentAllocationsContainer(); MemoryOperationsStatus isAllocationResident(const D3DKMT_HANDLE &handle); MOCKABLE_VIRTUAL MemoryOperationsStatus evictAllResources(); @@ -34,6 +34,8 @@ class WddmResidentAllocationsContainer { return std::unique_lock{lock}; } + MemoryOperationsStatus evictAllResourcesNoLock(); + Wddm *wddm; std::vector resourceHandles; SpinLock resourcesLock; diff --git a/shared/source/os_interface/windows/wddm_residency_controller.cpp b/shared/source/os_interface/windows/wddm_residency_controller.cpp index d99aae787a..24314939a6 100644 --- a/shared/source/os_interface/windows/wddm_residency_controller.cpp +++ b/shared/source/os_interface/windows/wddm_residency_controller.cpp @@ -188,11 +188,13 @@ bool WddmResidencyController::makeResidentResidencyAllocations(const ResidencyCo for (uint32_t i = 0; i < residencyCount; i++) { WddmAllocation *allocation = static_cast(allocationsForResidency[i]); ResidencyData &residencyData = allocation->getResidencyData(); - bool fragmentResidency[3] = {false, false, false}; + static constexpr int maxFragments = 3; + bool fragmentResidency[maxFragments] = {false, false, false}; totalSize += allocation->getAlignedSize(); 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) { DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", allocation, "on trimCandidateList"); this->removeFromTrimCandidateList(allocation, false);