diff --git a/runtime/helpers/cache_policy.cpp b/runtime/helpers/cache_policy.cpp index 9f4b083447..22fed7dd0d 100644 --- a/runtime/helpers/cache_policy.cpp +++ b/runtime/helpers/cache_policy.cpp @@ -13,11 +13,8 @@ namespace OCLRT { bool isL3Capable(void *ptr, size_t size) { - if (alignUp(ptr, MemoryConstants::cacheLineSize) == ptr && - alignUp(size, MemoryConstants::cacheLineSize) == size) { - return true; - } - return false; + return isAligned(ptr) && + isAligned(size); } bool isL3Capable(const OCLRT::GraphicsAllocation &graphicsAllocation) { diff --git a/runtime/kernel/kernel.cpp b/runtime/kernel/kernel.cpp index 7d33080cee..23f5e0a4e7 100644 --- a/runtime/kernel/kernel.cpp +++ b/runtime/kernel/kernel.cpp @@ -2196,10 +2196,7 @@ void Kernel::getAllocationsForCacheFlush(CacheFlushAllocationsVec &out) const { } bool Kernel::allocationForCacheFlush(GraphicsAllocation *argAllocation) const { - if (argAllocation->flushL3Required || argAllocation->isMemObjectsAllocationWithWritableFlags()) { - return true; - } - return false; + return argAllocation->flushL3Required || argAllocation->isMemObjectsAllocationWithWritableFlags(); } void Kernel::addAllocationToCacheFlushVector(uint32_t argIndex, GraphicsAllocation *argAllocation) { diff --git a/runtime/mem_obj/buffer.cpp b/runtime/mem_obj/buffer.cpp index f1da5d1682..ad82d4ead1 100644 --- a/runtime/mem_obj/buffer.cpp +++ b/runtime/mem_obj/buffer.cpp @@ -353,10 +353,7 @@ GraphicsAllocation::AllocationType Buffer::getGraphicsAllocationType(const Memor bool Buffer::isReadOnlyMemoryPermittedByFlags(cl_mem_flags flags) { // Host won't access or will only read and kernel will only read - if ((flags & (CL_MEM_HOST_NO_ACCESS | CL_MEM_HOST_READ_ONLY)) && (flags & CL_MEM_READ_ONLY)) { - return true; - } - return false; + return (flags & (CL_MEM_HOST_NO_ACCESS | CL_MEM_HOST_READ_ONLY)) && (flags & CL_MEM_READ_ONLY); } Buffer *Buffer::createSubBuffer(cl_mem_flags flags, diff --git a/runtime/mem_obj/image.cpp b/runtime/mem_obj/image.cpp index f3b9d3286e..a710259c66 100644 --- a/runtime/mem_obj/image.cpp +++ b/runtime/mem_obj/image.cpp @@ -989,18 +989,15 @@ const SurfaceFormatInfo *Image::getSurfaceFormatFromTable(cl_mem_flags flags, co } bool Image::isImage2d(cl_mem_object_type imageType) { - return (imageType == CL_MEM_OBJECT_IMAGE2D); + return imageType == CL_MEM_OBJECT_IMAGE2D; } bool Image::isImage2dOr2dArray(cl_mem_object_type imageType) { - return (imageType == CL_MEM_OBJECT_IMAGE2D) || (imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY); + return imageType == CL_MEM_OBJECT_IMAGE2D || imageType == CL_MEM_OBJECT_IMAGE2D_ARRAY; } bool Image::isDepthFormat(const cl_image_format &imageFormat) { - if (imageFormat.image_channel_order == CL_DEPTH || imageFormat.image_channel_order == CL_DEPTH_STENCIL) { - return true; - } - return false; + return imageFormat.image_channel_order == CL_DEPTH || imageFormat.image_channel_order == CL_DEPTH_STENCIL; } Image *Image::validateAndCreateImage(Context *context, diff --git a/runtime/memory_manager/memory_pool.h b/runtime/memory_manager/memory_pool.h index ba2e8fbeca..96f03ad449 100644 --- a/runtime/memory_manager/memory_pool.h +++ b/runtime/memory_manager/memory_pool.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 Intel Corporation + * Copyright (C) 2018-2019 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -21,9 +21,9 @@ constexpr Type System64KBPagesWith32BitGpuAddressing{4}; constexpr Type SystemCpuInaccessible{5}; inline bool isSystemMemoryPool(Type pool) { - if (pool == System4KBPages || pool == MemoryPool::System64KBPages || pool == System4KBPagesWith32BitGpuAddressing || pool == System64KBPagesWith32BitGpuAddressing) { - return true; - } - return false; + return pool == System4KBPages || + pool == System64KBPages || + pool == System4KBPagesWith32BitGpuAddressing || + pool == System64KBPagesWith32BitGpuAddressing; } } // namespace MemoryPool diff --git a/runtime/os_interface/debug_settings_manager.cpp b/runtime/os_interface/debug_settings_manager.cpp index ce51534427..dc1ec9b4ab 100644 --- a/runtime/os_interface/debug_settings_manager.cpp +++ b/runtime/os_interface/debug_settings_manager.cpp @@ -245,7 +245,7 @@ void DebugSettingsManager::dumpKernelArgs(const MultiDispatchInfo *m return; } - if ((flags.DumpKernelArgs.get() == false) || (multiDispatchInfo == nullptr)) { + if (flags.DumpKernelArgs.get() == false || multiDispatchInfo == nullptr) { return; } @@ -274,55 +274,55 @@ const char *DebugSettingsManager::getAllocationTypeString(GraphicsAl auto type = graphicsAllocation->getAllocationType(); switch (type) { - case OCLRT::GraphicsAllocation::AllocationType::UNKNOWN: + case GraphicsAllocation::AllocationType::UNKNOWN: return "UNKNOWN"; - case OCLRT::GraphicsAllocation::AllocationType::BUFFER_COMPRESSED: + case GraphicsAllocation::AllocationType::BUFFER_COMPRESSED: return "BUFFER_COMPRESSED"; - case OCLRT::GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY: + case GraphicsAllocation::AllocationType::BUFFER_HOST_MEMORY: return "BUFFER_HOST_MEMORY"; - case OCLRT::GraphicsAllocation::AllocationType::BUFFER: + case GraphicsAllocation::AllocationType::BUFFER: return "BUFFER"; - case OCLRT::GraphicsAllocation::AllocationType::IMAGE: + case GraphicsAllocation::AllocationType::IMAGE: return "IMAGE"; - case OCLRT::GraphicsAllocation::AllocationType::TAG_BUFFER: + case GraphicsAllocation::AllocationType::TAG_BUFFER: return "TAG_BUFFER"; - case OCLRT::GraphicsAllocation::AllocationType::LINEAR_STREAM: + case GraphicsAllocation::AllocationType::LINEAR_STREAM: return "LINEAR_STREAM"; - case OCLRT::GraphicsAllocation::AllocationType::FILL_PATTERN: + case GraphicsAllocation::AllocationType::FILL_PATTERN: return "FILL_PATTERN"; - case OCLRT::GraphicsAllocation::AllocationType::PIPE: + case GraphicsAllocation::AllocationType::PIPE: return "PIPE"; - case OCLRT::GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: + case GraphicsAllocation::AllocationType::TIMESTAMP_PACKET_TAG_BUFFER: return "TIMESTAMP_PACKET_TAG_BUFFER"; - case OCLRT::GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER: + case GraphicsAllocation::AllocationType::PROFILING_TAG_BUFFER: return "PROFILING_TAG_BUFFER"; - case OCLRT::GraphicsAllocation::AllocationType::COMMAND_BUFFER: + case GraphicsAllocation::AllocationType::COMMAND_BUFFER: return "COMMAND_BUFFER"; - case OCLRT::GraphicsAllocation::AllocationType::PRINTF_SURFACE: + case GraphicsAllocation::AllocationType::PRINTF_SURFACE: return "PRINTF_SURFACE"; - case OCLRT::GraphicsAllocation::AllocationType::GLOBAL_SURFACE: + case GraphicsAllocation::AllocationType::GLOBAL_SURFACE: return "GLOBAL_SURFACE"; - case OCLRT::GraphicsAllocation::AllocationType::PRIVATE_SURFACE: + case GraphicsAllocation::AllocationType::PRIVATE_SURFACE: return "PRIVATE_SURFACE"; - case OCLRT::GraphicsAllocation::AllocationType::CONSTANT_SURFACE: + case GraphicsAllocation::AllocationType::CONSTANT_SURFACE: return "CONSTANT_SURFACE"; - case OCLRT::GraphicsAllocation::AllocationType::SCRATCH_SURFACE: + case GraphicsAllocation::AllocationType::SCRATCH_SURFACE: return "SCRATCH_SURFACE"; - case OCLRT::GraphicsAllocation::AllocationType::INSTRUCTION_HEAP: + case GraphicsAllocation::AllocationType::INSTRUCTION_HEAP: return "INSTRUCTION_HEAP"; - case OCLRT::GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP: + case GraphicsAllocation::AllocationType::INDIRECT_OBJECT_HEAP: return "INDIRECT_OBJECT_HEAP"; - case OCLRT::GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP: + case GraphicsAllocation::AllocationType::SURFACE_STATE_HEAP: return "SURFACE_STATE_HEAP"; - case OCLRT::GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP: + case GraphicsAllocation::AllocationType::DYNAMIC_STATE_HEAP: return "DYNAMIC_STATE_HEAP"; - case OCLRT::GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY: + case GraphicsAllocation::AllocationType::SHARED_RESOURCE_COPY: return "SHARED_RESOURCE_COPY"; - case OCLRT::GraphicsAllocation::AllocationType::SVM: + case GraphicsAllocation::AllocationType::SVM: return "SVM"; case GraphicsAllocation::AllocationType::EXTERNAL_HOST_PTR: return "EXTERNAL_HOST_PTR"; - case OCLRT::GraphicsAllocation::AllocationType::UNDECIDED: + case GraphicsAllocation::AllocationType::UNDECIDED: return "UNDECIDED"; default: return "ILLEGAL_VALUE"; diff --git a/runtime/os_interface/windows/wddm_residency_controller.cpp b/runtime/os_interface/windows/wddm_residency_controller.cpp index edc7a9f344..2ae619d695 100644 --- a/runtime/os_interface/windows/wddm_residency_controller.cpp +++ b/runtime/os_interface/windows/wddm_residency_controller.cpp @@ -134,10 +134,7 @@ void WddmResidencyController::checkTrimCandidateCount() { } bool WddmResidencyController::checkTrimCandidateListCompaction() { - if (2 * trimCandidatesCount <= trimCandidateList.size()) { - return true; - } - return false; + return 2 * trimCandidatesCount <= trimCandidateList.size(); } void WddmResidencyController::compactTrimCandidateList() { diff --git a/unit_tests/perf_tests/perf_test_utils.cpp b/unit_tests/perf_tests/perf_test_utils.cpp index 8defb68eca..a787c31f1e 100644 --- a/unit_tests/perf_tests/perf_test_utils.cpp +++ b/unit_tests/perf_tests/perf_test_utils.cpp @@ -101,10 +101,7 @@ bool isInRange(double data, double reference, double multiplier) { double lower = reference / multiplier; double higher = reference * multiplier; - if ((data >= lower) && (data <= higher)) { - return true; - } - return false; + return data >= lower && data <= higher; } bool isLowerThanReference(double data, double reference, double multiplier) { diff --git a/unit_tests/sharings/va/va_sharing_linux_tests.cpp b/unit_tests/sharings/va/va_sharing_linux_tests.cpp index 1c70726438..07f4c5e538 100644 --- a/unit_tests/sharings/va/va_sharing_linux_tests.cpp +++ b/unit_tests/sharings/va/va_sharing_linux_tests.cpp @@ -19,30 +19,22 @@ class VASharingFunctionsTested : public VASharingFunctions { public: VASharingFunctionsTested() : VASharingFunctions(nullptr) {} - bool wereFunctionsAssigned() { - if ( - vaDisplayIsValidPFN != nullptr && - vaDeriveImagePFN != nullptr && - vaDestroyImagePFN != nullptr && - vaSyncSurfacePFN != nullptr && - vaGetLibFuncPFN != nullptr && - vaExtGetSurfaceHandlePFN != nullptr) { - return true; - } - return false; + bool wereFunctionsAssigned() const { + return vaDisplayIsValidPFN != nullptr && + vaDeriveImagePFN != nullptr && + vaDestroyImagePFN != nullptr && + vaSyncSurfacePFN != nullptr && + vaGetLibFuncPFN != nullptr && + vaExtGetSurfaceHandlePFN != nullptr; } - bool wereFunctionsAssignedNull() { - if ( - vaDisplayIsValidPFN == nullptr && - vaDeriveImagePFN == nullptr && - vaDestroyImagePFN == nullptr && - vaSyncSurfacePFN == nullptr && - vaGetLibFuncPFN == nullptr && - vaExtGetSurfaceHandlePFN == nullptr) { - return true; - } - return false; + bool wereFunctionsAssignedNull() const { + return vaDisplayIsValidPFN == nullptr && + vaDeriveImagePFN == nullptr && + vaDestroyImagePFN == nullptr && + vaSyncSurfacePFN == nullptr && + vaGetLibFuncPFN == nullptr && + vaExtGetSurfaceHandlePFN == nullptr; } };