From 05f2a1f5b29037a691f346b2d7ad22107b67992a Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Tue, 17 Sep 2024 17:39:08 +0100 Subject: [PATCH] Raise MSVC warning level from /W3 to /W4 This patch increases the warning level when using the MSVC compiler from `/W3` to `/W4` and fixes the issues found. Four warnings introduced by `/W4` are disabled, all related to variable name shadowing, as they overly prescriptive to valid code. --- cmake/helpers.cmake | 15 ++++-- examples/collector/collector.cpp | 7 +++ include/ur_api.h | 2 +- scripts/core/common.yml | 2 +- source/adapters/cuda/CMakeLists.txt | 7 +-- source/adapters/cuda/command_buffer.cpp | 26 +++++----- source/adapters/cuda/device.cpp | 4 +- source/adapters/cuda/enqueue.cpp | 50 +++++++++++-------- source/adapters/cuda/image.cpp | 5 +- source/adapters/cuda/kernel.cpp | 4 +- source/adapters/cuda/kernel.hpp | 8 +-- source/adapters/cuda/program.cpp | 4 +- source/adapters/cuda/usm.cpp | 2 +- source/adapters/level_zero/CMakeLists.txt | 18 ++++--- source/adapters/level_zero/adapter.cpp | 2 - source/adapters/level_zero/context.cpp | 2 +- source/adapters/level_zero/device.cpp | 16 +++--- source/adapters/level_zero/event.cpp | 2 - source/adapters/level_zero/platform.cpp | 2 - source/adapters/level_zero/program.hpp | 3 +- source/adapters/level_zero/queue.cpp | 2 +- source/adapters/level_zero/usm.cpp | 1 - source/adapters/level_zero/v2/event.cpp | 2 - source/adapters/level_zero/v2/usm.cpp | 1 - source/adapters/level_zero/virtual_mem.cpp | 3 -- source/adapters/opencl/adapter.cpp | 2 - source/adapters/opencl/event.cpp | 6 +-- source/adapters/opencl/memory.cpp | 9 ++-- source/adapters/opencl/program.cpp | 15 +++--- source/adapters/opencl/queue.cpp | 4 +- source/adapters/opencl/usm.cpp | 8 +-- source/adapters/opencl/usm_p2p.cpp | 11 ++-- source/common/logger/ur_logger.hpp | 5 +- source/common/ur_util.cpp | 2 +- source/common/ur_util.hpp | 5 +- .../layers/tracing/ur_tracing_layer.cpp | 8 +++ source/loader/ur_adapter_registry.hpp | 13 ++--- source/loader/ur_lib.cpp | 13 ++--- source/loader/windows/adapter_search.cpp | 3 +- test/CMakeLists.txt | 3 +- test/conformance/device/urDevicePartition.cpp | 2 +- .../urEnqueueDeviceGlobalVariableRead.cpp | 2 +- .../urEnqueueEventsWaitMultiDevice.cpp | 11 ++-- .../enqueue/urEnqueueKernelLaunch.cpp | 16 +++--- .../urEnqueueKernelLaunchAndMemcpyInOrder.cpp | 4 +- .../exp_command_buffer/commands.cpp | 6 +-- .../conformance/exp_command_buffer/fixtures.h | 2 + .../update/buffer_fill_kernel_update.cpp | 4 +- .../update/buffer_saxpy_kernel_update.cpp | 2 +- .../update/kernel_handle_update.cpp | 18 ++++--- .../update/usm_fill_kernel_update.cpp | 10 ++-- .../launch_properties.cpp | 2 +- test/conformance/integration/QueueBuffer.cpp | 23 ++++----- test/conformance/integration/fixtures.h | 3 +- .../urKernelGetSuggestedLocalWorkSize.cpp | 2 +- .../kernel/urKernelSetArgSampler.cpp | 2 +- .../urMemBufferMigrateAcrossDevices.cpp | 2 +- .../urMultiDeviceProgramCreateWithBinary.cpp | 22 ++++---- test/conformance/testing/include/uur/utils.h | 2 - test/conformance/usm/urUSMDeviceAlloc.cpp | 7 +-- test/conformance/usm/urUSMHostAlloc.cpp | 4 +- test/conformance/usm/urUSMSharedAlloc.cpp | 8 +-- test/layers/tracing/test_collector.cpp | 7 +++ tools/urinfo/utils.hpp | 4 +- tools/urtrace/collector.cpp | 8 ++- 65 files changed, 262 insertions(+), 208 deletions(-) diff --git a/cmake/helpers.cmake b/cmake/helpers.cmake index 8b40da7d4c..de4e3e1e69 100644 --- a/cmake/helpers.cmake +++ b/cmake/helpers.cmake @@ -98,18 +98,25 @@ function(add_ur_target_compile_options name) elseif(MSVC) target_compile_options(${name} PRIVATE $<$:/MP> # clang-cl.exe does not support /MP - /W3 + /W4 + /wd4456 # Disable: declaration of 'identifier' hides previous local declaration + /wd4457 # Disable: declaration of 'identifier' hides function parameter + /wd4458 # Disable: declaration of 'identifier' hides class member + /wd4459 # Disable: declaration of 'identifier' hides global declaration /MD$<$:d> /GS /DWIN32_LEAN_AND_MEAN /DNOMINMAX ) - if(UR_DEVELOPER_MODE) + target_compile_definitions(${name} PRIVATE # _CRT_SECURE_NO_WARNINGS used mainly because of getenv - # C4267: The compiler detected a conversion from size_t to a smaller type. + _CRT_SECURE_NO_WARNINGS + ) + + if(UR_DEVELOPER_MODE) target_compile_options(${name} PRIVATE - /WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267 + /WX /GS ) endif() endif() diff --git a/examples/collector/collector.cpp b/examples/collector/collector.cpp index cc9580bc4f..8ea7ee3cef 100644 --- a/examples/collector/collector.cpp +++ b/examples/collector/collector.cpp @@ -25,7 +25,14 @@ #include #include "ur_api.h" + +#ifdef _MSC_VER +#pragma warning(disable : 4245) +#endif #include "xpti/xpti_trace_framework.h" +#ifdef _MSC_VER +#pragma warning(default : 4245) +#endif constexpr uint16_t TRACE_FN_BEGIN = static_cast(xpti::trace_point_type_t::function_with_args_begin); diff --git a/include/ur_api.h b/include/ur_api.h index ca58a7ac66..442a028016 100644 --- a/include/ur_api.h +++ b/include/ur_api.h @@ -424,7 +424,7 @@ typedef struct ur_physical_mem_handle_t_ *ur_physical_mem_handle_t; /////////////////////////////////////////////////////////////////////////////// #ifndef UR_BIT /// @brief Generic macro for enumerator bit masks -#define UR_BIT(_i) (1 << _i) +#define UR_BIT(_i) (1U << _i) #endif // UR_BIT /////////////////////////////////////////////////////////////////////////////// diff --git a/scripts/core/common.yml b/scripts/core/common.yml index 73501ac39d..d1f5b769fa 100644 --- a/scripts/core/common.yml +++ b/scripts/core/common.yml @@ -134,7 +134,7 @@ name: "$x_physical_mem_handle_t" type: macro desc: "Generic macro for enumerator bit masks" name: "$X_BIT( _i )" -value: "( 1 << _i )" +value: "( 1U << _i )" --- #-------------------------------------------------------------------------- type: enum desc: "Defines Return/Error codes" diff --git a/source/adapters/cuda/CMakeLists.txt b/source/adapters/cuda/CMakeLists.txt index b6b153a5d8..a73b7ee886 100644 --- a/source/adapters/cuda/CMakeLists.txt +++ b/source/adapters/cuda/CMakeLists.txt @@ -97,15 +97,16 @@ if (UR_ENABLE_TRACING) get_target_property(XPTI_SRC_DIR xpti SOURCE_DIR) set(XPTI_PROXY_SRC "${XPTI_SRC_DIR}/xpti_proxy.cpp") endif() - target_compile_definitions(${TARGET_NAME} PRIVATE + add_library(cuda-xpti-proxy STATIC ${XPTI_PROXY_SRC}) + target_compile_definitions(cuda-xpti-proxy PRIVATE XPTI_ENABLE_INSTRUMENTATION XPTI_STATIC_LIBRARY ) - target_include_directories(${TARGET_NAME} PRIVATE + target_include_directories(cuda-xpti-proxy PRIVATE ${XPTI_INCLUDES} ${CUDA_CUPTI_INCLUDE_DIR} ) - target_sources(${TARGET_NAME} PRIVATE ${XPTI_PROXY_SRC}) + target_link_libraries(${TARGET_NAME} PRIVATE cuda-xpti-proxy) endif() if (CUDA_cupti_LIBRARY) diff --git a/source/adapters/cuda/command_buffer.cpp b/source/adapters/cuda/command_buffer.cpp index e47bcf9c2a..8143a814e2 100644 --- a/source/adapters/cuda/command_buffer.cpp +++ b/source/adapters/cuda/command_buffer.cpp @@ -242,7 +242,7 @@ static ur_result_t enqueueCommandBufferFillHelper( if ((PatternSize == 1) || (PatternSize == 2) || (PatternSize == 4)) { CUDA_MEMSET_NODE_PARAMS NodeParams = {}; NodeParams.dst = DstPtr; - NodeParams.elementSize = PatternSize; + NodeParams.elementSize = static_cast(PatternSize); NodeParams.height = N; NodeParams.pitch = PatternSize; NodeParams.width = 1; @@ -508,12 +508,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( auto &ArgIndices = hKernel->getArgIndices(); CUDA_KERNEL_NODE_PARAMS NodeParams = {}; NodeParams.func = CuFunc; - NodeParams.gridDimX = BlocksPerGrid[0]; - NodeParams.gridDimY = BlocksPerGrid[1]; - NodeParams.gridDimZ = BlocksPerGrid[2]; - NodeParams.blockDimX = ThreadsPerBlock[0]; - NodeParams.blockDimY = ThreadsPerBlock[1]; - NodeParams.blockDimZ = ThreadsPerBlock[2]; + NodeParams.gridDimX = static_cast(BlocksPerGrid[0]); + NodeParams.gridDimY = static_cast(BlocksPerGrid[1]); + NodeParams.gridDimZ = static_cast(BlocksPerGrid[2]); + NodeParams.blockDimX = static_cast(ThreadsPerBlock[0]); + NodeParams.blockDimY = static_cast(ThreadsPerBlock[1]); + NodeParams.blockDimZ = static_cast(ThreadsPerBlock[2]); NodeParams.sharedMemBytes = LocalSize; NodeParams.kernelParams = const_cast(ArgIndices.data()); @@ -1391,12 +1391,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferUpdateKernelLaunchExp( CUDA_KERNEL_NODE_PARAMS &Params = KernelCommandHandle->Params; Params.func = CuFunc; - Params.gridDimX = BlocksPerGrid[0]; - Params.gridDimY = BlocksPerGrid[1]; - Params.gridDimZ = BlocksPerGrid[2]; - Params.blockDimX = ThreadsPerBlock[0]; - Params.blockDimY = ThreadsPerBlock[1]; - Params.blockDimZ = ThreadsPerBlock[2]; + Params.gridDimX = static_cast(BlocksPerGrid[0]); + Params.gridDimY = static_cast(BlocksPerGrid[1]); + Params.gridDimZ = static_cast(BlocksPerGrid[2]); + Params.blockDimX = static_cast(ThreadsPerBlock[0]); + Params.blockDimY = static_cast(ThreadsPerBlock[1]); + Params.blockDimZ = static_cast(ThreadsPerBlock[2]); Params.sharedMemBytes = KernelCommandHandle->Kernel->getLocalSize(); Params.kernelParams = const_cast(KernelCommandHandle->Kernel->getArgIndices().data()); diff --git a/source/adapters/cuda/device.cpp b/source/adapters/cuda/device.cpp index ea7c4da8ec..0fe14c2f8e 100644 --- a/source/adapters/cuda/device.cpp +++ b/source/adapters/cuda/device.cpp @@ -1150,7 +1150,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform, try { if (pNumDevices) { - *pNumDevices = NumDevices; + *pNumDevices = static_cast(NumDevices); } if (ReturnDevices && phDevices) { @@ -1233,7 +1233,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceCreateWithNativeHandle( ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice, uint64_t *pDeviceTimestamp, uint64_t *pHostTimestamp) { - CUevent Event; + CUevent Event{}; ScopedContext Active(hDevice); if (pDeviceTimestamp) { diff --git a/source/adapters/cuda/enqueue.cpp b/source/adapters/cuda/enqueue.cpp index 0e00f680f6..15f812403f 100644 --- a/source/adapters/cuda/enqueue.cpp +++ b/source/adapters/cuda/enqueue.cpp @@ -160,7 +160,7 @@ void guessLocalWorkSize(ur_device_handle_t Device, size_t *ThreadsPerBlock, int MinGrid, MaxBlockSize; UR_CHECK_ERROR(cuOccupancyMaxPotentialBlockSize( &MinGrid, &MaxBlockSize, Kernel->get(), NULL, Kernel->getLocalSize(), - MaxBlockDim[0])); + static_cast(MaxBlockDim[0]))); roundToHighestFactorOfGlobalSizeIn3d(ThreadsPerBlock, GlobalSizeNormalized, MaxBlockDim, MaxBlockSize); @@ -208,7 +208,7 @@ setKernelParams([[maybe_unused]] const ur_context_handle_t Context, MaxWorkGroupSize = Device->getMaxWorkGroupSize(); if (ProvidedLocalWorkGroupSize) { - auto IsValid = [&](int Dim) { + auto IsValid = [&](size_t Dim) { if (ReqdThreadsPerBlock[Dim] != 0 && LocalWorkSize[Dim] != ReqdThreadsPerBlock[Dim]) return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; @@ -217,7 +217,8 @@ setKernelParams([[maybe_unused]] const ur_context_handle_t Context, LocalWorkSize[Dim] > MaxThreadsPerBlock[Dim]) return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; - if (LocalWorkSize[Dim] > Device->getMaxWorkItemSizes(Dim)) + if (LocalWorkSize[Dim] > + Device->getMaxWorkItemSizes(static_cast(Dim))) return UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE; // Checks that local work sizes are a divisor of the global work sizes // which includes that the local work sizes are neither larger than @@ -481,9 +482,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch( auto &ArgIndices = hKernel->getArgIndices(); UR_CHECK_ERROR(cuLaunchKernel( - CuFunc, BlocksPerGrid[0], BlocksPerGrid[1], BlocksPerGrid[2], - ThreadsPerBlock[0], ThreadsPerBlock[1], ThreadsPerBlock[2], LocalSize, - CuStream, const_cast(ArgIndices.data()), nullptr)); + CuFunc, static_cast(BlocksPerGrid[0]), + static_cast(BlocksPerGrid[1]), + static_cast(BlocksPerGrid[2]), + static_cast(ThreadsPerBlock[0]), + static_cast(ThreadsPerBlock[1]), + static_cast(ThreadsPerBlock[2]), LocalSize, CuStream, + const_cast(ArgIndices.data()), nullptr)); if (LocalSize != 0) hKernel->clearLocalSize(); @@ -649,12 +654,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunchCustomExp( auto &ArgIndices = hKernel->getArgIndices(); CUlaunchConfig launch_config; - launch_config.gridDimX = BlocksPerGrid[0]; - launch_config.gridDimY = BlocksPerGrid[1]; - launch_config.gridDimZ = BlocksPerGrid[2]; - launch_config.blockDimX = ThreadsPerBlock[0]; - launch_config.blockDimY = ThreadsPerBlock[1]; - launch_config.blockDimZ = ThreadsPerBlock[2]; + launch_config.gridDimX = static_cast(BlocksPerGrid[0]); + launch_config.gridDimY = static_cast(BlocksPerGrid[1]); + launch_config.gridDimZ = static_cast(BlocksPerGrid[2]); + launch_config.blockDimX = static_cast(ThreadsPerBlock[0]); + launch_config.blockDimY = static_cast(ThreadsPerBlock[1]); + launch_config.blockDimZ = static_cast(ThreadsPerBlock[2]); launch_config.sharedMemBytes = LocalSize; launch_config.hStream = CuStream; @@ -979,8 +984,9 @@ ur_result_t commonMemSetLargePattern(CUstream Stream, uint32_t PatternSize, auto OffsetPtr = Ptr + (step * sizeof(uint8_t)); // set all of the pattern chunks - UR_CHECK_ERROR(cuMemsetD2D8Async(OffsetPtr, Pitch, Value, sizeof(uint8_t), - Height, Stream)); + UR_CHECK_ERROR(cuMemsetD2D8Async(OffsetPtr, Pitch, + static_cast(Value), + sizeof(uint8_t), Height, Stream)); } return UR_RESULT_SUCCESS; } @@ -1031,8 +1037,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferFill( break; } default: { - UR_CHECK_ERROR(commonMemSetLargePattern(Stream, patternSize, size, - pPattern, DstDevice)); + UR_CHECK_ERROR( + commonMemSetLargePattern(Stream, static_cast(patternSize), + size, pPattern, DstDevice)); break; } } @@ -1064,7 +1071,6 @@ static size_t imageElementByteSize(CUDA_ARRAY_DESCRIPTOR ArrayDesc) { return 4; default: detail::ur::die("Invalid image format."); - return 0; } } @@ -1168,7 +1174,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead( CUDA_ARRAY_DESCRIPTOR ArrayDesc; UR_CHECK_ERROR(cuArrayGetDescriptor(&ArrayDesc, Array)); - int ElementByteSize = imageElementByteSize(ArrayDesc); + int ElementByteSize = static_cast(imageElementByteSize(ArrayDesc)); size_t ByteOffsetX = origin.x * ElementByteSize * ArrayDesc.NumChannels; size_t BytesToCopy = ElementByteSize * ArrayDesc.NumChannels * region.width; @@ -1241,7 +1247,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageWrite( CUDA_ARRAY_DESCRIPTOR ArrayDesc; UR_CHECK_ERROR(cuArrayGetDescriptor(&ArrayDesc, Array)); - int ElementByteSize = imageElementByteSize(ArrayDesc); + int ElementByteSize = static_cast(imageElementByteSize(ArrayDesc)); size_t ByteOffsetX = origin.x * ElementByteSize * ArrayDesc.NumChannels; size_t BytesToCopy = ElementByteSize * ArrayDesc.NumChannels * region.width; @@ -1320,7 +1326,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageCopy( UR_ASSERT(SrcArrayDesc.NumChannels == DstArrayDesc.NumChannels, UR_RESULT_ERROR_INVALID_MEM_OBJECT); - int ElementByteSize = imageElementByteSize(SrcArrayDesc); + int ElementByteSize = static_cast(imageElementByteSize(SrcArrayDesc)); size_t DstByteOffsetX = dstOrigin.x * ElementByteSize * SrcArrayDesc.NumChannels; @@ -1505,8 +1511,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMFill( CuStream)); break; default: - commonMemSetLargePattern(CuStream, patternSize, size, pPattern, - (CUdeviceptr)ptr); + commonMemSetLargePattern(CuStream, static_cast(patternSize), + size, pPattern, (CUdeviceptr)ptr); break; } if (phEvent) { diff --git a/source/adapters/cuda/image.cpp b/source/adapters/cuda/image.cpp index 4840553cc1..40fd18fef7 100644 --- a/source/adapters/cuda/image.cpp +++ b/source/adapters/cuda/image.cpp @@ -284,8 +284,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMPitchedAllocExp( ur_result_t Result = UR_RESULT_SUCCESS; try { ScopedContext Active(hDevice); - UR_CHECK_ERROR(cuMemAllocPitch((CUdeviceptr *)ppMem, pResultPitch, - widthInBytes, height, elementSizeBytes)); + UR_CHECK_ERROR( + cuMemAllocPitch((CUdeviceptr *)ppMem, pResultPitch, widthInBytes, + height, static_cast(elementSizeBytes))); } catch (ur_result_t error) { Result = error; } catch (...) { diff --git a/source/adapters/cuda/kernel.cpp b/source/adapters/cuda/kernel.cpp index 5fb097c304..91daf5649c 100644 --- a/source/adapters/cuda/kernel.cpp +++ b/source/adapters/cuda/kernel.cpp @@ -203,8 +203,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp( int MaxNumActiveGroupsPerCU{0}; UR_CHECK_ERROR(cuOccupancyMaxActiveBlocksPerMultiprocessor( - &MaxNumActiveGroupsPerCU, hKernel->get(), localWorkSize, - dynamicSharedMemorySize)); + &MaxNumActiveGroupsPerCU, hKernel->get(), + static_cast(localWorkSize), dynamicSharedMemorySize)); detail::ur::assertion(MaxNumActiveGroupsPerCU >= 0); // Handle the case where we can't have all SMs active with at least 1 group // per SM. In that case, the device is still able to run 1 work-group, hence diff --git a/source/adapters/cuda/kernel.hpp b/source/adapters/cuda/kernel.hpp index 7ad20a4f0e..77d8c817f4 100644 --- a/source/adapters/cuda/kernel.hpp +++ b/source/adapters/cuda/kernel.hpp @@ -97,8 +97,8 @@ struct ur_kernel_handle_t_ { } ParamSizes[Index] = Size; // calculate the insertion point on the array - size_t InsertPos = std::accumulate(std::begin(ParamSizes), - std::begin(ParamSizes) + Index, 0); + size_t InsertPos = std::accumulate( + std::begin(ParamSizes), std::begin(ParamSizes) + Index, size_t{0}); // Update the stored value for the argument std::memcpy(&Storage[InsertPos], Arg, Size); Indices[Index] = &Storage[InsertPos]; @@ -152,8 +152,8 @@ struct ur_kernel_handle_t_ { const args_index_t &getIndices() const noexcept { return Indices; } uint32_t getLocalSize() const { - return std::accumulate(std::begin(OffsetPerIndex), - std::end(OffsetPerIndex), 0); + return static_cast(std::accumulate( + std::begin(OffsetPerIndex), std::end(OffsetPerIndex), size_t{0})); } } Args; diff --git a/source/adapters/cuda/program.cpp b/source/adapters/cuda/program.cpp index 4b963a737a..8a29df8de6 100644 --- a/source/adapters/cuda/program.cpp +++ b/source/adapters/cuda/program.cpp @@ -148,8 +148,8 @@ ur_result_t ur_program_handle_t_::buildProgram(const char *BuildOptions) { } UR_CHECK_ERROR(cuModuleLoadDataEx(&Module, static_cast(Binary), - Options.size(), Options.data(), - OptionVals.data())); + static_cast(Options.size()), + Options.data(), OptionVals.data())); BuildStatus = UR_PROGRAM_BUILD_STATUS_SUCCESS; diff --git a/source/adapters/cuda/usm.cpp b/source/adapters/cuda/usm.cpp index 8a6ac41b08..8915736b3e 100644 --- a/source/adapters/cuda/usm.cpp +++ b/source/adapters/cuda/usm.cpp @@ -325,7 +325,7 @@ umf_result_t USMMemoryProvider::initialize(ur_context_handle_t Ctx, enum umf_result_t USMMemoryProvider::alloc(size_t Size, size_t Align, void **Ptr) { - auto Res = allocateImpl(Ptr, Size, Align); + auto Res = allocateImpl(Ptr, Size, static_cast(Align)); if (Res != UR_RESULT_SUCCESS) { getLastStatusRef() = Res; return UMF_RESULT_ERROR_MEMORY_PROVIDER_SPECIFIC; diff --git a/source/adapters/level_zero/CMakeLists.txt b/source/adapters/level_zero/CMakeLists.txt index 5e6d0ce18e..27f99e45e7 100644 --- a/source/adapters/level_zero/CMakeLists.txt +++ b/source/adapters/level_zero/CMakeLists.txt @@ -89,8 +89,9 @@ if(UR_BUILD_ADAPTER_L0) endif() # TODO: fix level_zero adapter conversion warnings + # C4267: The compiler detected a conversion from size_t to a smaller type. target_compile_options(ur_adapter_level_zero PRIVATE - $<$:/wd4805 /wd4244> + $<$:/wd4805 /wd4244 /wd4267> ) set_target_properties(ur_adapter_level_zero PROPERTIES @@ -98,9 +99,9 @@ if(UR_BUILD_ADAPTER_L0) SOVERSION "${PROJECT_VERSION_MAJOR}" ) - if (WIN32) - # 0x800: Search for the DLL only in the System32 folder - target_link_options(ur_adapter_level_zero PRIVATE /DEPENDENTLOADFLAG:0x800) + if(CMAKE_CXX_COMPILER_LINKER_ID MATCHES MSVC) + # 0x800: Search for the DLL only in the System32 folder + target_link_options(ur_adapter_level_zero PRIVATE LINKER:/DEPENDENTLOADFLAG:0x800) endif() target_link_libraries(ur_adapter_level_zero PRIVATE @@ -182,8 +183,9 @@ if(UR_BUILD_ADAPTER_L0_V2) target_compile_definitions(ur_adapter_level_zero_v2 PUBLIC UR_ADAPTER_LEVEL_ZERO_V2) # TODO: fix level_zero adapter conversion warnings + # C4267: The compiler detected a conversion from size_t to a smaller type. target_compile_options(ur_adapter_level_zero_v2 PRIVATE - $<$:/wd4805 /wd4244> + $<$:/wd4805 /wd4244 /wd4100 /wd4267> ) set_target_properties(ur_adapter_level_zero_v2 PROPERTIES @@ -191,9 +193,9 @@ if(UR_BUILD_ADAPTER_L0_V2) SOVERSION "${PROJECT_VERSION_MAJOR}" ) - if (WIN32) - # 0x800: Search for the DLL only in the System32 folder - target_link_options(ur_adapter_level_zero_v2 PUBLIC /DEPENDENTLOADFLAG:0x800) + if(CMAKE_CXX_COMPILER_LINKER_ID MATCHES MSVC) + # 0x800: Search for the DLL only in the System32 folder + target_link_options(ur_adapter_level_zero_v2 PUBLIC LINKER:/DEPENDENTLOADFLAG:0x800) endif() target_link_libraries(ur_adapter_level_zero_v2 PRIVATE diff --git a/source/adapters/level_zero/adapter.cpp b/source/adapters/level_zero/adapter.cpp index be79c09fef..d83d30da29 100644 --- a/source/adapters/level_zero/adapter.cpp +++ b/source/adapters/level_zero/adapter.cpp @@ -450,7 +450,5 @@ ur_result_t urAdapterGetInfo(ur_adapter_handle_t, ur_adapter_info_t PropName, default: return UR_RESULT_ERROR_INVALID_ENUMERATION; } - - return UR_RESULT_SUCCESS; } } // namespace ur::level_zero diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index 296e3e98d5..f2ba684bfa 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -756,7 +756,7 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList( // queue's map to hold the fence and other associated command // list information. auto &QGroup = Queue->getQueueGroup(UseCopyEngine); - uint32_t QueueGroupOrdinal; + uint32_t QueueGroupOrdinal = 0; auto &ZeCommandQueue = ForcedCmdQueue ? *ForcedCmdQueue : QGroup.getZeQueue(&QueueGroupOrdinal); diff --git a/source/adapters/level_zero/device.cpp b/source/adapters/level_zero/device.cpp index 866fd0e15f..a4c7d7eeb6 100644 --- a/source/adapters/level_zero/device.cpp +++ b/source/adapters/level_zero/device.cpp @@ -155,7 +155,7 @@ ur_result_t urDeviceGet( } } - uint32_t ZeDeviceCount = MatchedDevices.size(); + uint32_t ZeDeviceCount = static_cast(MatchedDevices.size()); auto N = (std::min)(ZeDeviceCount, NumEntries); if (Devices) @@ -318,9 +318,10 @@ ur_result_t urDeviceGetInfo( Device->QueueGroup[ur_device_handle_t_::queue_group_info_t::Compute] .ZeIndex >= 0; if (RepresentsCSlice) - MaxComputeUnits /= Device->RootDevice->SubDevices.size(); + MaxComputeUnits /= + static_cast(Device->RootDevice->SubDevices.size()); - return ReturnValue(uint32_t{MaxComputeUnits}); + return ReturnValue(MaxComputeUnits); } case UR_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS: // Level Zero spec defines only three dimensions @@ -422,7 +423,8 @@ ur_result_t urDeviceGetInfo( return Res; } - uint32_t ZeSubDeviceCount = Device->SubDevices.size(); + uint32_t ZeSubDeviceCount = + static_cast(Device->SubDevices.size()); if (pSize && ZeSubDeviceCount < 2) { *pSize = 0; return UR_RESULT_SUCCESS; @@ -1161,8 +1163,6 @@ ur_result_t urDeviceGetInfo( logger::toHex(ParamName)); return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION; } - - return UR_RESULT_SUCCESS; } bool CopyEngineRequested(const ur_device_handle_t &Device) { @@ -1210,7 +1210,7 @@ ur_result_t urDevicePartition( return Res; } - auto EffectiveNumDevices = [&]() -> decltype(Device->SubDevices.size()) { + auto EffectiveNumDevices = [&]() -> uint32_t { if (Device->SubDevices.size() == 0) return 0; @@ -1233,7 +1233,7 @@ ur_result_t urDevicePartition( } } - return Device->SubDevices.size(); + return static_cast(Device->SubDevices.size()); }(); // TODO: Consider support for partitioning to <= total sub-devices. diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index 2bd3011b4b..1c43aa111d 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -494,8 +494,6 @@ ur_result_t urEventGetInfo( PropName, logger::toHex(PropName)); return UR_RESULT_ERROR_INVALID_VALUE; } - - return UR_RESULT_SUCCESS; } ur_result_t urEventGetProfilingInfo( diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 721db3c359..506b0ee35b 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -99,8 +99,6 @@ ur_result_t urPlatformGetInfo( logger::debug("urPlatformGetInfo: unrecognized ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } - - return UR_RESULT_SUCCESS; } ur_result_t urPlatformGetApiVersion( diff --git a/source/adapters/level_zero/program.hpp b/source/adapters/level_zero/program.hpp index 4fe8c24acd..e4818e37bf 100644 --- a/source/adapters/level_zero/program.hpp +++ b/source/adapters/level_zero/program.hpp @@ -46,7 +46,8 @@ struct ur_program_handle_t_ : _ur_object { class SpecConstantShim { public: SpecConstantShim(ur_program_handle_t_ *Program) { - ZeSpecConstants.numConstants = Program->SpecConstants.size(); + ZeSpecConstants.numConstants = + static_cast(Program->SpecConstants.size()); ZeSpecContantsIds.reserve(ZeSpecConstants.numConstants); ZeSpecContantsValues.reserve(ZeSpecConstants.numConstants); diff --git a/source/adapters/level_zero/queue.cpp b/source/adapters/level_zero/queue.cpp index 978547df10..4d736736f4 100644 --- a/source/adapters/level_zero/queue.cpp +++ b/source/adapters/level_zero/queue.cpp @@ -2263,7 +2263,7 @@ ur_result_t ur_queue_handle_t_::createCommandList( ZeStruct ZeFenceDesc; ze_command_list_handle_t ZeCommandList; - uint32_t QueueGroupOrdinal; + uint32_t QueueGroupOrdinal = 0; auto &QGroup = getQueueGroup(UseCopyEngine); auto &ZeCommandQueue = ForcedCmdQueue ? *ForcedCmdQueue : QGroup.getZeQueue(&QueueGroupOrdinal); diff --git a/source/adapters/level_zero/usm.cpp b/source/adapters/level_zero/usm.cpp index 28bdf233e8..bf592e0db6 100644 --- a/source/adapters/level_zero/usm.cpp +++ b/source/adapters/level_zero/usm.cpp @@ -689,7 +689,6 @@ ur_result_t urUSMGetMemAllocInfo( logger::error("urUSMGetMemAllocInfo: unsupported ParamName"); return UR_RESULT_ERROR_INVALID_VALUE; } - return UR_RESULT_SUCCESS; } ur_result_t urUSMPoolCreate( diff --git a/source/adapters/level_zero/v2/event.cpp b/source/adapters/level_zero/v2/event.cpp index ba42b1ba0b..b970f95064 100644 --- a/source/adapters/level_zero/v2/event.cpp +++ b/source/adapters/level_zero/v2/event.cpp @@ -169,8 +169,6 @@ ur_result_t urEventGetInfo(ur_event_handle_t hEvent, ur_event_info_t propName, propName, logger::toHex(propName)); return UR_RESULT_ERROR_INVALID_VALUE; } - - return UR_RESULT_SUCCESS; } ur_result_t urEventGetProfilingInfo( diff --git a/source/adapters/level_zero/v2/usm.cpp b/source/adapters/level_zero/v2/usm.cpp index f23a6c6fe8..9b2ae2a0d7 100644 --- a/source/adapters/level_zero/v2/usm.cpp +++ b/source/adapters/level_zero/v2/usm.cpp @@ -378,6 +378,5 @@ ur_result_t urUSMGetMemAllocInfo( return UR_RESULT_ERROR_INVALID_VALUE; } } - return UR_RESULT_SUCCESS; } } // namespace ur::level_zero diff --git a/source/adapters/level_zero/virtual_mem.cpp b/source/adapters/level_zero/virtual_mem.cpp index e89899ded7..68c457d181 100644 --- a/source/adapters/level_zero/virtual_mem.cpp +++ b/source/adapters/level_zero/virtual_mem.cpp @@ -38,7 +38,6 @@ ur_result_t urVirtualMemGranularityGetInfo( propName, propName); return UR_RESULT_ERROR_INVALID_VALUE; } - return UR_RESULT_SUCCESS; } ur_result_t urVirtualMemReserve(ur_context_handle_t hContext, @@ -119,7 +118,5 @@ ur_result_t urVirtualMemGetInfo(ur_context_handle_t hContext, propName, propName); return UR_RESULT_ERROR_INVALID_VALUE; } - - return UR_RESULT_SUCCESS; } } // namespace ur::level_zero diff --git a/source/adapters/opencl/adapter.cpp b/source/adapters/opencl/adapter.cpp index 1decaa92ca..5e030eab24 100644 --- a/source/adapters/opencl/adapter.cpp +++ b/source/adapters/opencl/adapter.cpp @@ -98,6 +98,4 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetInfo(ur_adapter_handle_t, default: return UR_RESULT_ERROR_INVALID_ENUMERATION; } - - return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/event.cpp b/source/adapters/opencl/event.cpp index 45550a68e8..1792d0f110 100644 --- a/source/adapters/opencl/event.cpp +++ b/source/adapters/opencl/event.cpp @@ -10,6 +10,7 @@ #include "common.hpp" +#include #include #include #include @@ -32,8 +33,7 @@ cl_event_info convertUREventInfoToCL(const ur_event_info_t PropName) { return CL_EVENT_REFERENCE_COUNT; break; default: - return -1; - break; + return std::numeric_limits::max(); } } @@ -51,7 +51,7 @@ convertURProfilingInfoToCL(const ur_profiling_info_t PropName) { case UR_PROFILING_INFO_COMMAND_END: return CL_PROFILING_COMMAND_END; default: - return -1; + return std::numeric_limits::max(); } } diff --git a/source/adapters/opencl/memory.cpp b/source/adapters/opencl/memory.cpp index b2476fc420..674eacd6ac 100644 --- a/source/adapters/opencl/memory.cpp +++ b/source/adapters/opencl/memory.cpp @@ -9,6 +9,7 @@ //===----------------------------------------------------------------------===// #include "common.hpp" +#include cl_image_format mapURImageFormatToCL(const ur_image_format_t *PImageFormat) { cl_image_format CLImageFormat; @@ -59,7 +60,8 @@ cl_image_format mapURImageFormatToCL(const ur_image_format_t *PImageFormat) { CLImageFormat.image_channel_order = CL_sRGBA; break; default: - CLImageFormat.image_channel_order = -1; + CLImageFormat.image_channel_order = + std::numeric_limits::max(); break; } @@ -110,7 +112,8 @@ cl_image_format mapURImageFormatToCL(const ur_image_format_t *PImageFormat) { CLImageFormat.image_channel_data_type = CL_FLOAT; break; default: - CLImageFormat.image_channel_data_type = -1; + CLImageFormat.image_channel_data_type = + std::numeric_limits::max(); break; } @@ -139,7 +142,7 @@ cl_image_desc mapURImageDescToCL(const ur_image_desc_t *PImageDesc) { CLImageDesc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY; break; default: - CLImageDesc.image_type = -1; + CLImageDesc.image_type = std::numeric_limits::max(); break; } diff --git a/source/adapters/opencl/program.cpp b/source/adapters/opencl/program.cpp index 9c8f214410..a046cad056 100644 --- a/source/adapters/opencl/program.cpp +++ b/source/adapters/opencl/program.cpp @@ -143,10 +143,10 @@ urProgramCompile([[maybe_unused]] ur_context_handle_t hContext, std::unique_ptr> DevicesInProgram; UR_RETURN_ON_FAILURE(getDevicesFromProgram(hProgram, DevicesInProgram)); - CL_RETURN_ON_FAILURE(clCompileProgram(cl_adapter::cast(hProgram), - DevicesInProgram->size(), - DevicesInProgram->data(), pOptions, 0, - nullptr, nullptr, nullptr, nullptr)); + CL_RETURN_ON_FAILURE(clCompileProgram( + cl_adapter::cast(hProgram), + static_cast(DevicesInProgram->size()), DevicesInProgram->data(), + pOptions, 0, nullptr, nullptr, nullptr, nullptr)); return UR_RESULT_SUCCESS; } @@ -201,9 +201,10 @@ urProgramBuild([[maybe_unused]] ur_context_handle_t hContext, std::unique_ptr> DevicesInProgram; UR_RETURN_ON_FAILURE(getDevicesFromProgram(hProgram, DevicesInProgram)); - CL_RETURN_ON_FAILURE(clBuildProgram( - cl_adapter::cast(hProgram), DevicesInProgram->size(), - DevicesInProgram->data(), pOptions, nullptr, nullptr)); + CL_RETURN_ON_FAILURE( + clBuildProgram(cl_adapter::cast(hProgram), + static_cast(DevicesInProgram->size()), + DevicesInProgram->data(), pOptions, nullptr, nullptr)); return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/queue.cpp b/source/adapters/opencl/queue.cpp index 2e40963ad1..0bb81cb1e5 100644 --- a/source/adapters/opencl/queue.cpp +++ b/source/adapters/opencl/queue.cpp @@ -8,9 +8,9 @@ #include "common.hpp" #include "platform.hpp" +#include cl_command_queue_info mapURQueueInfoToCL(const ur_queue_info_t PropName) { - switch (PropName) { case UR_QUEUE_INFO_CONTEXT: return CL_QUEUE_CONTEXT; @@ -25,7 +25,7 @@ cl_command_queue_info mapURQueueInfoToCL(const ur_queue_info_t PropName) { case UR_QUEUE_INFO_SIZE: return CL_QUEUE_SIZE; default: - return -1; + return std::numeric_limits::max(); } } diff --git a/source/adapters/opencl/usm.cpp b/source/adapters/opencl/usm.cpp index 03ee4a18f3..940c054d97 100644 --- a/source/adapters/opencl/usm.cpp +++ b/source/adapters/opencl/usm.cpp @@ -513,12 +513,14 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy2D( } cl_int ClResult = CL_SUCCESS; if (blocking) { - ClResult = clWaitForEvents(Events.size(), Events.data()); + ClResult = + clWaitForEvents(static_cast(Events.size()), Events.data()); } if (phEvent && ClResult == CL_SUCCESS) { ClResult = clEnqueueBarrierWithWaitList( - cl_adapter::cast(hQueue), Events.size(), - Events.data(), cl_adapter::cast(phEvent)); + cl_adapter::cast(hQueue), + static_cast(Events.size()), Events.data(), + cl_adapter::cast(phEvent)); } for (const auto &E : Events) { CL_RETURN_ON_FAILURE(clReleaseEvent(E)); diff --git a/source/adapters/opencl/usm_p2p.cpp b/source/adapters/opencl/usm_p2p.cpp index b0f51eac2b..66387f5226 100644 --- a/source/adapters/opencl/usm_p2p.cpp +++ b/source/adapters/opencl/usm_p2p.cpp @@ -8,13 +8,12 @@ // //===----------------------------------------------------------------------===// -#include "common.hpp" +#include "logger/ur_logger.hpp" UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp([[maybe_unused]] ur_device_handle_t commandDevice, [[maybe_unused]] ur_device_handle_t peerDevice) { - - cl_adapter::die( + logger::warning( "Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -22,8 +21,7 @@ urUsmP2PEnablePeerAccessExp([[maybe_unused]] ur_device_handle_t commandDevice, UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp([[maybe_unused]] ur_device_handle_t commandDevice, [[maybe_unused]] ur_device_handle_t peerDevice) { - - cl_adapter::die( + logger::warning( "Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -34,8 +32,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( [[maybe_unused]] ur_exp_peer_info_t propName, [[maybe_unused]] size_t propSize, [[maybe_unused]] void *pPropValue, [[maybe_unused]] size_t *pPropSizeRet) { - - cl_adapter::die( + logger::warning( "Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/source/common/logger/ur_logger.hpp b/source/common/logger/ur_logger.hpp index c4dc655444..1039d16d3f 100644 --- a/source/common/logger/ur_logger.hpp +++ b/source/common/logger/ur_logger.hpp @@ -116,8 +116,9 @@ template inline std::string toHex(T t) { inline Logger create_logger(std::string logger_name, bool skip_prefix, bool skip_linebreak, logger::Level default_log_level) { - std::transform(logger_name.begin(), logger_name.end(), logger_name.begin(), - ::toupper); + std::transform( + logger_name.begin(), logger_name.end(), logger_name.begin(), + [](char c) -> char { return static_cast(::toupper(c)); }); std::stringstream env_var_name; const auto default_flush_level = logger::Level::ERR; const std::string default_output = "stderr"; diff --git a/source/common/ur_util.cpp b/source/common/ur_util.cpp index 176a2e028e..78651c4212 100644 --- a/source/common/ur_util.cpp +++ b/source/common/ur_util.cpp @@ -15,7 +15,7 @@ #include int ur_getpid(void) { return static_cast(GetCurrentProcessId()); } -int ur_close_fd(int fd) { return -1; } +int ur_close_fd(int fd [[maybe_unused]]) { return -1; } int ur_duplicate_fd(int pid, int fd_in) { // TODO: find another way to obtain a duplicate of another process's file descriptor diff --git a/source/common/ur_util.hpp b/source/common/ur_util.hpp index 0ede3c93dc..878123b6f0 100644 --- a/source/common/ur_util.hpp +++ b/source/common/ur_util.hpp @@ -98,8 +98,9 @@ std::optional ur_getenv(const char *name); inline bool getenv_tobool(const char *name, bool def = false) { if (auto env = ur_getenv(name); env) { - std::transform(env->begin(), env->end(), env->begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform(env->begin(), env->end(), env->begin(), [](char c) { + return static_cast(std::tolower(c)); + }); auto true_str = {"y", "yes", "t", "true", "1"}; return std::find(true_str.begin(), true_str.end(), *env) != true_str.end(); diff --git a/source/loader/layers/tracing/ur_tracing_layer.cpp b/source/loader/layers/tracing/ur_tracing_layer.cpp index 7a3f30d9a8..c081d827b3 100644 --- a/source/loader/layers/tracing/ur_tracing_layer.cpp +++ b/source/loader/layers/tracing/ur_tracing_layer.cpp @@ -12,8 +12,16 @@ #include "ur_tracing_layer.hpp" #include "ur_api.h" #include "ur_util.hpp" + +#ifdef _MSC_VER +#pragma warning(disable : 4245) +#endif #include "xpti/xpti_data_types.h" #include "xpti/xpti_trace_framework.h" +#ifdef _MSC_VER +#pragma warning(default : 4245) +#endif + #include #include #include diff --git a/source/loader/ur_adapter_registry.hpp b/source/loader/ur_adapter_registry.hpp index 7df799ab1e..201b57c6f0 100644 --- a/source/loader/ur_adapter_registry.hpp +++ b/source/loader/ur_adapter_registry.hpp @@ -225,12 +225,13 @@ class AdapterRegistry { } // case-insensitive comparison by converting both tolower - std::transform(platformBackendName.begin(), - platformBackendName.end(), - platformBackendName.begin(), - [](unsigned char c) { return std::tolower(c); }); - std::transform(backend.begin(), backend.end(), backend.begin(), - [](unsigned char c) { return std::tolower(c); }); + std::transform( + platformBackendName.begin(), platformBackendName.end(), + platformBackendName.begin(), + [](char c) { return static_cast(std::tolower(c)); }); + std::transform( + backend.begin(), backend.end(), backend.begin(), + [](char c) { return static_cast(std::tolower(c)); }); std::size_t nameFound = platformBackendName.find(backend); bool backendFound = nameFound != std::string::npos; diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index e1de6d6237..fb8035b428 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -17,6 +17,7 @@ #define NOMINMAX #include "ur_api.h" #include "ur_ldrddi.hpp" +#include #endif // !NOMINMAX #include "logger/ur_logger.hpp" @@ -412,7 +413,7 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, using DeviceIdType = unsigned long; constexpr DeviceIdType DeviceIdTypeALL = - -1; // ULONG_MAX but without #include + std::numeric_limits::max(); struct DeviceSpec { DevicePartLevel level; @@ -426,8 +427,9 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, auto getRootHardwareType = [](const std::string &input) -> DeviceHardwareType { std::string lowerInput(input); - std::transform(lowerInput.cbegin(), lowerInput.cend(), - lowerInput.begin(), ::tolower); + std::transform( + lowerInput.cbegin(), lowerInput.cend(), lowerInput.begin(), + [](char c) { return static_cast(std::tolower(c)); }); if (lowerInput == "cpu") { return ::UR_DEVICE_TYPE_CPU; } @@ -482,9 +484,8 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, platformBackendName.cend(), backend.cbegin(), backend.cend(), [](const auto &a, const auto &b) { // case-insensitive comparison by converting both tolower - return std::tolower( - static_cast(a)) == - std::tolower(static_cast(b)); + return std::tolower(static_cast(a)) == + std::tolower(static_cast(b)); })) { // irrelevant term for current request: different backend -- silently ignore logger::error("unrecognised backend '{}'", backend); diff --git a/source/loader/windows/adapter_search.cpp b/source/loader/windows/adapter_search.cpp index b514897d91..f850ec5de7 100644 --- a/source/loader/windows/adapter_search.cpp +++ b/source/loader/windows/adapter_search.cpp @@ -40,7 +40,8 @@ std::optional getLoaderLibPath() { return std::nullopt; } -std::optional getAdapterNameAsPath(std::string adapterName) { +std::optional getAdapterNameAsPath(std::string adapterName + [[maybe_unused]]) { return std::nullopt; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e7514cefd8..b9a7f5a0d0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -32,6 +32,7 @@ add_subdirectory(mock) if(UR_BUILD_TOOLS) add_subdirectory(tools) endif() -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX AND UR_TEST_FUZZTESTS) +if(CMAKE_CXX_COMPILER_ID STREQUAL Clang AND UR_DPCXX AND UR_TEST_FUZZTESTS AND + CMAKE_SYSTEM_NAME STREQUAL Linux) add_subdirectory(fuzz) endif() diff --git a/test/conformance/device/urDevicePartition.cpp b/test/conformance/device/urDevicePartition.cpp index 2b2939066d..1241900a1a 100644 --- a/test/conformance/device/urDevicePartition.cpp +++ b/test/conformance/device/urDevicePartition.cpp @@ -138,7 +138,7 @@ TEST_F(urDevicePartitionTest, PartitionByCounts) { uint32_t sum = 0; for (auto sub_device : sub_devices) { ASSERT_NE(sub_device, nullptr); - uint32_t n_cu_in_sub_device; + uint32_t n_cu_in_sub_device = 0; ASSERT_NO_FATAL_FAILURE( getNumberComputeUnits(sub_device, n_cu_in_sub_device)); sum += n_cu_in_sub_device; diff --git a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp index 799ce7a67d..d247ee6e96 100644 --- a/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp +++ b/test/conformance/enqueue/urEnqueueDeviceGlobalVariableRead.cpp @@ -14,7 +14,7 @@ TEST_P(urEnqueueDeviceGetGlobalVariableReadTest, Success) { 0, &global_var.value, 0, nullptr, nullptr)); size_t global_offset = 0; - size_t n_dimensions = 1; + uint32_t n_dimensions = 1; size_t global_size = 1; // execute the kernel diff --git a/test/conformance/enqueue/urEnqueueEventsWaitMultiDevice.cpp b/test/conformance/enqueue/urEnqueueEventsWaitMultiDevice.cpp index 1e281b0632..8ee6dc5365 100644 --- a/test/conformance/enqueue/urEnqueueEventsWaitMultiDevice.cpp +++ b/test/conformance/enqueue/urEnqueueEventsWaitMultiDevice.cpp @@ -175,8 +175,9 @@ TEST_P(urEnqueueEventsWaitMultiDeviceMTTest, EnqueueWaitOnAllQueues) { doComputation(work); uur::raii::Event gatherEvent; - ASSERT_SUCCESS(urEnqueueEventsWait(queues[0], devices.size(), events.data(), - gatherEvent.ptr())); + ASSERT_SUCCESS(urEnqueueEventsWait(queues[0], + static_cast(devices.size()), + events.data(), gatherEvent.ptr())); ASSERT_SUCCESS(urEventWait(1, gatherEvent.ptr())); for (size_t i = 0; i < devices.size(); i++) { @@ -201,9 +202,9 @@ TEST_P(urEnqueueEventsWaitMultiDeviceMTTest, doComputation(work); uur::raii::Event hGatherEvent; - ASSERT_SUCCESS(urEnqueueEventsWait(queues[0], eventHandles.size(), - eventHandles.data(), - hGatherEvent.ptr())); + ASSERT_SUCCESS(urEnqueueEventsWait( + queues[0], static_cast(eventHandles.size()), + eventHandles.data(), hGatherEvent.ptr())); ASSERT_SUCCESS(urEventWait(1, hGatherEvent.ptr())); for (auto &event : eventHandles) { diff --git a/test/conformance/enqueue/urEnqueueKernelLaunch.cpp b/test/conformance/enqueue/urEnqueueKernelLaunch.cpp index aa1c436fa8..fa1090b537 100644 --- a/test/conformance/enqueue/urEnqueueKernelLaunch.cpp +++ b/test/conformance/enqueue/urEnqueueKernelLaunch.cpp @@ -15,7 +15,7 @@ struct urEnqueueKernelLaunchTest : uur::urKernelExecutionTest { uint32_t val = 42; size_t global_size = 32; size_t global_offset = 0; - size_t n_dimensions = 1; + uint32_t n_dimensions = 1; }; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchTest); @@ -29,7 +29,7 @@ struct urEnqueueKernelLaunchKernelWgSizeTest : uur::urKernelExecutionTest { std::array global_offset{0, 0, 0}; // This must match the size in fixed_wg_size.cpp std::array wg_size{4, 4, 4}; - size_t n_dimensions = 3; + uint32_t n_dimensions = 3; }; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchKernelWgSizeTest); @@ -42,7 +42,7 @@ struct urEnqueueKernelLaunchKernelSubGroupTest : uur::urKernelExecutionTest { std::array global_size{32, 32, 32}; std::array global_offset{0, 0, 0}; - size_t n_dimensions = 3; + uint32_t n_dimensions = 3; }; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchKernelSubGroupTest); @@ -52,7 +52,7 @@ struct urEnqueueKernelLaunchKernelStandardTest : uur::urKernelExecutionTest { UUR_RETURN_ON_FATAL_FAILURE(urKernelExecutionTest::SetUp()); } - size_t n_dimensions = 1; + uint32_t n_dimensions = 1; size_t global_size = 1; size_t offset = 0; }; @@ -209,7 +209,7 @@ TEST_P(urEnqueueKernelLaunchKernelStandardTest, Success) { struct testParametersEnqueueKernel { size_t X, Y, Z; - size_t Dims; + uint32_t Dims; }; template @@ -260,7 +260,7 @@ struct urEnqueueKernelLaunchTestWithParam uint32_t val = 42; size_t global_range[3]; size_t global_offset[3] = {0, 0, 0}; - size_t n_dimensions; + uint32_t n_dimensions; size_t buffer_size; }; @@ -332,7 +332,7 @@ struct urEnqueueKernelLaunchWithUSM : uur::urKernelExecutionTest { UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchWithUSM); TEST_P(urEnqueueKernelLaunchWithUSM, Success) { - size_t work_dim = 1; + uint32_t work_dim = 1; size_t global_offset = 0; size_t global_size = alloc_size / sizeof(uint32_t); uint32_t fill_val = 42; @@ -423,7 +423,7 @@ struct urEnqueueKernelLaunchWithVirtualMemory : uur::urKernelExecutionTest { UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchWithVirtualMemory); TEST_P(urEnqueueKernelLaunchWithVirtualMemory, Success) { - size_t work_dim = 1; + uint32_t work_dim = 1; size_t global_offset = 0; size_t global_size = alloc_size / sizeof(uint32_t); uint32_t fill_val = 42; diff --git a/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp b/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp index b6306f1693..f20e4f1873 100644 --- a/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp +++ b/test/conformance/enqueue/urEnqueueKernelLaunchAndMemcpyInOrder.cpp @@ -354,7 +354,7 @@ TEST_P(urEnqueueKernelLaunchIncrementMultiDeviceMultiThreadTest, Success) { for (size_t i = 0; i < numThreads; i++) { threads.emplace_back([this, i, queuePerThread, useEvents]() { constexpr size_t global_offset = 0; - constexpr size_t n_dimensions = 1; + constexpr uint32_t n_dimensions = 1; auto queue = queuePerThread ? queues[i] : queues.back(); auto kernel = kernels[i]; @@ -362,7 +362,7 @@ TEST_P(urEnqueueKernelLaunchIncrementMultiDeviceMultiThreadTest, Success) { std::vector Events(numOpsPerThread + 1); for (size_t j = 0; j < numOpsPerThread; j++) { - size_t waitNum = 0; + uint32_t waitNum = 0; ur_event_handle_t *lastEvent = nullptr; ur_event_handle_t *signalEvent = nullptr; diff --git a/test/conformance/exp_command_buffer/commands.cpp b/test/conformance/exp_command_buffer/commands.cpp index 49b2444176..4ca2d263cb 100644 --- a/test/conformance/exp_command_buffer/commands.cpp +++ b/test/conformance/exp_command_buffer/commands.cpp @@ -148,8 +148,8 @@ struct urCommandBufferAppendKernelLaunchExpTest int32_t *ptrX = static_cast(shared_ptrs[1]); int32_t *ptrY = static_cast(shared_ptrs[2]); for (size_t i = 0; i < global_size; i++) { - ptrX[i] = i; - ptrY[i] = i * 2; + ptrX[i] = static_cast(i); + ptrY[i] = static_cast(i * 2); } // Index 0 is output @@ -200,7 +200,7 @@ TEST_P(urCommandBufferAppendKernelLaunchExpTest, Basic) { int32_t *ptrZ = static_cast(shared_ptrs[0]); for (size_t i = 0; i < global_size; i++) { - uint32_t result = (A * i) + (i * 2); + int32_t result = static_cast((A * i) + (i * 2)); ASSERT_EQ(result, ptrZ[i]); } } diff --git a/test/conformance/exp_command_buffer/fixtures.h b/test/conformance/exp_command_buffer/fixtures.h index 42bee05b5a..9f9455ce98 100644 --- a/test/conformance/exp_command_buffer/fixtures.h +++ b/test/conformance/exp_command_buffer/fixtures.h @@ -8,6 +8,8 @@ #include +#include + namespace uur { namespace command_buffer { diff --git a/test/conformance/exp_command_buffer/update/buffer_fill_kernel_update.cpp b/test/conformance/exp_command_buffer/update/buffer_fill_kernel_update.cpp index 3e13a895ff..1a56e356be 100644 --- a/test/conformance/exp_command_buffer/update/buffer_fill_kernel_update.cpp +++ b/test/conformance/exp_command_buffer/update/buffer_fill_kernel_update.cpp @@ -336,7 +336,7 @@ TEST_P(BufferFillCommandTest, OverrideUpdate) { ASSERT_SUCCESS(urCommandBufferUpdateKernelLaunchExp(command_handle, &first_update_desc)); - uint32_t second_val = -99; + uint32_t second_val = 99; ur_exp_command_buffer_update_value_arg_desc_t second_input_desc = { UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC, // stype nullptr, // pNext @@ -393,7 +393,7 @@ TEST_P(BufferFillCommandTest, OverrideArgList) { &first_val, // hArgValue }; - uint32_t second_val = -99; + uint32_t second_val = 99; input_descs[1] = { UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC, // stype nullptr, // pNext diff --git a/test/conformance/exp_command_buffer/update/buffer_saxpy_kernel_update.cpp b/test/conformance/exp_command_buffer/update/buffer_saxpy_kernel_update.cpp index 858b6b5680..5484289cec 100644 --- a/test/conformance/exp_command_buffer/update/buffer_saxpy_kernel_update.cpp +++ b/test/conformance/exp_command_buffer/update/buffer_saxpy_kernel_update.cpp @@ -31,7 +31,7 @@ struct BufferSaxpyKernelTest } // Variable that is incremented as arguments are added to the kernel - size_t current_arg_index = 0; + uint32_t current_arg_index = 0; // Index 0 is output buffer for HIP/Non-HIP ASSERT_SUCCESS(urKernelSetArgMemObj(kernel, current_arg_index++, nullptr, buffers[0])); diff --git a/test/conformance/exp_command_buffer/update/kernel_handle_update.cpp b/test/conformance/exp_command_buffer/update/kernel_handle_update.cpp index c74af937f6..4f05bdd679 100644 --- a/test/conformance/exp_command_buffer/update/kernel_handle_update.cpp +++ b/test/conformance/exp_command_buffer/update/kernel_handle_update.cpp @@ -269,7 +269,8 @@ TEST_P(urCommandBufferKernelHandleUpdateTest, Success) { ASSERT_SUCCESS(urCommandBufferAppendKernelLaunchExp( updatable_cmd_buf_handle, SaxpyKernel->Kernel, SaxpyKernel->NDimensions, &(SaxpyKernel->GlobalOffset), &(SaxpyKernel->GlobalSize), - &(SaxpyKernel->LocalSize), KernelAlternatives.size(), + &(SaxpyKernel->LocalSize), + static_cast(KernelAlternatives.size()), KernelAlternatives.data(), 0, nullptr, 0, nullptr, nullptr, nullptr, CommandHandle.ptr())); ASSERT_NE(CommandHandle, nullptr); @@ -298,7 +299,8 @@ TEST_P(urCommandBufferKernelHandleUpdateTest, UpdateAgain) { ASSERT_SUCCESS(urCommandBufferAppendKernelLaunchExp( updatable_cmd_buf_handle, SaxpyKernel->Kernel, SaxpyKernel->NDimensions, &(SaxpyKernel->GlobalOffset), &(SaxpyKernel->GlobalSize), - &(SaxpyKernel->LocalSize), KernelAlternatives.size(), + &(SaxpyKernel->LocalSize), + static_cast(KernelAlternatives.size()), KernelAlternatives.data(), 0, nullptr, 0, nullptr, nullptr, nullptr, CommandHandle.ptr())); ASSERT_NE(CommandHandle, nullptr); @@ -336,7 +338,8 @@ TEST_P(urCommandBufferKernelHandleUpdateTest, RestoreOriginalKernel) { ASSERT_SUCCESS(urCommandBufferAppendKernelLaunchExp( updatable_cmd_buf_handle, SaxpyKernel->Kernel, SaxpyKernel->NDimensions, &(SaxpyKernel->GlobalOffset), &(SaxpyKernel->GlobalSize), - &(SaxpyKernel->LocalSize), KernelAlternatives.size(), + &(SaxpyKernel->LocalSize), + static_cast(KernelAlternatives.size()), KernelAlternatives.data(), 0, nullptr, 0, nullptr, nullptr, nullptr, CommandHandle.ptr())); ASSERT_NE(CommandHandle, nullptr); @@ -394,9 +397,9 @@ TEST_P(urCommandBufferKernelHandleUpdateTest, updatable_cmd_buf_handle, SaxpyKernel->Kernel, SaxpyKernel->NDimensions, &(SaxpyKernel->GlobalOffset), &(SaxpyKernel->GlobalSize), &(SaxpyKernel->LocalSize), - KernelAlternatives.size(), KernelAlternatives.data(), - 0, nullptr, 0, nullptr, nullptr, nullptr, - &CommandHandle)); + static_cast(KernelAlternatives.size()), + KernelAlternatives.data(), 0, nullptr, 0, nullptr, + nullptr, nullptr, &CommandHandle)); } using urCommandBufferValidUpdateParametersTest = @@ -451,7 +454,8 @@ TEST_P(urCommandBufferValidUpdateParametersTest, UpdateOnlyLocalWorkSize) { ASSERT_SUCCESS(urCommandBufferAppendKernelLaunchExp( updatable_cmd_buf_handle, SaxpyKernel->Kernel, SaxpyKernel->NDimensions, &(SaxpyKernel->GlobalOffset), &(SaxpyKernel->GlobalSize), - &(SaxpyKernel->LocalSize), KernelAlternatives.size(), + &(SaxpyKernel->LocalSize), + static_cast(KernelAlternatives.size()), KernelAlternatives.data(), 0, nullptr, 0, nullptr, nullptr, nullptr, CommandHandle.ptr())); ASSERT_NE(CommandHandle, nullptr); diff --git a/test/conformance/exp_command_buffer/update/usm_fill_kernel_update.cpp b/test/conformance/exp_command_buffer/update/usm_fill_kernel_update.cpp index 85e6beccf9..a28414c94d 100644 --- a/test/conformance/exp_command_buffer/update/usm_fill_kernel_update.cpp +++ b/test/conformance/exp_command_buffer/update/usm_fill_kernel_update.cpp @@ -222,7 +222,7 @@ struct USMMultipleFillCommandTest std::memset(shared_ptr, 0, allocation_size); // Append multiple kernel commands to command-buffer - for (size_t k = 0; k < num_kernels; k++) { + for (uint32_t k = 0; k < num_kernels; k++) { // Calculate offset into output allocation, and set as // kernel output. void *offset_ptr = (uint32_t *)shared_ptr + (k * elements); @@ -270,7 +270,7 @@ struct USMMultipleFillCommandTest static constexpr size_t global_offset = 0; static constexpr size_t n_dimensions = 1; static constexpr size_t allocation_size = sizeof(val) * global_size; - static constexpr size_t num_kernels = 8; + static constexpr uint32_t num_kernels = 8; static constexpr size_t elements = global_size / num_kernels; void *shared_ptr = nullptr; @@ -290,7 +290,7 @@ TEST_P(USMMultipleFillCommandTest, UpdateAllKernels) { uint32_t *output = (uint32_t *)shared_ptr; for (size_t i = 0; i < global_size; i++) { - const uint32_t expected = val + (i / elements); + const uint32_t expected = val + (static_cast(i) / elements); ASSERT_EQ(expected, output[i]); } @@ -314,7 +314,7 @@ TEST_P(USMMultipleFillCommandTest, UpdateAllKernels) { }; // Update fill value - uint32_t new_fill_val = new_val + k; + uint32_t new_fill_val = new_val + static_cast(k); ur_exp_command_buffer_update_value_arg_desc_t new_input_desc = { UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_UPDATE_VALUE_ARG_DESC, // stype nullptr, // pNext @@ -352,7 +352,7 @@ TEST_P(USMMultipleFillCommandTest, UpdateAllKernels) { // Verify that update occurred correctly uint32_t *updated_output = (uint32_t *)new_shared_ptr; for (size_t i = 0; i < global_size; i++) { - uint32_t expected = new_val + (i / elements); + uint32_t expected = new_val + (static_cast(i) / elements); ASSERT_EQ(expected, updated_output[i]) << i; } } diff --git a/test/conformance/exp_launch_properties/launch_properties.cpp b/test/conformance/exp_launch_properties/launch_properties.cpp index a54a44ecaf..fcb1bdc78c 100644 --- a/test/conformance/exp_launch_properties/launch_properties.cpp +++ b/test/conformance/exp_launch_properties/launch_properties.cpp @@ -14,7 +14,7 @@ struct urEnqueueKernelLaunchCustomTest : uur::urKernelExecutionTest { uint32_t val = 42; size_t global_size = 32; size_t global_offset = 0; - size_t n_dimensions = 1; + uint32_t n_dimensions = 1; }; UUR_INSTANTIATE_DEVICE_TEST_SUITE_P(urEnqueueKernelLaunchCustomTest); diff --git a/test/conformance/integration/QueueBuffer.cpp b/test/conformance/integration/QueueBuffer.cpp index d801ebf684..02d5b7b1b9 100644 --- a/test/conformance/integration/QueueBuffer.cpp +++ b/test/conformance/integration/QueueBuffer.cpp @@ -4,8 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "fixtures.h" -#include -#include +#include struct QueueBufferTestWithParam : uur::IntegrationQueueTestWithParam { void SetUp() override { @@ -47,8 +46,8 @@ TEST_P(QueueBufferTestWithParam, QueueBufferTest) { std::vector EventsFill; ur_event_handle_t Event; - size_t Buffer1Index; - size_t Buffer2Index; + size_t Buffer1Index = 0; + size_t Buffer2Index = 0; ASSERT_NO_FATAL_FAILURE( AddBuffer1DArg(ArraySize * sizeof(uint32_t), &Buffer1, &Buffer1Index)); ASSERT_NO_FATAL_FAILURE( @@ -75,10 +74,10 @@ TEST_P(QueueBufferTestWithParam, QueueBufferTest) { for (uint32_t i = 0; i < NumIterations; ++i) { /* Copy from DeviceMem1 to DeviceMem2 and multiply by 2 */ - ASSERT_SUCCESS( - urKernelSetArgMemObj(kernel, Buffer2Index, nullptr, Buffer2)); - ASSERT_SUCCESS( - urKernelSetArgMemObj(kernel, Buffer1Index, nullptr, Buffer1)); + ASSERT_SUCCESS(urKernelSetArgMemObj( + kernel, static_cast(Buffer2Index), nullptr, Buffer2)); + ASSERT_SUCCESS(urKernelSetArgMemObj( + kernel, static_cast(Buffer1Index), nullptr, Buffer1)); ASSERT_SUCCESS(urEnqueueKernelLaunch(Queue, kernel, NDimensions, &GlobalOffset, &ArraySize, nullptr, @@ -88,10 +87,10 @@ TEST_P(QueueBufferTestWithParam, QueueBufferTest) { CurValueMem2 = CurValueMem1 * 2; /* Copy from DeviceMem1 to DeviceMem2 and multiply by 2 */ - ASSERT_SUCCESS( - urKernelSetArgMemObj(kernel, Buffer1Index, nullptr, Buffer2)); - ASSERT_SUCCESS( - urKernelSetArgMemObj(kernel, Buffer2Index, nullptr, Buffer1)); + ASSERT_SUCCESS(urKernelSetArgMemObj( + kernel, static_cast(Buffer1Index), nullptr, Buffer2)); + ASSERT_SUCCESS(urKernelSetArgMemObj( + kernel, static_cast(Buffer2Index), nullptr, Buffer1)); ASSERT_SUCCESS(urEnqueueKernelLaunch(Queue, kernel, NDimensions, &GlobalOffset, &ArraySize, nullptr, diff --git a/test/conformance/integration/fixtures.h b/test/conformance/integration/fixtures.h index aca70a5245..d4d71fa9fa 100644 --- a/test/conformance/integration/fixtures.h +++ b/test/conformance/integration/fixtures.h @@ -35,7 +35,8 @@ struct IntegrationQueueTestWithParam void submitBarrierIfNeeded(std::vector &(Events)) { if (QueueFlags == UR_QUEUE_FLAG_OUT_OF_ORDER_EXEC_MODE_ENABLE) { ASSERT_SUCCESS(urEnqueueEventsWaitWithBarrier( - Queue, Events.size(), Events.data(), nullptr)); + Queue, static_cast(Events.size()), Events.data(), + nullptr)); AllEvents.insert(AllEvents.end(), Events.begin(), Events.end()); } } diff --git a/test/conformance/kernel/urKernelGetSuggestedLocalWorkSize.cpp b/test/conformance/kernel/urKernelGetSuggestedLocalWorkSize.cpp index 4eeabf5573..4b39755400 100644 --- a/test/conformance/kernel/urKernelGetSuggestedLocalWorkSize.cpp +++ b/test/conformance/kernel/urKernelGetSuggestedLocalWorkSize.cpp @@ -12,7 +12,7 @@ struct urKernelGetSuggestedLocalWorkSizeTest : uur::urKernelExecutionTest { } size_t global_size = 32; size_t global_offset = 0; - size_t n_dimensions = 1; + uint32_t n_dimensions = 1; size_t suggested_local_work_size; }; diff --git a/test/conformance/kernel/urKernelSetArgSampler.cpp b/test/conformance/kernel/urKernelSetArgSampler.cpp index 824619874e..9a06299f66 100644 --- a/test/conformance/kernel/urKernelSetArgSampler.cpp +++ b/test/conformance/kernel/urKernelSetArgSampler.cpp @@ -88,7 +88,7 @@ UUR_INSTANTIATE_KERNEL_TEST_SUITE_P(urKernelSetArgSamplerTest); TEST_P(urKernelSetArgSamplerTest, SuccessWithProps) { ur_kernel_arg_sampler_properties_t props{ UR_STRUCTURE_TYPE_KERNEL_ARG_SAMPLER_PROPERTIES, nullptr}; - size_t arg_index = 2; + uint32_t arg_index = 2; ASSERT_SUCCESS(urKernelSetArgSampler(kernel, arg_index, &props, sampler)); } diff --git a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp index f7617a2940..bf2a44300a 100644 --- a/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp +++ b/test/conformance/memory-migrate/urMemBufferMigrateAcrossDevices.cpp @@ -88,7 +88,7 @@ struct urMultiDeviceContextMemBufferTest : urMultiDeviceContextTest { } // Adds a kernel arg representing a sycl buffer constructed with a 1D range. - void AddBuffer1DArg(ur_kernel_handle_t kernel, size_t current_arg_index, + void AddBuffer1DArg(ur_kernel_handle_t kernel, uint32_t current_arg_index, ur_mem_handle_t buffer) { ASSERT_SUCCESS( urKernelSetArgMemObj(kernel, current_arg_index, nullptr, buffer)); diff --git a/test/conformance/program/urMultiDeviceProgramCreateWithBinary.cpp b/test/conformance/program/urMultiDeviceProgramCreateWithBinary.cpp index 95a135af1c..1b8e380d27 100644 --- a/test/conformance/program/urMultiDeviceProgramCreateWithBinary.cpp +++ b/test/conformance/program/urMultiDeviceProgramCreateWithBinary.cpp @@ -39,8 +39,8 @@ struct urMultiDeviceProgramCreateWithBinaryTest // Now create a program with multiple device binaries. ASSERT_SUCCESS(urProgramCreateWithBinary( - context, devices.size(), devices.data(), binary_sizes.data(), - pointers.data(), nullptr, &binary_program)); + context, static_cast(devices.size()), devices.data(), + binary_sizes.data(), pointers.data(), nullptr, &binary_program)); } void TearDown() override { @@ -61,7 +61,7 @@ struct urMultiDeviceProgramCreateWithBinaryTest TEST_F(urMultiDeviceProgramCreateWithBinaryTest, CreateAndRunKernelOnAllDevices) { constexpr size_t global_offset = 0; - constexpr size_t n_dimensions = 1; + constexpr uint32_t n_dimensions = 1; constexpr size_t global_size = 100; constexpr size_t local_size = 100; @@ -112,8 +112,9 @@ TEST_F(urMultiDeviceProgramCreateWithBinaryTest, pointers_with_invalid_binary.push_back(nullptr); } uur::raii::Program invalid_bin_program; - ASSERT_EQ(urProgramCreateWithBinary(context, devices.size(), devices.data(), - binary_sizes.data(), + ASSERT_EQ(urProgramCreateWithBinary(context, + static_cast(devices.size()), + devices.data(), binary_sizes.data(), pointers_with_invalid_binary.data(), nullptr, invalid_bin_program.ptr()), UR_RESULT_ERROR_INVALID_VALUE); @@ -132,20 +133,23 @@ TEST_F(urMultiDeviceProgramCreateWithBinaryTest, MultipleBuildCalls) { devices.begin(), devices.begin() + devices.size() / 2); auto second_subset = std::vector( devices.begin() + devices.size() / 2, devices.end()); - ASSERT_SUCCESS(urProgramBuildExp(binary_program, first_subset.size(), + ASSERT_SUCCESS(urProgramBuildExp(binary_program, + static_cast(first_subset.size()), first_subset.data(), nullptr)); auto kernelName = uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0]; uur::raii::Kernel kernel; ASSERT_SUCCESS( urKernelCreate(binary_program, kernelName.data(), kernel.ptr())); - ASSERT_SUCCESS(urProgramBuildExp(binary_program, second_subset.size(), - second_subset.data(), nullptr)); + ASSERT_SUCCESS(urProgramBuildExp( + binary_program, static_cast(second_subset.size()), + second_subset.data(), nullptr)); ASSERT_SUCCESS( urKernelCreate(binary_program, kernelName.data(), kernel.ptr())); // Building for the same subset of devices should not fail. - ASSERT_SUCCESS(urProgramBuildExp(binary_program, first_subset.size(), + ASSERT_SUCCESS(urProgramBuildExp(binary_program, + static_cast(first_subset.size()), first_subset.data(), nullptr)); } diff --git a/test/conformance/testing/include/uur/utils.h b/test/conformance/testing/include/uur/utils.h index 8e2033d8dc..41e396bdfe 100644 --- a/test/conformance/testing/include/uur/utils.h +++ b/test/conformance/testing/include/uur/utils.h @@ -176,8 +176,6 @@ ur_result_t GetObjectReferenceCount(T object, uint32_t &out_ref_count) { object, UR_EXP_COMMAND_BUFFER_COMMAND_INFO_REFERENCE_COUNT, out_ref_count); } - - return UR_RESULT_ERROR_INVALID_VALUE; } inline std::string GetPlatformName(ur_platform_handle_t hPlatform) { diff --git a/test/conformance/usm/urUSMDeviceAlloc.cpp b/test/conformance/usm/urUSMDeviceAlloc.cpp index cd48e73dbe..e3a454743f 100644 --- a/test/conformance/usm/urUSMDeviceAlloc.cpp +++ b/test/conformance/usm/urUSMDeviceAlloc.cpp @@ -110,9 +110,10 @@ TEST_P(urUSMDeviceAllocTest, InvalidNullPtrResult) { TEST_P(urUSMDeviceAllocTest, InvalidUSMSize) { void *ptr = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_USM_SIZE, - urUSMDeviceAlloc(context, device, nullptr, pool, -1, &ptr)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_USM_SIZE, + urUSMDeviceAlloc(context, device, nullptr, pool, + std::numeric_limits::max(), + &ptr)); } TEST_P(urUSMDeviceAllocTest, InvalidValueAlignPowerOfTwo) { diff --git a/test/conformance/usm/urUSMHostAlloc.cpp b/test/conformance/usm/urUSMHostAlloc.cpp index ce11ddf3c1..7fc64ea804 100644 --- a/test/conformance/usm/urUSMHostAlloc.cpp +++ b/test/conformance/usm/urUSMHostAlloc.cpp @@ -5,6 +5,7 @@ #include "helpers.h" #include +#include #include struct urUSMHostAllocTest @@ -123,7 +124,8 @@ TEST_P(urUSMHostAllocTest, InvalidNullPtrMem) { TEST_P(urUSMHostAllocTest, InvalidUSMSize) { void *ptr = nullptr; ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_USM_SIZE, - urUSMHostAlloc(context, nullptr, pool, -1, &ptr)); + urUSMHostAlloc(context, nullptr, pool, + std::numeric_limits::max(), &ptr)); } TEST_P(urUSMHostAllocTest, InvalidValueAlignPowerOfTwo) { diff --git a/test/conformance/usm/urUSMSharedAlloc.cpp b/test/conformance/usm/urUSMSharedAlloc.cpp index e50bd8cfe7..9531b23326 100644 --- a/test/conformance/usm/urUSMSharedAlloc.cpp +++ b/test/conformance/usm/urUSMSharedAlloc.cpp @@ -4,6 +4,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception #include "helpers.h" +#include #include struct urUSMSharedAllocTest @@ -140,9 +141,10 @@ TEST_P(urUSMSharedAllocTest, InvalidNullPtrMem) { TEST_P(urUSMSharedAllocTest, InvalidUSMSize) { void *ptr = nullptr; - ASSERT_EQ_RESULT( - UR_RESULT_ERROR_INVALID_USM_SIZE, - urUSMSharedAlloc(context, device, nullptr, pool, -1, &ptr)); + ASSERT_EQ_RESULT(UR_RESULT_ERROR_INVALID_USM_SIZE, + urUSMSharedAlloc(context, device, nullptr, pool, + std::numeric_limits::max(), + &ptr)); } TEST_P(urUSMSharedAllocTest, InvalidValueAlignPowerOfTwo) { diff --git a/test/layers/tracing/test_collector.cpp b/test/layers/tracing/test_collector.cpp index 2e412427a7..961a8989aa 100644 --- a/test/layers/tracing/test_collector.cpp +++ b/test/layers/tracing/test_collector.cpp @@ -19,7 +19,14 @@ #include #include "ur_api.h" + +#ifdef _MSC_VER +#pragma warning(disable : 4245) +#endif #include "xpti/xpti_trace_framework.h" +#ifdef _MSC_VER +#pragma warning(default : 4245) +#endif constexpr uint16_t TRACE_FN_BEGIN = static_cast(xpti::trace_point_type_t::function_with_args_begin); diff --git a/tools/urinfo/utils.hpp b/tools/urinfo/utils.hpp index d7819b2947..c879d7fb56 100644 --- a/tools/urinfo/utils.hpp +++ b/tools/urinfo/utils.hpp @@ -51,7 +51,7 @@ inline std::string getAdapterBackend(ur_adapter_handle_t adapter) { stripPrefix(adapterBackendStream.str(), "UR_ADAPTER_BACKEND_"); std::transform(adapterBackendStr.begin(), adapterBackendStr.end(), adapterBackendStr.begin(), - [](unsigned char c) { return std::tolower(c); }); + [](char c) { return static_cast(std::tolower(c)); }); return adapterBackendStr; } @@ -65,7 +65,7 @@ inline std::string getDeviceType(ur_device_handle_t device) { stripPrefix(deviceTypeStream.str(), "UR_DEVICE_TYPE_"); std::transform(deviceTypeStr.begin(), deviceTypeStr.end(), deviceTypeStr.begin(), - [](unsigned char c) { return std::tolower(c); }); + [](char c) { return static_cast(std::tolower(c)); }); return deviceTypeStr; } diff --git a/tools/urtrace/collector.cpp b/tools/urtrace/collector.cpp index eb8c18d164..ea40d63e06 100644 --- a/tools/urtrace/collector.cpp +++ b/tools/urtrace/collector.cpp @@ -30,7 +30,14 @@ #include "ur_api.h" #include "ur_print.hpp" #include "ur_util.hpp" + +#ifdef _MSC_VER +#pragma warning(disable : 4245) +#endif #include "xpti/xpti_trace_framework.h" +#ifdef _MSC_VER +#pragma warning(default : 4245) +#endif constexpr uint16_t TRACE_FN_BEGIN = static_cast(xpti::trace_point_type_t::function_with_args_begin); @@ -279,7 +286,6 @@ std::unique_ptr create_writer() { default: ur::unreachable(); } - return nullptr; } static std::unique_ptr &writer() {