From 420d79edf8ce8e6b85a5f9ffd38de724e0b2eadd Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Fri, 6 Sep 2024 13:38:59 +0100 Subject: [PATCH] [NFC] Warning squishing This fixes some warnings picked up by GCC 11 and Clang 20 when -Wextra is set. Note that -Wextra is not currently set on any command line - I'll do that seperately as part of a more general "hardening" commit. --- source/adapters/level_zero/context.cpp | 2 +- source/adapters/level_zero/event.cpp | 4 ++-- source/adapters/level_zero/image.cpp | 4 +++- .../level_zero/v2/event_provider_normal.cpp | 2 +- .../level_zero/v2/queue_immediate_in_order.cpp | 1 + source/loader/ur_lib.cpp | 16 +++++++++------- .../urKernelCreateWithNativeHandle.cpp | 12 ++++++++---- test/conformance/context/urContextCreate.cpp | 3 ++- test/conformance/device_code/indexers_usm.cpp | 3 +++ test/conformance/device_code/linker_error.cpp | 10 +++++----- test/conformance/exp_command_buffer/fixtures.h | 3 ++- .../program/urProgramCreateWithIL.cpp | 3 ++- 12 files changed, 39 insertions(+), 24 deletions(-) diff --git a/source/adapters/level_zero/context.cpp b/source/adapters/level_zero/context.cpp index de75dc6126..a8eaaa2317 100644 --- a/source/adapters/level_zero/context.cpp +++ b/source/adapters/level_zero/context.cpp @@ -512,7 +512,7 @@ ur_result_t ur_context_handle_t_::getFreeSlotInExistingOrNewPool( // Create one event ZePool per MaxNumEventsPerPool events if (*ZePool == nullptr) { ze_event_pool_counter_based_exp_desc_t counterBasedExt = { - ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC}; + ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC, nullptr, 0}; ZeStruct ZeEventPoolDesc; ZeEventPoolDesc.count = MaxNumEventsPerPool; ZeEventPoolDesc.flags = 0; diff --git a/source/adapters/level_zero/event.cpp b/source/adapters/level_zero/event.cpp index c6aaa99a9a..01ea6efb91 100644 --- a/source/adapters/level_zero/event.cpp +++ b/source/adapters/level_zero/event.cpp @@ -1517,8 +1517,8 @@ ur_result_t _ur_ze_event_list_t::createAndRetainUrZeEventList( std::shared_lock Lock(EventList[I]->Mutex); - ur_device_handle_t QueueRootDevice; - ur_device_handle_t CurrentQueueRootDevice; + ur_device_handle_t QueueRootDevice = nullptr; + ur_device_handle_t CurrentQueueRootDevice = nullptr; if (Queue) { QueueRootDevice = Queue->Device; CurrentQueueRootDevice = CurQueueDevice; diff --git a/source/adapters/level_zero/image.cpp b/source/adapters/level_zero/image.cpp index fc623e7e74..a717597623 100644 --- a/source/adapters/level_zero/image.cpp +++ b/source/adapters/level_zero/image.cpp @@ -16,6 +16,7 @@ #include "sampler.hpp" #include "ur_interface_loader.hpp" #include "ur_level_zero.hpp" +#include "ze_api.h" typedef ze_result_t(ZE_APICALL *zeImageGetDeviceOffsetExp_pfn)( ze_image_handle_t hImage, uint64_t *pDeviceOffset); @@ -445,7 +446,8 @@ ur_result_t bindlessImagesCreateImpl(ur_context_handle_t hContext, ze_image_handle_t ZeImage; ze_memory_allocation_properties_t MemAllocProperties{ - ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES}; + ZE_STRUCTURE_TYPE_MEMORY_ALLOCATION_PROPERTIES, nullptr, + ZE_MEMORY_TYPE_UNKNOWN, 0, 0}; ZE2UR_CALL(zeMemGetAllocProperties, (hContext->ZeContext, reinterpret_cast(hImageMem), &MemAllocProperties, nullptr)); diff --git a/source/adapters/level_zero/v2/event_provider_normal.cpp b/source/adapters/level_zero/v2/event_provider_normal.cpp index 114d283c94..4df05c12ed 100644 --- a/source/adapters/level_zero/v2/event_provider_normal.cpp +++ b/source/adapters/level_zero/v2/event_provider_normal.cpp @@ -32,7 +32,7 @@ provider_pool::provider_pool(ur_context_handle_t context, desc.flags = ZE_EVENT_POOL_FLAG_HOST_VISIBLE; ze_event_pool_counter_based_exp_desc_t counterBasedExt = { - ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC, nullptr}; + ZE_STRUCTURE_TYPE_COUNTER_BASED_EVENT_POOL_EXP_DESC, nullptr, 0}; if (events == event_type::EVENT_COUNTER) { counterBasedExt.flags = diff --git a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp index eeb31a2e92..3882a69135 100644 --- a/source/adapters/level_zero/v2/queue_immediate_in_order.cpp +++ b/source/adapters/level_zero/v2/queue_immediate_in_order.cpp @@ -147,6 +147,7 @@ ur_queue_immediate_in_order_t::queueGetInfo(ur_queue_info_t propName, // We can exit early if we have in-order queue. if (!lastHandler) return ReturnValue(true); + [[fallthrough]]; } default: logger::error( diff --git a/source/loader/ur_lib.cpp b/source/loader/ur_lib.cpp index 9aad7159c3..7f2d1baa13 100644 --- a/source/loader/ur_lib.cpp +++ b/source/loader/ur_lib.cpp @@ -560,19 +560,20 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, const auto thirdDeviceId = getDeviceId(thirdPart); deviceList.push_back(DeviceSpec{ DevicePartLevel::SUBSUB, hardwareType, firstDeviceId, - secondDeviceId, thirdDeviceId}); + secondDeviceId, thirdDeviceId, nullptr}); } else { // second dot not found, this is a subdevice - deviceList.push_back(DeviceSpec{DevicePartLevel::SUB, - hardwareType, firstDeviceId, - secondDeviceId}); + deviceList.push_back( + DeviceSpec{DevicePartLevel::SUB, hardwareType, + firstDeviceId, secondDeviceId, 0, nullptr}); } } else { // first dot not found, this is a root device const auto hardwareType = getRootHardwareType(filterString); const auto firstDeviceId = getDeviceId(filterString); deviceList.push_back(DeviceSpec{DevicePartLevel::ROOT, - hardwareType, firstDeviceId}); + hardwareType, firstDeviceId, 0, + 0, nullptr}); } } } @@ -587,8 +588,9 @@ ur_result_t urDeviceGetSelected(ur_platform_handle_t hPlatform, // for example, we pretend that "garbage:0;!cuda:*" was just "!cuda:*" // so we add an implicit accept-all term (equivalent to prepending "*:*;") // as we would have done if the user had given us the corrected string - acceptDeviceList.push_back(DeviceSpec{ - DevicePartLevel::ROOT, ::UR_DEVICE_TYPE_ALL, DeviceIdTypeALL}); + acceptDeviceList.push_back(DeviceSpec{DevicePartLevel::ROOT, + ::UR_DEVICE_TYPE_ALL, + DeviceIdTypeALL, 0, 0, nullptr}); } logger::debug("DEBUG: size of acceptDeviceList = {}", diff --git a/test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp b/test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp index 6ee49dbbfb..b3918c7818 100644 --- a/test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp +++ b/test/adapters/level_zero/urKernelCreateWithNativeHandle.cpp @@ -24,7 +24,8 @@ TEST_P(urLevelZeroKernelNativeHandleTest, OwnedHandleRelease) { auto kernel_name = uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0]; - ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; + ze_module_desc_t moduleDesc{}; + moduleDesc.stype = ZE_STRUCTURE_TYPE_MODULE_DESC; moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV; moduleDesc.inputSize = il_binary->size(); moduleDesc.pInputModule = @@ -36,7 +37,8 @@ TEST_P(urLevelZeroKernelNativeHandleTest, OwnedHandleRelease) { &module, NULL), ZE_RESULT_SUCCESS); - ze_kernel_desc_t kernelDesc = {ZE_STRUCTURE_TYPE_KERNEL_DESC}; + ze_kernel_desc_t kernelDesc{}; + kernelDesc.stype = ZE_STRUCTURE_TYPE_KERNEL_DESC; kernelDesc.pKernelName = kernel_name.c_str(); ze_kernel_handle_t native_kernel; @@ -75,7 +77,8 @@ TEST_P(urLevelZeroKernelNativeHandleTest, NullProgram) { auto kernel_name = uur::KernelsEnvironment::instance->GetEntryPointNames("foo")[0]; - ze_module_desc_t moduleDesc = {ZE_STRUCTURE_TYPE_MODULE_DESC}; + ze_module_desc_t moduleDesc{}; + moduleDesc.stype = ZE_STRUCTURE_TYPE_MODULE_DESC; moduleDesc.format = ZE_MODULE_FORMAT_IL_SPIRV; moduleDesc.inputSize = il_binary->size(); moduleDesc.pInputModule = @@ -87,7 +90,8 @@ TEST_P(urLevelZeroKernelNativeHandleTest, NullProgram) { &module, NULL), ZE_RESULT_SUCCESS); - ze_kernel_desc_t kernelDesc = {ZE_STRUCTURE_TYPE_KERNEL_DESC}; + ze_kernel_desc_t kernelDesc{}; + kernelDesc.stype = ZE_STRUCTURE_TYPE_KERNEL_DESC; kernelDesc.pKernelName = kernel_name.c_str(); ze_kernel_handle_t native_kernel; diff --git a/test/conformance/context/urContextCreate.cpp b/test/conformance/context/urContextCreate.cpp index d5fb59389f..0f268a3992 100644 --- a/test/conformance/context/urContextCreate.cpp +++ b/test/conformance/context/urContextCreate.cpp @@ -17,7 +17,8 @@ TEST_P(urContextCreateTest, Success) { } TEST_P(urContextCreateTest, SuccessWithProperties) { - ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES}; + ur_context_properties_t properties{UR_STRUCTURE_TYPE_CONTEXT_PROPERTIES, + nullptr, 0}; uur::raii::Context context = nullptr; ASSERT_SUCCESS(urContextCreate(1, &device, &properties, context.ptr())); ASSERT_NE(nullptr, context); diff --git a/test/conformance/device_code/indexers_usm.cpp b/test/conformance/device_code/indexers_usm.cpp index e055fa47cc..cd3b56bf0c 100644 --- a/test/conformance/device_code/indexers_usm.cpp +++ b/test/conformance/device_code/indexers_usm.cpp @@ -3,6 +3,9 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Offsets are deprecated, but we should still test that they work +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + #include int main() { diff --git a/test/conformance/device_code/linker_error.cpp b/test/conformance/device_code/linker_error.cpp index 5fc7eebf6f..8afa369bb2 100644 --- a/test/conformance/device_code/linker_error.cpp +++ b/test/conformance/device_code/linker_error.cpp @@ -3,17 +3,17 @@ // See LICENSE.TXT // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include +#include SYCL_EXTERNAL void this_function_does_not_exist(); int main() { - cl::sycl::queue deviceQueue; - cl::sycl::range<1> numOfItems{1}; + sycl::queue deviceQueue; + sycl::range<1> numOfItems{1}; try { - deviceQueue.submit([&](cl::sycl::handler &cgh) { - auto kern = [=](cl::sycl::id<1>) { + deviceQueue.submit([&](sycl::handler &cgh) { + auto kern = [=](sycl::id<1>) { #ifdef __SYCL_DEVICE_ONLY__ this_function_does_not_exist(); #endif diff --git a/test/conformance/exp_command_buffer/fixtures.h b/test/conformance/exp_command_buffer/fixtures.h index c144ac5fa2..9a38772eb7 100644 --- a/test/conformance/exp_command_buffer/fixtures.h +++ b/test/conformance/exp_command_buffer/fixtures.h @@ -154,7 +154,8 @@ struct urUpdatableCommandBufferExpExecutionTest // Create a command-buffer with update enabled. ur_exp_command_buffer_desc_t desc{ - UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, true}; + UR_STRUCTURE_TYPE_EXP_COMMAND_BUFFER_DESC, nullptr, true, false, + false}; ASSERT_SUCCESS(urCommandBufferCreateExp(context, device, &desc, &updatable_cmd_buf_handle)); diff --git a/test/conformance/program/urProgramCreateWithIL.cpp b/test/conformance/program/urProgramCreateWithIL.cpp index 3d81d14104..7c02c3c7b9 100644 --- a/test/conformance/program/urProgramCreateWithIL.cpp +++ b/test/conformance/program/urProgramCreateWithIL.cpp @@ -37,7 +37,8 @@ TEST_P(urProgramCreateWithILTest, Success) { } TEST_P(urProgramCreateWithILTest, SuccessWithProperties) { - ur_program_properties_t properties{UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES}; + ur_program_properties_t properties{UR_STRUCTURE_TYPE_PROGRAM_PROPERTIES, + nullptr, 0, nullptr}; ur_program_handle_t program = nullptr; ASSERT_SUCCESS(urProgramCreateWithIL( context, il_binary->data(), il_binary->size(), &properties, &program));