Skip to content

Commit

Permalink
Add /we4189 switch to CMAKE_CXX_FLAGS for MSVC.
Browse files Browse the repository at this point in the history
- treat unused local variables warnings as error in Debug

Change-Id: I2da08b72e0f0083d3cdf932fbf92ef4981a88615
  • Loading branch information
HoppeMateusz authored and Compute-Runtime-Automation committed Feb 8, 2019
1 parent 6e0d04e commit cb37f2a
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 66 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ if(NOT DEFINED AUB_STREAM_DIR AND NOT DISABLE_AUB_STREAM)
endif()
else()
unset(AUB_STREAM_DIR)
endif(NOT DEFINED AUB_STREAM_DIR)
endif()

if(LIBDRM_DIR)
get_filename_component(I915_INCLUDES_DIR "${LIBDRM_DIR}/include" ABSOLUTE)
Expand Down Expand Up @@ -469,7 +469,10 @@ endif()
if(MSVC)
# Force to treat warnings as errors
if(NOT CMAKE_CXX_FLAGS MATCHES "/WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /we4189")
endif()
endif()

# Support for WUD
Expand Down
6 changes: 5 additions & 1 deletion offline_compiler/utilities/windows/seh_exception.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -73,6 +73,10 @@ void SehException::getCallStack(unsigned int code, struct _EXCEPTION_POINTERS *e
stack.clear();

BOOL result = SymInitialize(hProcess, NULL, TRUE);
if (result == FALSE) {
return;
}

STACKFRAME64 stackFrame;
memset(&stackFrame, 0, sizeof(STACKFRAME64));
const int nameSize = 255;
Expand Down
2 changes: 1 addition & 1 deletion runtime/os_interface/windows/device_factory_win.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down
5 changes: 4 additions & 1 deletion runtime/os_interface/windows/kmdaf_listener.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/*
* Copyright (C) 2018 Intel Corporation
* Copyright (C) 2018-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "runtime/os_interface/windows/kmdaf_listener.h"
#pragma warning(push) // save the current state
#pragma warning(disable : 4189) // disable warning 4189 (unused local variable)
#include "kmdaf.h"
#pragma warning(pop) // restore state.

namespace OCLRT {

Expand Down
5 changes: 2 additions & 3 deletions runtime/os_interface/windows/thk_wrapper.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -80,8 +80,7 @@ class ThkWrapper {
SYSTEM_ENTER()
NTSTATUS Status;
Status = mFunc(param);
unsigned int ID = getId<Param>();
SYSTEM_LEAVE(ID);
SYSTEM_LEAVE(getId<Param>());
return Status;
} else {
return mFunc(param);
Expand Down
4 changes: 2 additions & 2 deletions runtime/os_interface/windows/wddm/wddm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ bool Wddm::init(PreemptionMode preemptionMode) {

EvictionStatus Wddm::evictAllTemporaryResources() {
decltype(temporaryResources) resourcesToEvict;
auto &lock = acquireLock(temporaryResourcesLock);
auto lock = acquireLock(temporaryResourcesLock);
temporaryResources.swap(resourcesToEvict);
if (resourcesToEvict.empty()) {
return EvictionStatus::NOT_APPLIED;
Expand All @@ -959,7 +959,7 @@ EvictionStatus Wddm::evictAllTemporaryResources() {
}

EvictionStatus Wddm::evictTemporaryResource(WddmAllocation &allocation) {
auto &lock = acquireLock(temporaryResourcesLock);
auto lock = acquireLock(temporaryResourcesLock);
auto position = std::find(temporaryResources.begin(), temporaryResources.end(), allocation.handle);
if (position == temporaryResources.end()) {
return EvictionStatus::NOT_APPLIED;
Expand Down
4 changes: 1 addition & 3 deletions runtime/sharings/d3d/d3d_sharing.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -41,8 +41,6 @@ D3DSharing<D3D>::~D3DSharing() {

template <typename D3D>
void D3DSharing<D3D>::synchronizeObject(UpdateData &updateData) {
void *sharedHandle = nullptr;

sharingFunctions->getDeviceContext(d3dQuery);
if (!sharedResource) {
sharingFunctions->copySubresourceRegion(resourceStaging, 0, resource, subresource);
Expand Down
6 changes: 4 additions & 2 deletions unit_tests/device/device_win_timers_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -22,7 +22,9 @@ TEST_F(MockOSTimeWinTest, DynamicResolution) {
auto wddmMock = std::unique_ptr<WddmMock>(new WddmMock());
auto mDev = std::unique_ptr<MockDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(nullptr));

bool error = wddmMock->init(mDev->getPreemptionMode());
bool success = wddmMock->init(mDev->getPreemptionMode());
EXPECT_TRUE(success);

std::unique_ptr<MockOSTimeWin> timeWin(new MockOSTimeWin(wddmMock.get()));

double res = 0.0;
Expand Down
3 changes: 1 addition & 2 deletions unit_tests/gen9/windows/os_interface_tests_gen9.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2017-2018 Intel Corporation
* Copyright (C) 2017-2019 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -13,7 +13,6 @@ typedef OsInterfaceTest OsInterfaceTestSkl;

GEN9TEST_F(OsInterfaceTestSkl, askKmdIfPreemptionRegisterWhitelisted) {
HardwareInfo *hwInfo = nullptr;
const HardwareInfo *refHwinfo = *platformDevices;
size_t numDevices = 0;

ExecutionEnvironment executionEnvironment;
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ int main(int argc, char **argv) {
int retVal = 0;
bool useDefaultListener = false;
bool enable_alarm = true;
bool enable_segv = true;
bool enable_abrt = true;
bool setupFeatureTable = testMode == TestMode::AubTests ? true : false;

applyWorkarounds();

#if defined(__linux__)
bool enable_segv = true;
bool enable_abrt = true;
if (getenv("IGDRCL_TEST_SELF_EXEC") == nullptr) {
std::string wd = getRunPath(argv[0]);
setenv("LD_LIBRARY_PATH", wd.c_str(), 1);
Expand Down
1 change: 0 additions & 1 deletion unit_tests/mocks/mock_wddm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ bool WddmMock::destroyAllocation(WddmAllocation *alloc, OsContextWin *osContext)
D3DKMT_HANDLE *allocationHandles = nullptr;
uint32_t allocationCount = 0;
D3DKMT_HANDLE resourceHandle = 0;
void *cpuPtr = nullptr;
void *reserveAddress = alloc->getReservedAddress();
if (alloc->peekSharedHandle()) {
resourceHandle = alloc->resourceHandle;
Expand Down
25 changes: 8 additions & 17 deletions unit_tests/os_interface/windows/device_command_stream_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ TEST_F(WddmCommandStreamTest, givenGraphicsAllocationWithDifferentGpuAddressThen

LinearStream cs(commandBuffer);
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
csr->flush(batchBuffer, csr->getResidencyAllocations());
EXPECT_EQ(mockGpuAddres, wddm->submitResult.commandBufferSubmitted);
memoryManager->freeGraphicsMemory(commandBuffer);
}
Expand Down Expand Up @@ -376,7 +376,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafDisabledWhenFlushIsCalledWithAll
ResidencyContainer allocationsForResidency = {linearStreamAllocation};

EXPECT_FALSE(wddm->isKmDafEnabled());
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
csr->flush(batchBuffer, allocationsForResidency);

EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -392,7 +392,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithoutA
BatchBuffer batchBuffer{cs.getGraphicsAllocation(), 0, 0, nullptr, false, false, QueueThrottle::MEDIUM, cs.getUsed(), &cs};

wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
csr->flush(batchBuffer, csr->getResidencyAllocations());

EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -415,7 +415,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithResi
EXPECT_EQ(linearStreamAllocation, csr->getResidencyAllocations()[0]);

wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, csr->getResidencyAllocations());
csr->flush(batchBuffer, csr->getResidencyAllocations());

EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -437,7 +437,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {linearStreamAllocation};

wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
csr->flush(batchBuffer, allocationsForResidency);

EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -459,7 +459,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {fillPatternAllocation};

wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
csr->flush(batchBuffer, allocationsForResidency);

EXPECT_EQ(1u, wddm->kmDafLockResult.called);
EXPECT_EQ(1u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -480,7 +480,7 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
ResidencyContainer allocationsForResidency = {nonLinearStreamAllocation};

wddm->setKmDafEnabled(true);
auto flushStamp = csr->flush(batchBuffer, allocationsForResidency);
csr->flush(batchBuffer, allocationsForResidency);

EXPECT_EQ(0u, wddm->kmDafLockResult.called);
EXPECT_EQ(0u, wddm->kmDafLockResult.lockedAllocations.size());
Expand All @@ -490,8 +490,6 @@ TEST_F(WddmCommandStreamTest, givenWddmWithKmDafEnabledWhenFlushIsCalledWithAllo
}

TEST_F(WddmCommandStreamTest, makeResident) {
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);

GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
Expand All @@ -506,8 +504,6 @@ TEST_F(WddmCommandStreamTest, makeResident) {
}

TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations) {
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);

GraphicsAllocation *commandBuffer = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
ASSERT_NE(nullptr, commandBuffer);
LinearStream cs(commandBuffer);
Expand All @@ -522,8 +518,6 @@ TEST_F(WddmCommandStreamTest, makeNonResidentPutsAllocationInEvictionAllocations
}

TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidateList) {
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);

GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
GraphicsAllocation *allocation2 = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
ASSERT_NE(nullptr, allocation);
Expand All @@ -543,8 +537,6 @@ TEST_F(WddmCommandStreamTest, processEvictionPlacesAllAllocationsOnTrimCandidate
}

TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);

GraphicsAllocation *allocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
ASSERT_NE(nullptr, allocation);

Expand All @@ -562,7 +554,6 @@ TEST_F(WddmCommandStreamTest, processEvictionClearsEvictionAllocations) {
TEST_F(WddmCommandStreamTest, makeResidentNonResidentMemObj) {
GraphicsAllocation *gfxAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
Buffer *buffer = new AlignedBuffer(gfxAllocation);
WddmMemoryManager *wddmMM = reinterpret_cast<WddmMemoryManager *>(memoryManager);

csr->makeResident(*buffer->getGraphicsAllocation());
EXPECT_EQ(0u, wddm->makeResidentResult.called);
Expand Down Expand Up @@ -888,7 +879,7 @@ HWTEST_F(WddmCsrCompressionTests, givenEnabledCompressionWhenFlushingThenInitTra

auto memoryManager = executionEnvironment->memoryManager.get();

auto &csrCS = mockWddmCsr->getCS();
mockWddmCsr->getCS();

auto graphicsAllocation = memoryManager->allocateGraphicsMemoryWithProperties(MockAllocationProperties{MemoryConstants::pageSize});
IndirectHeap cs(graphicsAllocation);
Expand Down
1 change: 1 addition & 0 deletions unit_tests/os_interface/windows/gl/gl_os_sharing_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ TEST_F(GlArbSyncEventOsTest, WhenCreateSynchronizationObjectSucceedsThenAllHAndl
gdi->createSynchronizationObject.mFunc = CreateSyncObjectMock::createSynchObject;
gdi->createSynchronizationObject2.mFunc = CreateSyncObjectMock::createSynchObject2;
auto ret = setupArbSyncObject(sharing, osInterface, syncInfo);
EXPECT_TRUE(ret);
EXPECT_EQ(1U, syncInfo.serverSynchronizationObject);
EXPECT_EQ(2U, syncInfo.clientSynchronizationObject);
EXPECT_EQ(3U, syncInfo.submissionSynchronizationObject);
Expand Down
3 changes: 1 addition & 2 deletions unit_tests/os_interface/windows/wddm20_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ TEST_F(Wddm20WithMockGdiDllTests, givenWddmAllocationWhenMappingGpuVaThenUseGmmS

allocation.gmm = gmm.get();
auto status = wddm->createAllocation(&allocation);
EXPECT_EQ(STATUS_SUCCESS, status);

auto mockResourceInfo = static_cast<MockGmmResourceInfo *>(gmm->gmmResourceInfo.get());
mockResourceInfo->overrideReturnedSize(allocation.getAlignedSize() + (2 * MemoryConstants::pageSize));
Expand Down Expand Up @@ -646,8 +647,6 @@ TEST_F(Wddm20Tests, givenDestroyAllocationWhenItIsCalledThenAllocationIsPassedTo

*osContextWin->getResidencyController().getMonitoredFence().cpuAddress = 10;

D3DKMT_HANDLE handle = (D3DKMT_HANDLE)0x1234;

gdi->getWaitFromCpuArg().FenceValueArray = nullptr;
gdi->getWaitFromCpuArg().Flags.Value = 0;
gdi->getWaitFromCpuArg().hDevice = (D3DKMT_HANDLE)0;
Expand Down
Loading

0 comments on commit cb37f2a

Please sign in to comment.