diff --git a/runtime/command_queue/command_queue_hw.h b/runtime/command_queue/command_queue_hw.h index 47f2115886..1dcf91362f 100644 --- a/runtime/command_queue/command_queue_hw.h +++ b/runtime/command_queue/command_queue_hw.h @@ -333,7 +333,7 @@ class CommandQueueHw : public CommandQueue { protected: MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo){}; - size_t calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image); + size_t calculateHostPtrSizeForImage(const size_t *region, size_t rowPitch, size_t slicePitch, Image *image); private: bool isTaskLevelUpdateRequired(const uint32_t &taskLevel, const cl_event *eventWaitList, const cl_uint &numEventsInWaitList, unsigned int commandType); diff --git a/runtime/command_queue/enqueue_common.h b/runtime/command_queue/enqueue_common.h index f55ef03224..b13c6130f0 100644 --- a/runtime/command_queue/enqueue_common.h +++ b/runtime/command_queue/enqueue_common.h @@ -290,7 +290,7 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, CompletionStamp completionStamp; if (!blockQueue) { if (parentKernel) { - size_t minSizeSSHForEM = KernelCommandsHelper::template getSizeRequiredForExecutionModel(const_cast(*parentKernel)); + size_t minSizeSSHForEM = KernelCommandsHelper::template getSizeRequiredForExecutionModel(*parentKernel); uint32_t taskCount = getCommandStreamReceiver().peekTaskCount() + 1; devQueueHw->setupExecutionModelDispatch(getIndirectHeap(IndirectHeap::SURFACE_STATE, minSizeSSHForEM), @@ -406,7 +406,7 @@ void CommandQueueHw::enqueueHandler(Surface **surfacesForResidency, if (blockQueue) { if (parentKernel) { - size_t minSizeSSHForEM = KernelCommandsHelper::template getSizeRequiredForExecutionModel(const_cast(*parentKernel)); + size_t minSizeSSHForEM = KernelCommandsHelper::template getSizeRequiredForExecutionModel(*parentKernel); blockedCommandsData->surfaceStateHeapSizeEM = minSizeSSHForEM; } @@ -730,7 +730,7 @@ void CommandQueueHw::computeOffsetsValueForRectCommands(size_t *buffe } template -size_t CommandQueueHw::calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image) { +size_t CommandQueueHw::calculateHostPtrSizeForImage(const size_t *region, size_t rowPitch, size_t slicePitch, Image *image) { auto bytesPerPixel = image->getSurfaceFormatInfo().ImageElementSizeInBytes; auto dstRowPitch = rowPitch ? rowPitch : region[0] * bytesPerPixel; auto dstSlicePitch = slicePitch ? slicePitch : ((image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ? 1 : region[1]) * dstRowPitch); diff --git a/runtime/command_queue/enqueue_read_image.h b/runtime/command_queue/enqueue_read_image.h index d91b78219a..87d5ae3441 100644 --- a/runtime/command_queue/enqueue_read_image.h +++ b/runtime/command_queue/enqueue_read_image.h @@ -72,7 +72,7 @@ cl_int CommandQueueHw::enqueueReadImage( BuiltInOwnershipWrapper builtInLock(builder, this->context); - size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast(region), inputRowPitch, inputSlicePitch, srcImage); + size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, srcImage); void *dstPtr = ptr; MemObjSurface srcImgSurf(srcImage); diff --git a/runtime/command_queue/enqueue_write_image.h b/runtime/command_queue/enqueue_write_image.h index 9118d77454..7546db69c2 100644 --- a/runtime/command_queue/enqueue_write_image.h +++ b/runtime/command_queue/enqueue_write_image.h @@ -66,7 +66,7 @@ cl_int CommandQueueHw::enqueueWriteImage( BuiltInOwnershipWrapper lock(builder, this->context); - size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast(region), inputRowPitch, inputSlicePitch, dstImage); + size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, dstImage); void *srcPtr = const_cast(ptr); MemObjSurface dstImgSurf(dstImage); diff --git a/runtime/command_queue/gpgpu_walker.h b/runtime/command_queue/gpgpu_walker.h index a81cf77f5c..0e02d2b601 100644 --- a/runtime/command_queue/gpgpu_walker.h +++ b/runtime/command_queue/gpgpu_walker.h @@ -247,7 +247,7 @@ IndirectHeap &getIndirectHeap(CommandQueue &commandQueue, const MultiDispatchInf if (Kernel *parentKernel = multiDispatchInfo.peekParentKernel()) { if (heapType == IndirectHeap::SURFACE_STATE) { - expectedSize += KernelCommandsHelper::template getSizeRequiredForExecutionModel(const_cast(*parentKernel)); + expectedSize += KernelCommandsHelper::template getSizeRequiredForExecutionModel(*parentKernel); } else //if (heapType == IndirectHeap::DYNAMIC_STATE || heapType == IndirectHeap::INDIRECT_OBJECT) { DeviceQueueHw *pDevQueue = castToObject>(commandQueue.getContext().getDefaultDeviceQueue()); diff --git a/runtime/helpers/base_object.h b/runtime/helpers/base_object.h index 06dfde7125..d694ff6ffc 100644 --- a/runtime/helpers/base_object.h +++ b/runtime/helpers/base_object.h @@ -59,7 +59,7 @@ inline DerivedType *castToObjectOrAbort(typename DerivedType::BaseType *object) template inline const DerivedType *castToObject(const typename DerivedType::BaseType *object) { - return const_cast(castToObject(const_cast(object))); + return castToObject(const_cast(object)); } template diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index fb3d8d8b73..7f23c92173 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -1939,7 +1939,7 @@ void Kernel::ReflectionSurfaceHelper::setParentImageParams(void *reflectionSurfa uint32_t numArgs = (uint32_t)parentArguments.size(); for (uint32_t i = 0; i < numArgs; i++) { if (parentArguments[i].type == Kernel::kernelArgType::IMAGE_OBJ) { - const Image *image = const_cast(castToObject((cl_mem)parentArguments[i].object)); + const Image *image = castToObject((cl_mem)parentArguments[i].object); if (image) { pImageParameters->m_ArraySize = (uint32_t)image->getImageDesc().image_array_size; pImageParameters->m_Depth = (uint32_t)image->getImageDesc().image_depth; @@ -1964,7 +1964,7 @@ void Kernel::ReflectionSurfaceHelper::setParentSamplerParams(void *reflectionSur uint32_t numArgs = (uint32_t)parentArguments.size(); for (uint32_t i = 0; i < numArgs; i++) { if (parentArguments[i].type == Kernel::kernelArgType::SAMPLER_OBJ) { - const Sampler *sampler = const_cast(castToObject((cl_sampler)parentArguments[i].object)); + const Sampler *sampler = castToObject((cl_sampler)parentArguments[i].object); if (sampler) { pParentSamplerParams->CoordinateSnapRequired = (uint32_t)sampler->getSnapWaValue(); pParentSamplerParams->m_AddressingMode = (uint32_t)sampler->addressingMode; diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index 50fbe44cd1..a8973e9857 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -233,7 +233,7 @@ Buffer *Buffer::create(Context *context, properties.flags, size, memory->getUnderlyingBuffer(), - const_cast(hostPtr), + hostPtr, memory, zeroCopyAllowed, isHostPtrSVM, diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index 85df475cb2..5ae93d2006 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -573,7 +573,7 @@ cl_int Image::validateImageTraits(Context *context, cl_mem_flags flags, const cl return CL_SUCCESS; } -size_t Image::calculateHostPtrSize(size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType) { +size_t Image::calculateHostPtrSize(const size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType) { DEBUG_BREAK_IF(!((rowPitch != 0) && (slicePitch != 0))); size_t sizeToReturn = 0u; diff --git a/runtime/mem_obj/image.h b/runtime/mem_obj/image.h index 0ddd4f5a03..62b6785e40 100644 --- a/runtime/mem_obj/image.h +++ b/runtime/mem_obj/image.h @@ -88,7 +88,7 @@ class Image : public MemObj { static cl_int validateImageTraits(Context *context, cl_mem_flags flags, const cl_image_format *imageFormat, const cl_image_desc *imageDesc, const void *hostPtr); - static size_t calculateHostPtrSize(size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType); + static size_t calculateHostPtrSize(const size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType); static void calculateHostPtrOffset(size_t *imageOffset, const size_t *origin, const size_t *region, size_t rowPitch, size_t slicePitch, uint32_t imageType, size_t bytesPerPixel); diff --git a/runtime/os_interface/linux/hw_info_config.cpp b/runtime/os_interface/linux/hw_info_config.cpp index 8eb9dd3ff7..bf23488f4c 100644 --- a/runtime/os_interface/linux/hw_info_config.cpp +++ b/runtime/os_interface/linux/hw_info_config.cpp @@ -78,10 +78,10 @@ int HwInfoConfig::configureHwInfo(const HardwareInfo *inHwInfo, HardwareInfo *ou auto pWaTable = std::unique_ptr(new WorkaroundTable); *pWaTable = *(inHwInfo->pWaTable); - outHwInfo->pPlatform = const_cast(pPlatform.get()); - outHwInfo->pSysInfo = const_cast(pSysInfo.get()); - outHwInfo->pSkuTable = const_cast(pSkuTable.get()); - outHwInfo->pWaTable = const_cast(pWaTable.get()); + outHwInfo->pPlatform = pPlatform.get(); + outHwInfo->pSysInfo = pSysInfo.get(); + outHwInfo->pSkuTable = pSkuTable.get(); + outHwInfo->pWaTable = pWaTable.get(); outHwInfo->capabilityTable = inHwInfo->capabilityTable; int val = 0; diff --git a/unit_tests/api/cl_intel_accelerator_tests.inl b/unit_tests/api/cl_intel_accelerator_tests.inl index 58e878c7fa..045681e2ce 100644 --- a/unit_tests/api/cl_intel_accelerator_tests.inl +++ b/unit_tests/api/cl_intel_accelerator_tests.inl @@ -161,42 +161,42 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCountWithNullReturnExpectPas } TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCount1ExpectPass) { - cl_uint parm_value = static_cast(-1); + cl_uint param_value = static_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_REFERENCE_COUNT_INTEL, sizeof(cl_uint), - reinterpret_cast(&parm_value), + ¶m_value, nullptr); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(1u, parm_value); + EXPECT_EQ(1u, param_value); } TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCountWithLongReturnExpectPass) { - cl_uint parm_value = static_cast(-1); + cl_uint param_value = static_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_REFERENCE_COUNT_INTEL, sizeof(cl_uint) + 1, - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(sizeof(cl_uint), param_value_size_ret); - EXPECT_EQ(1u, parm_value); + EXPECT_EQ(1u, param_value); } TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCountWithShortReturnExpectFail) { - cl_uint parm_value = static_cast(-1); + cl_uint param_value = static_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_REFERENCE_COUNT_INTEL, sizeof(cl_uint) - 1, - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); @@ -215,7 +215,7 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCountSizeQueryExpectPass) { } TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCount2ExpectPass) { - cl_uint parm_value = static_cast(-1); + cl_uint param_value = static_cast(-1); result = clRetainAcceleratorINTEL(accelerator); ASSERT_EQ(CL_SUCCESS, result); @@ -224,11 +224,11 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCount2ExpectPass) { accelerator, CL_ACCELERATOR_REFERENCE_COUNT_INTEL, sizeof(cl_uint), - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(2u, parm_value); + EXPECT_EQ(2u, param_value); result = clReleaseAcceleratorINTEL(accelerator); @@ -238,11 +238,11 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoReferenceCount2ExpectPass) { accelerator, CL_ACCELERATOR_REFERENCE_COUNT_INTEL, sizeof(cl_uint), - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); - EXPECT_EQ(1u, parm_value); + EXPECT_EQ(1u, param_value); } TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextNullReturnExpectPass) { @@ -258,13 +258,13 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextNullReturnExpectPass) { } TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextLongExpectPass) { - cl_context parm_value = reinterpret_cast(-1); + cl_context param_value = reinterpret_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_CONTEXT_INTEL, sizeof(cl_context) + 1, - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); @@ -272,30 +272,30 @@ TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextLongExpectPass) { } TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextLongExpectRightContext) { - cl_context parm_value = reinterpret_cast(-1); + cl_context param_value = reinterpret_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_CONTEXT_INTEL, sizeof(cl_context), - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); EXPECT_EQ(sizeof(cl_context), param_value_size_ret); cl_context referenceContext = static_cast(pContext); - EXPECT_EQ(referenceContext, parm_value); + EXPECT_EQ(referenceContext, param_value); } TEST_F(IntelAcceleratorGetInfoTest, GetInfoContextShortExpectPass) { - cl_context parm_value = reinterpret_cast(-1); + cl_context param_value = reinterpret_cast(-1); result = clGetAcceleratorInfoINTEL( accelerator, CL_ACCELERATOR_CONTEXT_INTEL, sizeof(cl_context) - 1, - reinterpret_cast(&parm_value), + ¶m_value, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); diff --git a/unit_tests/api/cl_intel_motion_estimation.cpp b/unit_tests/api/cl_intel_motion_estimation.cpp index 4210fce62c..a3a931953b 100644 --- a/unit_tests/api/cl_intel_motion_estimation.cpp +++ b/unit_tests/api/cl_intel_motion_estimation.cpp @@ -247,7 +247,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoDescriptorExactExpectPass) { accelerator, CL_ACCELERATOR_DESCRIPTOR_INTEL, sizeof(cl_motion_estimation_desc_intel), // exact - reinterpret_cast(&descReturn), + &descReturn, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); @@ -264,7 +264,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoDescriptorShortExpectFail) { accelerator, CL_ACCELERATOR_DESCRIPTOR_INTEL, sizeof(cl_motion_estimation_desc_intel) - 1, // short - reinterpret_cast(&descReturn), + &descReturn, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); @@ -276,7 +276,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoDescriptorVeryShortExpectFail) { accelerator, CL_ACCELERATOR_DESCRIPTOR_INTEL, 0, // very short - reinterpret_cast(&descReturn), + &descReturn, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); @@ -288,7 +288,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoDescriptorLongExpectPass) { accelerator, CL_ACCELERATOR_DESCRIPTOR_INTEL, sizeof(cl_motion_estimation_desc_intel) + 1, // long - reinterpret_cast(&descReturn), + &descReturn, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); @@ -314,7 +314,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoTypeExpectPass) { accelerator, CL_ACCELERATOR_TYPE_INTEL, sizeof(cl_uint), - reinterpret_cast(&type_returned), + &type_returned, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); @@ -328,7 +328,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoTypeExactExpectPass) { accelerator, CL_ACCELERATOR_TYPE_INTEL, sizeof(cl_uint), // exact - reinterpret_cast(&type_returned), + &type_returned, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); @@ -342,7 +342,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoTypeShortExpectFail) { accelerator, CL_ACCELERATOR_TYPE_INTEL, sizeof(cl_uint) - 1, // short - reinterpret_cast(&type_returned), + &type_returned, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); @@ -354,7 +354,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoTypeVeryShortExpectFail) { accelerator, CL_ACCELERATOR_TYPE_INTEL, 0, // very short - reinterpret_cast(&type_returned), + &type_returned, ¶m_value_size_ret); EXPECT_EQ(CL_INVALID_VALUE, result); @@ -366,7 +366,7 @@ TEST_F(IntelMotionEstimationGetInfoTest, getInfoTypeLongExpectPass) { accelerator, CL_ACCELERATOR_TYPE_INTEL, sizeof(cl_uint) + 1, // long - reinterpret_cast(&type_returned), + &type_returned, ¶m_value_size_ret); EXPECT_EQ(CL_SUCCESS, result); diff --git a/unit_tests/aub_mem_dump/lrca_helper_tests.cpp b/unit_tests/aub_mem_dump/lrca_helper_tests.cpp index 2fc6668420..719c94f14b 100644 --- a/unit_tests/aub_mem_dump/lrca_helper_tests.cpp +++ b/unit_tests/aub_mem_dump/lrca_helper_tests.cpp @@ -17,7 +17,7 @@ TEST(LrcaHelper, WhenLrcaHelperIsInitializedThenLrcaIncludesDebugModeLri) { auto lrcaBufferSize = helper.sizeLRCA / sizeof(uint32_t); auto lrca = std::unique_ptr(new uint32_t[lrcaBufferSize]); - helper.initialize(reinterpret_cast(lrca.get())); + helper.initialize(lrca.get()); bool debugModeLriFound = false; for (uint32_t i = 0; i < lrcaBufferSize; i += 2) { diff --git a/unit_tests/event/async_events_handler_tests.cpp b/unit_tests/event/async_events_handler_tests.cpp index 7cd0dea273..7f61a359f8 100644 --- a/unit_tests/event/async_events_handler_tests.cpp +++ b/unit_tests/event/async_events_handler_tests.cpp @@ -207,7 +207,7 @@ TEST_F(AsyncEventsHandlerTests, givenEventsNotHandledByHandlderWhenAsyncExecutio EXPECT_EQ(3, event1->getRefInternalCount()); EXPECT_EQ(3, event2->getRefInternalCount()); handler->allowAsyncProcess.store(false); - MockHandler::asyncProcess(reinterpret_cast(handler.get())); // enter and exit because of allowAsyncProcess == false + MockHandler::asyncProcess(handler.get()); // enter and exit because of allowAsyncProcess == false EXPECT_EQ(2, event1->getRefInternalCount()); EXPECT_EQ(2, event2->getRefInternalCount()); EXPECT_TRUE(handler->peekIsListEmpty()); @@ -349,7 +349,7 @@ TEST_F(AsyncEventsHandlerTests, givenSleepCandidateWhenProcessedThenCallWaitWith EXPECT_CALL(*event1, wait(true, true)).Times(1).WillOnce(Invoke(unsetAsyncFlag)); - MockHandler::asyncProcess(reinterpret_cast(handler.get())); + MockHandler::asyncProcess(handler.get()); event1->setStatus(CL_COMPLETE); } @@ -360,7 +360,7 @@ TEST_F(AsyncEventsHandlerTests, asyncProcessCallsProcessListBeforeReturning) { handler->registerEvent(event); handler->allowAsyncProcess.store(false); - MockHandler::asyncProcess(reinterpret_cast(handler.get())); + MockHandler::asyncProcess(handler.get()); EXPECT_TRUE(handler->peekIsListEmpty()); EXPECT_EQ(1, event->getRefInternalCount()); diff --git a/unit_tests/sampler/sampler_tests.cpp b/unit_tests/sampler/sampler_tests.cpp index 4b314a4ad4..be8d80570b 100644 --- a/unit_tests/sampler/sampler_tests.cpp +++ b/unit_tests/sampler/sampler_tests.cpp @@ -137,7 +137,7 @@ TEST(castToSamplerTest, GivenGenericPointerWhichHoldsSamplerObjectWhenCastToSamp TEST(castToSamplerTest, GivenGenericPointerWhichDoestNotHoldSamplerObjectWhenCastToSamplerIsCalledThenCastWithAFailure) { auto context = std::make_unique(); auto notSamplerObj = std::unique_ptr(ImageHelper::create(context.get())); - auto ptr = reinterpret_cast(notSamplerObj.get()); + void *ptr = notSamplerObj.get(); auto notSampler = castToObject(ptr); EXPECT_EQ(nullptr, notSampler);