From 2548bea71d5c22c76fd647b5dd5dffd62011b82a Mon Sep 17 00:00:00 2001 From: Piotr Fusik Date: Mon, 29 Jul 2019 16:11:51 +0200 Subject: [PATCH] Minor clean-up. Change-Id: Id1523930fc8aedf85506e254c67f6b1ca8dd020d Signed-off-by: Piotr Fusik --- .../command_stream_receiver_hw.h | 2 - runtime/gtpin/gtpin_hw_helper.inl | 2 +- .../helpers/flat_batch_buffer_helper_hw.inl | 2 +- runtime/kernel/kernel.cpp | 8 ++-- runtime/memory_manager/host_ptr_defines.h | 8 +--- .../os_interface/linux/drm_buffer_object.h | 2 +- .../os_interface/linux/drm_command_stream.h | 2 +- .../os_interface/linux/drm_command_stream.inl | 12 ++--- .../os_interface/linux/drm_memory_manager.cpp | 5 +- .../windows/wddm_device_command_stream.h | 4 +- .../windows/wddm_device_command_stream.inl | 10 ++-- runtime/tbx/tbx_sockets_imp.cpp | 2 +- runtime/utilities/directory.h | 2 +- runtime/utilities/linux/directory.cpp | 2 +- runtime/utilities/windows/directory.cpp | 2 +- unit_tests/fixtures/kernel_data_fixture.cpp | 2 +- unit_tests/helpers/per_thread_data_tests.cpp | 4 +- unit_tests/mocks/mock_sip.cpp | 4 +- .../offline_compiler_tests.cpp | 2 +- unit_tests/program/program_data_tests.cpp | 46 +++++++++---------- 20 files changed, 55 insertions(+), 68 deletions(-) diff --git a/runtime/command_stream/command_stream_receiver_hw.h b/runtime/command_stream/command_stream_receiver_hw.h index 215ee60ed5..34b2071776 100644 --- a/runtime/command_stream/command_stream_receiver_hw.h +++ b/runtime/command_stream/command_stream_receiver_hw.h @@ -73,8 +73,6 @@ class CommandStreamReceiverHw : public CommandStreamReceiver { void blitBuffer(const BlitProperties &blitProperites) override; protected: - using CommandStreamReceiver::osContext; - void programPreemption(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags); void programL3(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t &newL3Config); void programPreamble(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags, uint32_t &newL3Config); diff --git a/runtime/gtpin/gtpin_hw_helper.inl b/runtime/gtpin/gtpin_hw_helper.inl index 956f0509ef..5a8d05fb4e 100644 --- a/runtime/gtpin/gtpin_hw_helper.inl +++ b/runtime/gtpin/gtpin_hw_helper.inl @@ -28,7 +28,7 @@ bool GTPinHwHelperHw::addSurfaceState(Kernel *pKernel) { size_t sizeToEnlarge = ssSize + btsSize; size_t currBTOffset = pKernel->getBindingTableOffset(); size_t currSurfaceStateSize = currBTOffset; - char *pSsh = reinterpret_cast(pKernel->getSurfaceStateHeap()); + char *pSsh = static_cast(pKernel->getSurfaceStateHeap()); char *pNewSsh = new char[sshSize + sizeToEnlarge]; memcpy_s(pNewSsh, sshSize + sizeToEnlarge, pSsh, currSurfaceStateSize); RENDER_SURFACE_STATE *pSS = reinterpret_cast(pNewSsh + currSurfaceStateSize); diff --git a/runtime/helpers/flat_batch_buffer_helper_hw.inl b/runtime/helpers/flat_batch_buffer_helper_hw.inl index 864382527a..b9bc0ffdf3 100644 --- a/runtime/helpers/flat_batch_buffer_helper_hw.inl +++ b/runtime/helpers/flat_batch_buffer_helper_hw.inl @@ -114,7 +114,7 @@ GraphicsAllocation *FlatBatchBufferHelperHw::flattenBatchBuffer(Batch flatBatchBuffer = getMemoryManager()->allocateGraphicsMemoryWithProperties(flatBatchBufferProperties); UNRECOVERABLE_IF(flatBatchBuffer == nullptr); - char *ptr = reinterpret_cast(flatBatchBuffer->getUnderlyingBuffer()); + char *ptr = static_cast(flatBatchBuffer->getUnderlyingBuffer()); memcpy_s(ptr, indirectPatchCommandsSize, indirectPatchCommands.get(), indirectPatchCommandsSize); ptr += indirectPatchCommandsSize; for (auto &chunk : orderedChunks) { diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index debb2d27fb..a8a4858bf4 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -755,13 +755,11 @@ void Kernel::setStartOffset(uint32_t offset) { } const void *Kernel::getSurfaceStateHeap() const { - return kernelInfo.usesSsh - ? pSshLocal.get() - : nullptr; + return kernelInfo.usesSsh ? pSshLocal.get() : nullptr; } void *Kernel::getSurfaceStateHeap() { - return const_cast(const_cast(this)->getSurfaceStateHeap()); + return kernelInfo.usesSsh ? pSshLocal.get() : nullptr; } size_t Kernel::getDynamicStateHeapSize() const { @@ -783,7 +781,7 @@ size_t Kernel::getNumberOfBindingTableStates() const { } void Kernel::resizeSurfaceStateHeap(void *pNewSsh, size_t newSshSize, size_t newBindingTableCount, size_t newBindingTableOffset) { - pSshLocal.reset(reinterpret_cast(pNewSsh)); + pSshLocal.reset(static_cast(pNewSsh)); sshLocalSize = static_cast(newSshSize); numberOfBindingTableStates = newBindingTableCount; localBindingTableOffset = newBindingTableOffset; diff --git a/runtime/memory_manager/host_ptr_defines.h b/runtime/memory_manager/host_ptr_defines.h index 8dab08c81b..ec2a44f481 100644 --- a/runtime/memory_manager/host_ptr_defines.h +++ b/runtime/memory_manager/host_ptr_defines.h @@ -61,7 +61,7 @@ struct FragmentStorage { }; struct AllocationStorageData { - OsHandle *osHandleStorage; + OsHandle *osHandleStorage = nullptr; size_t fragmentSize = 0; const void *cpuPtr = nullptr; bool freeTheFragment = false; @@ -71,12 +71,6 @@ struct AllocationStorageData { struct OsHandleStorage { AllocationStorageData fragmentStorageData[maxFragmentsCount]; uint32_t fragmentCount = 0; - OsHandleStorage() { - for (int i = 0; i < maxFragmentsCount; i++) { - fragmentStorageData[i].osHandleStorage = nullptr; - fragmentStorageData[i].cpuPtr = nullptr; - } - } }; } // namespace NEO diff --git a/runtime/os_interface/linux/drm_buffer_object.h b/runtime/os_interface/linux/drm_buffer_object.h index 59440c98cf..aac6bce51d 100644 --- a/runtime/os_interface/linux/drm_buffer_object.h +++ b/runtime/os_interface/linux/drm_buffer_object.h @@ -59,7 +59,7 @@ class BufferObject { uint64_t peekUnmapSize() const { return unmapSize; } StorageAllocatorType peekAllocationType() const { return storageAllocatorType; } void setAllocationType(StorageAllocatorType allocatorType) { this->storageAllocatorType = allocatorType; } - bool peekIsReusableAllocation() { return this->isReused; } + bool peekIsReusableAllocation() const { return this->isReused; } protected: BufferObject(Drm *drm, int handle, bool isAllocated); diff --git a/runtime/os_interface/linux/drm_command_stream.h b/runtime/os_interface/linux/drm_command_stream.h index 28f856f44a..ca0a6b82f3 100644 --- a/runtime/os_interface/linux/drm_command_stream.h +++ b/runtime/os_interface/linux/drm_command_stream.h @@ -42,7 +42,7 @@ class DrmCommandStreamReceiver : public DeviceCommandStreamReceiver { void makeNonResident(GraphicsAllocation &gfxAllocation) override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override; - DrmMemoryManager *getMemoryManager(); + DrmMemoryManager *getMemoryManager() const; gemCloseWorkerMode peekGemCloseWorkerOperationMode() { return this->gemCloseWorkerOperationMode; diff --git a/runtime/os_interface/linux/drm_command_stream.inl b/runtime/os_interface/linux/drm_command_stream.inl index ee1d8d4c42..98a1350818 100644 --- a/runtime/os_interface/linux/drm_command_stream.inl +++ b/runtime/os_interface/linux/drm_command_stream.inl @@ -104,7 +104,7 @@ void DrmCommandStreamReceiver::makeResident(BufferObject *bo) { template void DrmCommandStreamReceiver::processResidency(ResidencyContainer &inputAllocationsForResidency) { for (auto &alloc : inputAllocationsForResidency) { - auto drmAlloc = static_cast(alloc); + auto drmAlloc = static_cast(alloc); if (drmAlloc->fragmentsStorage.fragmentCount) { for (unsigned int f = 0; f < drmAlloc->fragmentsStorage.fragmentCount; f++) { const auto osContextId = osContext->getContextId(); @@ -129,18 +129,16 @@ void DrmCommandStreamReceiver::makeNonResident(GraphicsAllocation &gf if (this->residency.size() != 0) { this->residency.clear(); } - if (gfxAllocation.fragmentsStorage.fragmentCount) { - for (auto fragmentId = 0u; fragmentId < gfxAllocation.fragmentsStorage.fragmentCount; fragmentId++) { - gfxAllocation.fragmentsStorage.fragmentStorageData[fragmentId].residency->resident[osContext->getContextId()] = false; - } + for (auto fragmentId = 0u; fragmentId < gfxAllocation.fragmentsStorage.fragmentCount; fragmentId++) { + gfxAllocation.fragmentsStorage.fragmentStorageData[fragmentId].residency->resident[osContext->getContextId()] = false; } } gfxAllocation.releaseResidencyInOsContext(this->osContext->getContextId()); } template -DrmMemoryManager *DrmCommandStreamReceiver::getMemoryManager() { - return (DrmMemoryManager *)CommandStreamReceiver::getMemoryManager(); +DrmMemoryManager *DrmCommandStreamReceiver::getMemoryManager() const { + return static_cast(CommandStreamReceiver::getMemoryManager()); } template diff --git a/runtime/os_interface/linux/drm_memory_manager.cpp b/runtime/os_interface/linux/drm_memory_manager.cpp index 6191da90f3..1440fb632f 100644 --- a/runtime/os_interface/linux/drm_memory_manager.cpp +++ b/runtime/os_interface/linux/drm_memory_manager.cpp @@ -412,7 +412,7 @@ DrmAllocation *DrmMemoryManager::allocate32BitGraphicsMemoryImpl(const Allocatio BufferObject *DrmMemoryManager::findAndReferenceSharedBufferObject(int boHandle) { BufferObject *bo = nullptr; for (const auto &i : sharingBufferObjects) { - if (i->handle == static_cast(boHandle)) { + if (i->handle == boHandle) { bo = i; bo->reference(); break; @@ -547,8 +547,7 @@ void DrmMemoryManager::removeAllocationFromHostPtrManager(GraphicsAllocation *gf } void DrmMemoryManager::freeGraphicsMemoryImpl(GraphicsAllocation *gfxAllocation) { - DrmAllocation *input; - input = static_cast(gfxAllocation); + auto input = static_cast(gfxAllocation); for (auto handleId = 0u; handleId < maxHandleCount; handleId++) { if (gfxAllocation->getGmm(handleId)) { delete gfxAllocation->getGmm(handleId); diff --git a/runtime/os_interface/windows/wddm_device_command_stream.h b/runtime/os_interface/windows/wddm_device_command_stream.h index 19d09773d7..dd3506f295 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.h +++ b/runtime/os_interface/windows/wddm_device_command_stream.h @@ -30,8 +30,8 @@ class WddmCommandStreamReceiver : public DeviceCommandStreamReceiver void processEviction() override; bool waitForFlushStamp(FlushStamp &flushStampToWait) override; - WddmMemoryManager *getMemoryManager(); - Wddm *peekWddm() { + WddmMemoryManager *getMemoryManager() const; + Wddm *peekWddm() const { return wddm; } GmmPageTableMngr *createPageTableManager() override; diff --git a/runtime/os_interface/windows/wddm_device_command_stream.inl b/runtime/os_interface/windows/wddm_device_command_stream.inl index 83eb394d74..f409b1c015 100644 --- a/runtime/os_interface/windows/wddm_device_command_stream.inl +++ b/runtime/os_interface/windows/wddm_device_command_stream.inl @@ -103,13 +103,13 @@ FlushStamp WddmCommandStreamReceiver::flush(BatchBuffer &batchBuffer, template void WddmCommandStreamReceiver::makeResident(GraphicsAllocation &gfxAllocation) { - DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", static_cast(&gfxAllocation)); + DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation =", &gfxAllocation); if (gfxAllocation.fragmentsStorage.fragmentCount == 0) { - DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation default handle =", static_cast(&gfxAllocation)->getDefaultHandle()); + DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "allocation default handle =", static_cast(gfxAllocation).getDefaultHandle()); } else { - for (uint32_t allocationId = 0; allocationId < static_cast(&gfxAllocation)->fragmentsStorage.fragmentCount; allocationId++) { - DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "fragment handle =", static_cast(&gfxAllocation)->fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle); + for (uint32_t allocationId = 0; allocationId < gfxAllocation.fragmentsStorage.fragmentCount; allocationId++) { + DBG_LOG(ResidencyDebugEnable, "Residency:", __FUNCTION__, "fragment handle =", gfxAllocation.fragmentsStorage.fragmentStorageData[allocationId].osHandleStorage->handle); } } @@ -129,7 +129,7 @@ void WddmCommandStreamReceiver::processEviction() { } template -WddmMemoryManager *WddmCommandStreamReceiver::getMemoryManager() { +WddmMemoryManager *WddmCommandStreamReceiver::getMemoryManager() const { return static_cast(CommandStreamReceiver::getMemoryManager()); } diff --git a/runtime/tbx/tbx_sockets_imp.cpp b/runtime/tbx/tbx_sockets_imp.cpp index c39b910d6c..bcbc2f7bb9 100644 --- a/runtime/tbx/tbx_sockets_imp.cpp +++ b/runtime/tbx/tbx_sockets_imp.cpp @@ -297,7 +297,7 @@ bool TbxSocketsImp::sendWriteData(const void *buffer, size_t sizeInBytes) { bool TbxSocketsImp::getResponseData(void *buffer, size_t sizeInBytes) { size_t totalRecv = 0; - auto dataBuffer = reinterpret_cast(buffer); + auto dataBuffer = static_cast(buffer); do { auto bytesRecv = ::recv(m_socket, &dataBuffer[totalRecv], static_cast(sizeInBytes - totalRecv), 0); diff --git a/runtime/utilities/directory.h b/runtime/utilities/directory.h index de680ad61c..a0a8b2b790 100644 --- a/runtime/utilities/directory.h +++ b/runtime/utilities/directory.h @@ -13,6 +13,6 @@ namespace NEO { class Directory { public: - static std::vector getFiles(std::string &path); + static std::vector getFiles(const std::string &path); }; }; // namespace NEO diff --git a/runtime/utilities/linux/directory.cpp b/runtime/utilities/linux/directory.cpp index 8eefc65df5..b6774019cd 100644 --- a/runtime/utilities/linux/directory.cpp +++ b/runtime/utilities/linux/directory.cpp @@ -12,7 +12,7 @@ namespace NEO { -std::vector Directory::getFiles(std::string &path) { +std::vector Directory::getFiles(const std::string &path) { std::vector files; DIR *dir = opendir(path.c_str()); diff --git a/runtime/utilities/windows/directory.cpp b/runtime/utilities/windows/directory.cpp index d55cc07fbf..86c54b92e3 100644 --- a/runtime/utilities/windows/directory.cpp +++ b/runtime/utilities/windows/directory.cpp @@ -11,7 +11,7 @@ namespace NEO { -std::vector Directory::getFiles(std::string &path) { +std::vector Directory::getFiles(const std::string &path) { std::vector files; std::string newPath; diff --git a/unit_tests/fixtures/kernel_data_fixture.cpp b/unit_tests/fixtures/kernel_data_fixture.cpp index ae1853582e..9802d2c2f5 100644 --- a/unit_tests/fixtures/kernel_data_fixture.cpp +++ b/unit_tests/fixtures/kernel_data_fixture.cpp @@ -30,7 +30,7 @@ void KernelDataTest::buildAndDecode() { kernelDataSize += sizeof(SPatchDataParameterStream); program->setDevice(pDevice); - pKernelData = reinterpret_cast(alignedMalloc(kernelDataSize, MemoryConstants::cacheLineSize)); + pKernelData = static_cast(alignedMalloc(kernelDataSize, MemoryConstants::cacheLineSize)); ASSERT_NE(nullptr, pKernelData); // kernel blob diff --git a/unit_tests/helpers/per_thread_data_tests.cpp b/unit_tests/helpers/per_thread_data_tests.cpp index a905b2579a..e40a40c7e6 100644 --- a/unit_tests/helpers/per_thread_data_tests.cpp +++ b/unit_tests/helpers/per_thread_data_tests.cpp @@ -227,11 +227,11 @@ TEST(PerThreadDataTest, generateLocalIDs) { auto sizePerThreadDataTotal = PerThreadDataHelper::getPerThreadDataSizeTotal(simd, numChannels, localWorkSize); auto sizeOverSizedBuffer = sizePerThreadDataTotal * 4; - auto buffer = reinterpret_cast(alignedMalloc(sizeOverSizedBuffer, 16)); + auto buffer = static_cast(alignedMalloc(sizeOverSizedBuffer, 16)); memset(buffer, 0, sizeOverSizedBuffer); // Setup reference filled with zeros - auto reference = reinterpret_cast(alignedMalloc(sizePerThreadDataTotal, 16)); + auto reference = static_cast(alignedMalloc(sizePerThreadDataTotal, 16)); memset(reference, 0, sizePerThreadDataTotal); LinearStream stream(buffer, sizeOverSizedBuffer / 2); diff --git a/unit_tests/mocks/mock_sip.cpp b/unit_tests/mocks/mock_sip.cpp index 33ffe169bc..fcd5ed15f0 100644 --- a/unit_tests/mocks/mock_sip.cpp +++ b/unit_tests/mocks/mock_sip.cpp @@ -23,7 +23,7 @@ namespace NEO { std::vector MockSipKernel::dummyBinaryForSip; std::vector MockSipKernel::getDummyGenBinary() { - if (dummyBinaryForSip.size() == 0) { + if (dummyBinaryForSip.empty()) { dummyBinaryForSip = getBinary(); } return dummyBinaryForSip; @@ -37,7 +37,7 @@ std::vector MockSipKernel::getBinary() { UNRECOVERABLE_IF(binary == nullptr); - std::vector ret{reinterpret_cast(binary), reinterpret_cast(binary) + binarySize}; + std::vector ret{static_cast(binary), static_cast(binary) + binarySize}; deleteDataReadFromFile(binary); return ret; diff --git a/unit_tests/offline_compiler/offline_compiler_tests.cpp b/unit_tests/offline_compiler/offline_compiler_tests.cpp index de25e6658c..4bce661837 100644 --- a/unit_tests/offline_compiler/offline_compiler_tests.cpp +++ b/unit_tests/offline_compiler/offline_compiler_tests.cpp @@ -610,7 +610,7 @@ TEST(OfflineCompilerTest, getStringWithinDelimiters) { EXPECT_EQ(std::string::npos, dst.find("R\"===(")); EXPECT_EQ(std::string::npos, dst.find(")===\"")); - delete[] reinterpret_cast(ptrSrc); + delete[] static_cast(ptrSrc); } TEST(OfflineCompilerTest, convertToPascalCase) { diff --git a/unit_tests/program/program_data_tests.cpp b/unit_tests/program/program_data_tests.cpp index 925477ab86..8d72bb111b 100644 --- a/unit_tests/program/program_data_tests.cpp +++ b/unit_tests/program/program_data_tests.cpp @@ -175,7 +175,7 @@ TEST_F(ProgramDataTest, AllocateConstantMemorySurfaceProgramBinaryInfo) { buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface()); - EXPECT_EQ(0, memcmp(constValue, reinterpret_cast(pProgram->getConstantSurface()->getUnderlyingBuffer()), constSize)); + EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize)); } TEST_F(MockProgramDataTest, whenGlobalConstantsAreExportedThenAllocateSurfacesAsSvm) { @@ -327,7 +327,7 @@ TEST_F(ProgramDataTest, GivenDeviceForcing32BitMessagesWhenConstAllocationIsPres buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getConstantSurface()); - EXPECT_EQ(0, memcmp(constValue, reinterpret_cast(pProgram->getConstantSurface()->getUnderlyingBuffer()), constSize)); + EXPECT_EQ(0, memcmp(constValue, pProgram->getConstantSurface()->getUnderlyingBuffer(), constSize)); if (is64bit) { EXPECT_TRUE(pProgram->getConstantSurface()->is32BitAllocation()); @@ -338,7 +338,7 @@ TEST_F(ProgramDataTest, AllocateGlobalMemorySurfaceProgramBinaryInfo) { auto globalSize = setupGlobalAllocation(); buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface()); - EXPECT_EQ(0, memcmp(globalValue, reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()), globalSize)); + EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize)); } TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { @@ -390,7 +390,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { sizeof(SPatchAllocateGlobalMemorySurfaceProgramBinaryInfo)); memcpy_s((cl_char *)pAllocateGlobalMemorySurface + sizeof(allocateGlobalMemorySurface), globalPointerSize, &pGlobalPointerValue, globalPointerSize); - pProgramPatchList = (void *)pAllocateGlobalMemorySurface; + pProgramPatchList = pAllocateGlobalMemorySurface; programPatchListSize = allocateGlobalMemorySurface.Size; buildAndDecodeProgramPatchList(); @@ -400,7 +400,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { globalSurface->setCpuPtrAndGpuAddress(globalSurface->getUnderlyingBuffer(), globalSurface->getGpuAddress() + 1); EXPECT_NE(reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalSurface->getGpuAddress()); - EXPECT_EQ(0, memcmp(&pGlobalPointerValue, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pAllocateGlobalMemorySurface; @@ -423,7 +423,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(&pGlobalPointerValue, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; @@ -446,7 +446,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(&pGlobalPointerValue, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; @@ -469,7 +469,7 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(&pGlobalPointerValue, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_EQ(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); delete[] pGlobalPointer; @@ -493,9 +493,9 @@ TEST_F(ProgramDataTest, GlobalPointerProgramBinaryInfo) { buildAndDecodeProgramPatchList(); if (!globalSurface->is32BitAllocation()) { - EXPECT_NE(0, memcmp(&pGlobalPointerValue, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_NE(0, memcmp(&pGlobalPointerValue, globalSurface->getUnderlyingBuffer(), globalPointerSize)); ptr = pGlobalPointerValue + (globalSurface->getGpuAddressToPatch()); - EXPECT_EQ(0, memcmp(&ptr, reinterpret_cast(globalSurface->getUnderlyingBuffer()), globalPointerSize)); + EXPECT_EQ(0, memcmp(&ptr, globalSurface->getUnderlyingBuffer(), globalPointerSize)); } delete[] pGlobalPointer; } @@ -528,7 +528,7 @@ TEST_F(ProgramDataTest, Given32BitDeviceWhenGlobalMemorySurfaceIsPresentThenItHa buildAndDecodeProgramPatchList(); EXPECT_NE(nullptr, pProgram->getGlobalSurface()); - EXPECT_EQ(0, memcmp(globalValue, reinterpret_cast(pProgram->getGlobalSurface()->getUnderlyingBuffer()), globalSize)); + EXPECT_EQ(0, memcmp(globalValue, pProgram->getGlobalSurface()->getUnderlyingBuffer(), globalSize)); if (is64bit) { EXPECT_TRUE(pProgram->getGlobalSurface()->is32BitAllocation()); } @@ -602,9 +602,9 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { constantSurface->setCpuPtrAndGpuAddress(constantSurface->getUnderlyingBuffer(), constantSurface->getGpuAddress() + 1); EXPECT_NE(reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantSurface->getGpuAddress()); - EXPECT_EQ(0, memcmp(pConstantData, reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantDataLen)); + EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // there was no PATCH_TOKEN_CONSTANT_POINTER_PROGRAM_BINARY_INFO, so constant buffer offset should be still 0 - EXPECT_EQ(0U, *(uint64_t *)(reinterpret_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); + EXPECT_EQ(0U, *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // once finally constant buffer offset gets patched - the patch value depends on the bitness of the compute kernel auto patchOffsetValueStorage = std::unique_ptr(new uint64_t); // 4bytes for 32-bit compute kernel, full 8byte for 64-bit compute kernel uint64_t *patchOffsetValue = patchOffsetValueStorage.get(); @@ -633,11 +633,11 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { programPatchListSize = constantPointer.Size; buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(pConstantData, reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantDataLen)); + EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched - EXPECT_EQ(0U, *(uint64_t *)(reinterpret_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); + EXPECT_EQ(0U, *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset - *(uint64_t *)((char *)constantSurface->getUnderlyingBuffer() + constantBufferOffsetPatchOffset) = 0U; + *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset) = 0U; delete[] pConstantPointer; @@ -658,9 +658,9 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { programPatchListSize = constantPointer.Size; buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(pConstantData, reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantDataLen)); + EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched - EXPECT_EQ(0U, *(uint64_t *)(reinterpret_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); + EXPECT_EQ(0U, *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset *(uint64_t *)((char *)constantSurface->getUnderlyingBuffer() + constantBufferOffsetPatchOffset) = 0U; @@ -683,11 +683,11 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { programPatchListSize = constantPointer.Size; buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(pConstantData, reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantDataLen)); + EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was not patched - EXPECT_EQ(0U, *(uint64_t *)(reinterpret_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); + EXPECT_EQ(0U, *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); // reset the constant pointer offset - *(uint64_t *)((char *)constantSurface->getUnderlyingBuffer() + constantBufferOffsetPatchOffset) = 0U; + *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset) = 0U; delete[] pConstantPointer; @@ -709,9 +709,9 @@ TEST_F(ProgramDataTest, ConstantPointerProgramBinaryInfo) { buildAndDecodeProgramPatchList(); - EXPECT_EQ(0, memcmp(pConstantData, reinterpret_cast(constantSurface->getUnderlyingBuffer()), constantDataLen)); + EXPECT_EQ(0, memcmp(pConstantData, constantSurface->getUnderlyingBuffer(), constantDataLen)); // check that constant pointer offset was patched - EXPECT_EQ(*reinterpret_cast(patchOffsetValue), *(uint64_t *)(reinterpret_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); + EXPECT_EQ(*reinterpret_cast(patchOffsetValue), *reinterpret_cast(static_cast(constantSurface->getUnderlyingBuffer()) + constantBufferOffsetPatchOffset)); delete[] pConstantPointer; }