Skip to content

Commit e8a7113

Browse files
Remove unnecessary casts.
Change-Id: I2d293d065c7efa006efe7d60a625cba0c6116c86
1 parent 4b4b886 commit e8a7113

16 files changed

+51
-51
lines changed

runtime/command_queue/command_queue_hw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class CommandQueueHw : public CommandQueue {
333333

334334
protected:
335335
MOCKABLE_VIRTUAL void enqueueHandlerHook(const unsigned int commandType, const MultiDispatchInfo &dispatchInfo){};
336-
size_t calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image);
336+
size_t calculateHostPtrSizeForImage(const size_t *region, size_t rowPitch, size_t slicePitch, Image *image);
337337

338338
private:
339339
bool isTaskLevelUpdateRequired(const uint32_t &taskLevel, const cl_event *eventWaitList, const cl_uint &numEventsInWaitList, unsigned int commandType);

runtime/command_queue/enqueue_common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
290290
CompletionStamp completionStamp;
291291
if (!blockQueue) {
292292
if (parentKernel) {
293-
size_t minSizeSSHForEM = KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<IndirectHeap::SURFACE_STATE>(const_cast<const Kernel &>(*parentKernel));
293+
size_t minSizeSSHForEM = KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<IndirectHeap::SURFACE_STATE>(*parentKernel);
294294

295295
uint32_t taskCount = getCommandStreamReceiver().peekTaskCount() + 1;
296296
devQueueHw->setupExecutionModelDispatch(getIndirectHeap(IndirectHeap::SURFACE_STATE, minSizeSSHForEM),
@@ -406,7 +406,7 @@ void CommandQueueHw<GfxFamily>::enqueueHandler(Surface **surfacesForResidency,
406406

407407
if (blockQueue) {
408408
if (parentKernel) {
409-
size_t minSizeSSHForEM = KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<IndirectHeap::SURFACE_STATE>(const_cast<const Kernel &>(*parentKernel));
409+
size_t minSizeSSHForEM = KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<IndirectHeap::SURFACE_STATE>(*parentKernel);
410410
blockedCommandsData->surfaceStateHeapSizeEM = minSizeSSHForEM;
411411
}
412412

@@ -730,7 +730,7 @@ void CommandQueueHw<GfxFamily>::computeOffsetsValueForRectCommands(size_t *buffe
730730
}
731731

732732
template <typename GfxFamily>
733-
size_t CommandQueueHw<GfxFamily>::calculateHostPtrSizeForImage(size_t *region, size_t rowPitch, size_t slicePitch, Image *image) {
733+
size_t CommandQueueHw<GfxFamily>::calculateHostPtrSizeForImage(const size_t *region, size_t rowPitch, size_t slicePitch, Image *image) {
734734
auto bytesPerPixel = image->getSurfaceFormatInfo().ImageElementSizeInBytes;
735735
auto dstRowPitch = rowPitch ? rowPitch : region[0] * bytesPerPixel;
736736
auto dstSlicePitch = slicePitch ? slicePitch : ((image->getImageDesc().image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY ? 1 : region[1]) * dstRowPitch);

runtime/command_queue/enqueue_read_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueReadImage(
7272

7373
BuiltInOwnershipWrapper builtInLock(builder, this->context);
7474

75-
size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast<size_t *>(region), inputRowPitch, inputSlicePitch, srcImage);
75+
size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, srcImage);
7676
void *dstPtr = ptr;
7777

7878
MemObjSurface srcImgSurf(srcImage);

runtime/command_queue/enqueue_write_image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cl_int CommandQueueHw<GfxFamily>::enqueueWriteImage(
6666

6767
BuiltInOwnershipWrapper lock(builder, this->context);
6868

69-
size_t hostPtrSize = calculateHostPtrSizeForImage(const_cast<size_t *>(region), inputRowPitch, inputSlicePitch, dstImage);
69+
size_t hostPtrSize = calculateHostPtrSizeForImage(region, inputRowPitch, inputSlicePitch, dstImage);
7070
void *srcPtr = const_cast<void *>(ptr);
7171

7272
MemObjSurface dstImgSurf(dstImage);

runtime/command_queue/gpgpu_walker.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ IndirectHeap &getIndirectHeap(CommandQueue &commandQueue, const MultiDispatchInf
247247

248248
if (Kernel *parentKernel = multiDispatchInfo.peekParentKernel()) {
249249
if (heapType == IndirectHeap::SURFACE_STATE) {
250-
expectedSize += KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<heapType>(const_cast<const Kernel &>(*parentKernel));
250+
expectedSize += KernelCommandsHelper<GfxFamily>::template getSizeRequiredForExecutionModel<heapType>(*parentKernel);
251251
} else //if (heapType == IndirectHeap::DYNAMIC_STATE || heapType == IndirectHeap::INDIRECT_OBJECT)
252252
{
253253
DeviceQueueHw<GfxFamily> *pDevQueue = castToObject<DeviceQueueHw<GfxFamily>>(commandQueue.getContext().getDefaultDeviceQueue());

runtime/helpers/base_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ inline DerivedType *castToObjectOrAbort(typename DerivedType::BaseType *object)
5959

6060
template <typename DerivedType>
6161
inline const DerivedType *castToObject(const typename DerivedType::BaseType *object) {
62-
return const_cast<const DerivedType *>(castToObject<DerivedType>(const_cast<typename DerivedType::BaseType *>(object)));
62+
return castToObject<DerivedType>(const_cast<typename DerivedType::BaseType *>(object));
6363
}
6464

6565
template <typename DerivedType>

runtime/kernel/kernel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,7 +1939,7 @@ void Kernel::ReflectionSurfaceHelper::setParentImageParams(void *reflectionSurfa
19391939
uint32_t numArgs = (uint32_t)parentArguments.size();
19401940
for (uint32_t i = 0; i < numArgs; i++) {
19411941
if (parentArguments[i].type == Kernel::kernelArgType::IMAGE_OBJ) {
1942-
const Image *image = const_cast<const Image *>(castToObject<Image>((cl_mem)parentArguments[i].object));
1942+
const Image *image = castToObject<Image>((cl_mem)parentArguments[i].object);
19431943
if (image) {
19441944
pImageParameters->m_ArraySize = (uint32_t)image->getImageDesc().image_array_size;
19451945
pImageParameters->m_Depth = (uint32_t)image->getImageDesc().image_depth;
@@ -1964,7 +1964,7 @@ void Kernel::ReflectionSurfaceHelper::setParentSamplerParams(void *reflectionSur
19641964
uint32_t numArgs = (uint32_t)parentArguments.size();
19651965
for (uint32_t i = 0; i < numArgs; i++) {
19661966
if (parentArguments[i].type == Kernel::kernelArgType::SAMPLER_OBJ) {
1967-
const Sampler *sampler = const_cast<const Sampler *>(castToObject<Sampler>((cl_sampler)parentArguments[i].object));
1967+
const Sampler *sampler = castToObject<Sampler>((cl_sampler)parentArguments[i].object);
19681968
if (sampler) {
19691969
pParentSamplerParams->CoordinateSnapRequired = (uint32_t)sampler->getSnapWaValue();
19701970
pParentSamplerParams->m_AddressingMode = (uint32_t)sampler->addressingMode;

runtime/mem_obj/buffer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ Buffer *Buffer::create(Context *context,
233233
properties.flags,
234234
size,
235235
memory->getUnderlyingBuffer(),
236-
const_cast<void *>(hostPtr),
236+
hostPtr,
237237
memory,
238238
zeroCopyAllowed,
239239
isHostPtrSVM,

runtime/mem_obj/image.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ cl_int Image::validateImageTraits(Context *context, cl_mem_flags flags, const cl
573573
return CL_SUCCESS;
574574
}
575575

576-
size_t Image::calculateHostPtrSize(size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType) {
576+
size_t Image::calculateHostPtrSize(const size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType) {
577577
DEBUG_BREAK_IF(!((rowPitch != 0) && (slicePitch != 0)));
578578
size_t sizeToReturn = 0u;
579579

runtime/mem_obj/image.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Image : public MemObj {
8888

8989
static cl_int validateImageTraits(Context *context, cl_mem_flags flags, const cl_image_format *imageFormat, const cl_image_desc *imageDesc, const void *hostPtr);
9090

91-
static size_t calculateHostPtrSize(size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType);
91+
static size_t calculateHostPtrSize(const size_t *region, size_t rowPitch, size_t slicePitch, size_t pixelSize, uint32_t imageType);
9292

9393
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);
9494

0 commit comments

Comments
 (0)