Skip to content

Don't use std::ignore for unused parameters #17219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions unified-runtime/source/adapters/cuda/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urAdapterRelease(ur_adapter_handle_t) {
}

UR_APIEXPORT ur_result_t UR_APICALL urAdapterGetLastError(
ur_adapter_handle_t, const char **ppMessage, int32_t *pError) {
std::ignore = pError;
ur_adapter_handle_t, const char **ppMessage, int32_t * /*pError*/) {
*ppMessage = ErrorMessage;
return ErrorMessageCode;
}
Expand Down
3 changes: 1 addition & 2 deletions unified-runtime/source/adapters/cuda/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ ur_context_handle_t_::getOwningURPool(umf_memory_pool_t *UMFPool) {
///
UR_APIEXPORT ur_result_t UR_APICALL
urContextCreate(uint32_t DeviceCount, const ur_device_handle_t *phDevices,
const ur_context_properties_t *pProperties,
const ur_context_properties_t * /*pProperties*/,
ur_context_handle_t *phContext) {
std::ignore = pProperties;

std::unique_ptr<ur_context_handle_t_> ContextPtr{nullptr};
try {
Expand Down
9 changes: 5 additions & 4 deletions unified-runtime/source/adapters/cuda/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetInfo(ur_device_handle_t hDevice,

/// \return PI_SUCCESS if the function is executed successfully
/// CUDA devices are always root devices so retain always returns success.
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRetain(ur_device_handle_t) {
UR_APIEXPORT ur_result_t UR_APICALL
urDeviceRetain(ur_device_handle_t /*hDevice*/) {
return UR_RESULT_SUCCESS;
}

Expand All @@ -1210,7 +1211,8 @@ urDevicePartition(ur_device_handle_t, const ur_device_partition_properties_t *,

/// \return UR_RESULT_SUCCESS always since CUDA devices are always root
/// devices.
UR_APIEXPORT ur_result_t UR_APICALL urDeviceRelease(ur_device_handle_t) {
UR_APIEXPORT ur_result_t UR_APICALL
urDeviceRelease(ur_device_handle_t /*hDevice*/) {
return UR_RESULT_SUCCESS;
}

Expand Down Expand Up @@ -1337,9 +1339,8 @@ ur_result_t UR_APICALL urDeviceGetGlobalTimestamps(ur_device_handle_t hDevice,
/// \return If available, the first binary that is PTX
///
UR_APIEXPORT ur_result_t UR_APICALL urDeviceSelectBinary(
ur_device_handle_t hDevice, const ur_device_binary_t *pBinaries,
ur_device_handle_t /*hDevice*/, const ur_device_binary_t *pBinaries,
uint32_t NumBinaries, uint32_t *pSelectedBinary) {
std::ignore = hDevice;

// Look for an image for the NVPTX64 target, and return the first one that is
// found
Expand Down
18 changes: 6 additions & 12 deletions unified-runtime/source/adapters/cuda/enqueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1179,11 +1179,9 @@ static ur_result_t commonEnqueueMemImageNDCopy(

UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
ur_queue_handle_t hQueue, ur_mem_handle_t hImage, bool blockingRead,
ur_rect_offset_t origin, ur_rect_region_t region, size_t rowPitch,
size_t slicePitch, void *pDst, uint32_t numEventsInWaitList,
ur_rect_offset_t origin, ur_rect_region_t region, size_t /*rowPitch*/,
size_t /*slicePitch*/, void *pDst, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) {
std::ignore = rowPitch;
std::ignore = slicePitch;

UR_ASSERT(hImage->isImage(), UR_RESULT_ERROR_INVALID_MEM_OBJECT);

Expand Down Expand Up @@ -1253,13 +1251,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
}

UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageWrite(
ur_queue_handle_t hQueue, ur_mem_handle_t hImage, bool blockingWrite,
ur_rect_offset_t origin, ur_rect_region_t region, size_t rowPitch,
size_t slicePitch, void *pSrc, uint32_t numEventsInWaitList,
ur_queue_handle_t hQueue, ur_mem_handle_t hImage, bool /*blockingWrite*/,
ur_rect_offset_t origin, ur_rect_region_t region, size_t /*rowPitch*/,
size_t /*slicePitch*/, void *pSrc, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) {
std::ignore = blockingWrite;
std::ignore = rowPitch;
std::ignore = slicePitch;

UR_ASSERT(hImage->isImage(), UR_RESULT_ERROR_INVALID_MEM_OBJECT);
auto &Image = std::get<SurfaceMem>(hImage->Mem);
Expand Down Expand Up @@ -1597,9 +1592,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMMemcpy(

UR_APIEXPORT ur_result_t UR_APICALL urEnqueueUSMPrefetch(
ur_queue_handle_t hQueue, const void *pMem, size_t size,
ur_usm_migration_flags_t flags, uint32_t numEventsInWaitList,
ur_usm_migration_flags_t /*flags*/, uint32_t numEventsInWaitList,
const ur_event_handle_t *phEventWaitList, ur_event_handle_t *phEvent) {
std::ignore = flags;

size_t PointerRangeSize = 0;
UR_CHECK_ERROR(cuPointerGetAttribute(
Expand Down
3 changes: 1 addition & 2 deletions unified-runtime/source/adapters/cuda/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEventGetNativeHandle(

UR_APIEXPORT ur_result_t UR_APICALL urEventCreateWithNativeHandle(
ur_native_handle_t hNativeEvent, ur_context_handle_t hContext,
const ur_event_native_properties_t *pProperties,
const ur_event_native_properties_t * /*pProperties*/,
ur_event_handle_t *phEvent) {
std::ignore = pProperties;

std::unique_ptr<ur_event_handle_t_> EventPtr{nullptr};

Expand Down
4 changes: 1 addition & 3 deletions unified-runtime/source/adapters/cuda/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,15 +259,13 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler,

UR_APIEXPORT ur_result_t UR_APICALL urUSMPitchedAllocExp(
ur_context_handle_t hContext, ur_device_handle_t hDevice,
const ur_usm_desc_t *pUSMDesc, ur_usm_pool_handle_t pool,
const ur_usm_desc_t * /*pUSMDesc*/, ur_usm_pool_handle_t /*pool*/,
size_t widthInBytes, size_t height, size_t elementSizeBytes, void **ppMem,
size_t *pResultPitch) {
UR_ASSERT(std::find(hContext->getDevices().begin(),
hContext->getDevices().end(),
hDevice) != hContext->getDevices().end(),
UR_RESULT_ERROR_INVALID_CONTEXT);
std::ignore = pUSMDesc;
std::ignore = pool;

UR_ASSERT((height > 0), UR_RESULT_ERROR_INVALID_VALUE);
UR_ASSERT((elementSizeBytes > 0), UR_RESULT_ERROR_INVALID_VALUE);
Expand Down
58 changes: 22 additions & 36 deletions unified-runtime/source/adapters/cuda/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,13 +190,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelGetNativeHandle(
}

UR_APIEXPORT ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp(
ur_kernel_handle_t hKernel, ur_device_handle_t hDevice, uint32_t workDim,
const size_t *pLocalWorkSize, size_t dynamicSharedMemorySize,
uint32_t *pGroupCountRet) {
ur_kernel_handle_t hKernel, ur_device_handle_t /*hDevice*/,
uint32_t workDim, const size_t *pLocalWorkSize,
size_t dynamicSharedMemorySize, uint32_t *pGroupCountRet) {
UR_ASSERT(hKernel, UR_RESULT_ERROR_INVALID_KERNEL);

std::ignore = hDevice;

size_t localWorkSize = pLocalWorkSize[0];
localWorkSize *= (workDim >= 2 ? pLocalWorkSize[1] : 1);
localWorkSize *= (workDim == 3 ? pLocalWorkSize[2] : 1);
Expand Down Expand Up @@ -244,9 +242,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSuggestMaxCooperativeGroupCountExp(

UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgValue(
ur_kernel_handle_t hKernel, uint32_t argIndex, size_t argSize,
const ur_kernel_arg_value_properties_t *pProperties,
const ur_kernel_arg_value_properties_t * /*pProperties*/,
const void *pArgValue) {
std::ignore = pProperties;
UR_ASSERT(argSize, UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE);

ur_result_t Result = UR_RESULT_SUCCESS;
Expand All @@ -260,8 +257,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgValue(

UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgLocal(
ur_kernel_handle_t hKernel, uint32_t argIndex, size_t argSize,
const ur_kernel_arg_local_properties_t *pProperties) {
std::ignore = pProperties;
const ur_kernel_arg_local_properties_t * /*pProperties*/) {
UR_ASSERT(argSize, UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE);

ur_result_t Result = UR_RESULT_SUCCESS;
Expand Down Expand Up @@ -357,11 +353,10 @@ urKernelGetSubGroupInfo(ur_kernel_handle_t hKernel, ur_device_handle_t hDevice,
return UR_RESULT_ERROR_INVALID_ENUMERATION;
}

UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgPointer(ur_kernel_handle_t hKernel, uint32_t argIndex,
const ur_kernel_arg_pointer_properties_t *pProperties,
const void *pArgValue) {
std::ignore = pProperties;
UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgPointer(
ur_kernel_handle_t hKernel, uint32_t argIndex,
const ur_kernel_arg_pointer_properties_t * /*pProperties*/,
const void *pArgValue) {
try {
// setKernelArg is expecting a pointer to our argument
hKernel->setKernelArg(argIndex, sizeof(pArgValue), &pArgValue);
Expand Down Expand Up @@ -416,14 +411,11 @@ urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex,
}

// A NOP for the CUDA backend
UR_APIEXPORT ur_result_t UR_APICALL urKernelSetExecInfo(
ur_kernel_handle_t hKernel, ur_kernel_exec_info_t propName, size_t propSize,
const ur_kernel_exec_info_properties_t *pProperties,
const void *pPropValue) {
std::ignore = hKernel;
std::ignore = propSize;
std::ignore = pPropValue;
std::ignore = pProperties;
UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetExecInfo(ur_kernel_handle_t /*hKernel*/,
ur_kernel_exec_info_t propName, size_t /*propSize*/,
const ur_kernel_exec_info_properties_t * /*pProperties*/,
const void * /*pPropValue*/) {

switch (propName) {
case UR_KERNEL_EXEC_INFO_USM_INDIRECT_ACCESS:
Expand All @@ -436,23 +428,17 @@ UR_APIEXPORT ur_result_t UR_APICALL urKernelSetExecInfo(
}

UR_APIEXPORT ur_result_t UR_APICALL urKernelCreateWithNativeHandle(
ur_native_handle_t hNativeKernel, ur_context_handle_t hContext,
ur_program_handle_t hProgram,
const ur_kernel_native_properties_t *pProperties,
ur_kernel_handle_t *phKernel) {
std::ignore = hNativeKernel;
std::ignore = hContext;
std::ignore = hProgram;
std::ignore = pProperties;
std::ignore = phKernel;
ur_native_handle_t /*hNativeKernel*/, ur_context_handle_t /*hContext*/,
ur_program_handle_t /*hProgram*/,
const ur_kernel_native_properties_t * /*pProperties*/,
ur_kernel_handle_t * /*phKernel*/) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urKernelSetArgSampler(ur_kernel_handle_t hKernel, uint32_t argIndex,
const ur_kernel_arg_sampler_properties_t *pProperties,
ur_sampler_handle_t hArgValue) {
std::ignore = pProperties;
UR_APIEXPORT ur_result_t UR_APICALL urKernelSetArgSampler(
ur_kernel_handle_t hKernel, uint32_t argIndex,
const ur_kernel_arg_sampler_properties_t * /*pProperties*/,
ur_sampler_handle_t hArgValue) {

ur_result_t Result = UR_RESULT_SUCCESS;
try {
Expand Down
13 changes: 5 additions & 8 deletions unified-runtime/source/adapters/cuda/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,14 @@ urPlatformGet(ur_adapter_handle_t, uint32_t, ur_platform_handle_t *phPlatforms,
}

UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetApiVersion(
ur_platform_handle_t hDriver, ur_api_version_t *pVersion) {
std::ignore = hDriver;
ur_platform_handle_t /*hDriver*/, ur_api_version_t *pVersion) {
*pVersion = UR_API_VERSION_CURRENT;
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetNativeHandle(
ur_platform_handle_t hPlatform, ur_native_handle_t *phNativePlatform) {
std::ignore = hPlatform;
std::ignore = phNativePlatform;
UR_APIEXPORT ur_result_t UR_APICALL
urPlatformGetNativeHandle(ur_platform_handle_t /*hPlatform*/,
ur_native_handle_t * /*phNativePlatform*/) {
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

Expand All @@ -214,9 +212,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformCreateWithNativeHandle(
// Return empty string for cuda.
// TODO: Determine correct string to be passed.
UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetBackendOption(
ur_platform_handle_t hPlatform, const char *pFrontendOption,
ur_platform_handle_t /*hPlatform*/, const char *pFrontendOption,
const char **ppPlatformOption) {
std::ignore = hPlatform;
using namespace std::literals;
if (pFrontendOption == nullptr)
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
Expand Down
16 changes: 7 additions & 9 deletions unified-runtime/source/adapters/cuda/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
/// Loads the images from a UR program into a CUmodule that can be
/// used later on to extract functions (kernels).
/// See \ref ur_program_handle_t for implementation details.
UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext,
ur_program_handle_t hProgram,
const char *pOptions) {
std::ignore = hContext;
UR_APIEXPORT ur_result_t UR_APICALL
urProgramBuild(ur_context_handle_t /*hContext*/, ur_program_handle_t hProgram,
const char *pOptions) {

ur_result_t Result = UR_RESULT_SUCCESS;

Expand Down Expand Up @@ -361,11 +360,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle(
return UR_RESULT_ERROR_UNSUPPORTED_FEATURE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urProgramGetBuildInfo(ur_program_handle_t hProgram, ur_device_handle_t hDevice,
ur_program_build_info_t propName, size_t propSize,
void *pPropValue, size_t *pPropSizeRet) {
std::ignore = hDevice;
UR_APIEXPORT ur_result_t UR_APICALL urProgramGetBuildInfo(
ur_program_handle_t hProgram, ur_device_handle_t /*hDevice*/,
ur_program_build_info_t propName, size_t propSize, void *pPropValue,
size_t *pPropSizeRet) {

UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);

Expand Down
10 changes: 4 additions & 6 deletions unified-runtime/source/adapters/cuda/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueFinish(ur_queue_handle_t hQueue) {
// There is no CUDA counterpart for queue flushing and we don't run into the
// same problem of having to flush cross-queue dependencies as some of the
// other plugins, so it can be left as no-op.
UR_APIEXPORT ur_result_t UR_APICALL urQueueFlush(ur_queue_handle_t hQueue) {
std::ignore = hQueue;
UR_APIEXPORT ur_result_t UR_APICALL urQueueFlush(ur_queue_handle_t /*hQueue*/) {
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL
urQueueGetNativeHandle(ur_queue_handle_t hQueue, ur_queue_native_desc_t *pDesc,
ur_native_handle_t *phNativeQueue) {
std::ignore = pDesc;
UR_APIEXPORT ur_result_t UR_APICALL urQueueGetNativeHandle(
ur_queue_handle_t hQueue, ur_queue_native_desc_t * /*pDesc*/,
ur_native_handle_t *phNativeQueue) {

ScopedContext Active(hQueue->getDevice());
*phNativeQueue =
Expand Down
18 changes: 3 additions & 15 deletions unified-runtime/source/adapters/cuda/usm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUSMFree(ur_context_handle_t hContext,
ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t,
ur_device_handle_t Device,
ur_usm_device_mem_flags_t, size_t Size,
uint32_t Alignment) {
[[maybe_unused]] uint32_t Alignment) {
try {
ScopedContext Active(Device);
*ResultPtr = umfPoolMalloc(Device->MemoryPoolDevice, Size);
Expand All @@ -122,20 +122,16 @@ ur_result_t USMDeviceAllocImpl(void **ResultPtr, ur_context_handle_t,
return Err;
}

#ifdef NDEBUG
std::ignore = Alignment;
#else
assert((Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0));
#endif
return UR_RESULT_SUCCESS;
}

ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t,
ur_device_handle_t Device,
ur_usm_host_mem_flags_t,
ur_usm_device_mem_flags_t, size_t Size,
uint32_t Alignment) {
[[maybe_unused]] uint32_t Alignment) {
try {
ScopedContext Active(Device);
*ResultPtr = umfPoolMalloc(Device->MemoryPoolShared, Size);
Expand All @@ -144,31 +140,23 @@ ur_result_t USMSharedAllocImpl(void **ResultPtr, ur_context_handle_t,
return Err;
}

#ifdef NDEBUG
std::ignore = Alignment;
#else
assert((Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0));
#endif
return UR_RESULT_SUCCESS;
}

ur_result_t USMHostAllocImpl(void **ResultPtr, ur_context_handle_t hContext,
ur_usm_host_mem_flags_t, size_t Size,
uint32_t Alignment) {
[[maybe_unused]] uint32_t Alignment) {
try {
*ResultPtr = umfPoolMalloc(hContext->MemoryPoolHost, Size);
UMF_CHECK_PTR(*ResultPtr);
} catch (ur_result_t Err) {
return Err;
}

#ifdef NDEBUG
std::ignore = Alignment;
#else
assert((Alignment == 0 ||
reinterpret_cast<std::uintptr_t>(*ResultPtr) % Alignment == 0));
#endif
return UR_RESULT_SUCCESS;
}

Expand Down
Loading