Skip to content

Commit c63ad9b

Browse files
authored
Merge pull request #1206 from ProGTX/peter/werror
Werror fixes
2 parents 178e3fc + fbdb6a3 commit c63ad9b

File tree

13 files changed

+29
-65
lines changed

13 files changed

+29
-65
lines changed

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,6 @@ if(UR_ENABLE_TRACING)
116116
)
117117
if (MSVC)
118118
set(TARGET_XPTI $<IF:$<CONFIG:Release>,xpti,xptid>)
119-
120-
# disable warning C4267: The compiler detected a conversion from size_t to a smaller type.
121-
target_compile_options(xptifw PRIVATE /wd4267)
122119
else()
123120
set(TARGET_XPTI xpti)
124121
endif()

cmake/helpers.cmake

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,16 @@ function(add_ur_target_compile_options name)
8484
/W3
8585
/MD$<$<CONFIG:Debug>:d>
8686
/GS
87+
/DWIN32_LEAN_AND_MEAN
88+
/DNOMINMAX
8789
)
8890

8991
if(UR_DEVELOPER_MODE)
90-
target_compile_options(${name} PRIVATE /WX /GS)
92+
# _CRT_SECURE_NO_WARNINGS used mainly because of getenv
93+
# C4267: The compiler detected a conversion from size_t to a smaller type.
94+
target_compile_options(${name} PRIVATE
95+
/WX /GS /D_CRT_SECURE_NO_WARNINGS /wd4267
96+
)
9197
endif()
9298
endif()
9399
endfunction()

source/adapters/cuda/device.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urDeviceGet(ur_platform_handle_t hPlatform,
11011101

11021102
UR_APIEXPORT ur_result_t UR_APICALL urDeviceGetNativeHandle(
11031103
ur_device_handle_t hDevice, ur_native_handle_t *phNativeHandle) {
1104-
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(hDevice->get());
1104+
*phNativeHandle = reinterpret_cast<ur_native_handle_t>(
1105+
static_cast<std::uintptr_t>(hDevice->get()));
11051106
return UR_RESULT_SUCCESS;
11061107
}
11071108

source/adapters/cuda/image.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ urToCudaImageChannelFormat(ur_image_channel_type_t image_channel_type,
146146
std::make_pair(image_channel_type, num_channels));
147147
cuda_format = cuda_format_and_size.first;
148148
pixel_size_bytes = cuda_format_and_size.second;
149-
} catch (std::out_of_range &e) {
149+
} catch (const std::out_of_range &) {
150150
return UR_RESULT_ERROR_IMAGE_FORMAT_NOT_SUPPORTED;
151151
}
152152
}
@@ -276,7 +276,7 @@ ur_result_t urTextureCreate(ur_sampler_handle_t hSampler,
276276
ImageTexDesc.mipmapFilterMode = MipFilterMode;
277277
ImageTexDesc.maxMipmapLevelClamp = hSampler->MaxMipmapLevelClamp;
278278
ImageTexDesc.minMipmapLevelClamp = hSampler->MinMipmapLevelClamp;
279-
ImageTexDesc.maxAnisotropy = hSampler->MaxAnisotropy;
279+
ImageTexDesc.maxAnisotropy = static_cast<unsigned>(hSampler->MaxAnisotropy);
280280

281281
// The address modes can interfere with other dimensionsenqueueEventsWait
282282
// e.g. 1D texture sampling can be interfered with when setting other

source/adapters/cuda/program.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ ur_result_t ur_program_handle_t_::buildProgram(const char *BuildOptions) {
141141
getMaxRegistersJitOptionValue(this->BuildOptions, MaxRegs);
142142
if (Valid) {
143143
Options.push_back(CU_JIT_MAX_REGISTERS);
144-
OptionVals.push_back(reinterpret_cast<void *>(MaxRegs));
144+
OptionVals.push_back(
145+
reinterpret_cast<void *>(static_cast<std::uintptr_t>(MaxRegs)));
145146
}
146147
}
147148

source/adapters/cuda/sampler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ urSamplerCreate(ur_context_handle_t hContext, const ur_sampler_desc_t *pDesc,
1818
new ur_sampler_handle_t_(hContext)};
1919

2020
if (pDesc->stype == UR_STRUCTURE_TYPE_SAMPLER_DESC) {
21-
Sampler->Props |= pDesc->normalizedCoords;
21+
Sampler->Props |= static_cast<uint32_t>(pDesc->normalizedCoords);
2222
Sampler->Props |= pDesc->filterMode << 1;
2323
Sampler->Props |= pDesc->addressingMode << 2;
2424
} else {

source/adapters/hip/enqueue.cpp

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,9 @@
1515
#include "memory.hpp"
1616
#include "queue.hpp"
1717

18-
namespace {
18+
extern size_t imageElementByteSize(hipArray_Format ArrayFormat);
1919

20-
static size_t imageElementByteSize(hipArray_Format ArrayFormat) {
21-
switch (ArrayFormat) {
22-
case HIP_AD_FORMAT_UNSIGNED_INT8:
23-
case HIP_AD_FORMAT_SIGNED_INT8:
24-
return 1;
25-
case HIP_AD_FORMAT_UNSIGNED_INT16:
26-
case HIP_AD_FORMAT_SIGNED_INT16:
27-
case HIP_AD_FORMAT_HALF:
28-
return 2;
29-
case HIP_AD_FORMAT_UNSIGNED_INT32:
30-
case HIP_AD_FORMAT_SIGNED_INT32:
31-
case HIP_AD_FORMAT_FLOAT:
32-
return 4;
33-
default:
34-
detail::ur::die("Invalid image format.");
35-
}
36-
return 0;
37-
}
20+
namespace {
3821

3922
ur_result_t enqueueEventsWait(ur_queue_handle_t, hipStream_t Stream,
4023
uint32_t NumEventsInWaitList,

source/adapters/hip/memory.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313
#include <cassert>
1414
#include <ur_util.hpp>
1515

16-
namespace {
17-
18-
size_t GetHipFormatPixelSize(hipArray_Format Format) {
19-
switch (Format) {
16+
size_t imageElementByteSize(hipArray_Format ArrayFormat) {
17+
switch (ArrayFormat) {
2018
case HIP_AD_FORMAT_UNSIGNED_INT8:
2119
case HIP_AD_FORMAT_SIGNED_INT8:
2220
return 1;
@@ -31,10 +29,9 @@ size_t GetHipFormatPixelSize(hipArray_Format Format) {
3129
default:
3230
detail::ur::die("Invalid HIP format specifier");
3331
}
32+
return 0;
3433
}
3534

36-
} // namespace
37-
3835
/// Decreases the reference count of the Mem object.
3936
/// If this is zero, calls the relevant HIP Free function
4037
/// \return UR_RESULT_SUCCESS unless deallocation error
@@ -245,7 +242,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemGetInfo(ur_mem_handle_t hMemory,
245242
UR_CHECK_ERROR(
246243
hipArray3DGetDescriptor(&ArrayDescriptor, Mem.getArray(Device)));
247244
const auto PixelSizeBytes =
248-
GetHipFormatPixelSize(ArrayDescriptor.Format) *
245+
imageElementByteSize(ArrayDescriptor.Format) *
249246
ArrayDescriptor.NumChannels;
250247
const auto ImageSizeBytes =
251248
PixelSizeBytes *
@@ -405,25 +402,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
405402
}
406403
};
407404

408-
const auto hipFormatToElementSize =
409-
[](hipArray_Format HipFormat) -> size_t {
410-
switch (HipFormat) {
411-
case HIP_AD_FORMAT_UNSIGNED_INT8:
412-
case HIP_AD_FORMAT_SIGNED_INT8:
413-
return 1;
414-
case HIP_AD_FORMAT_UNSIGNED_INT16:
415-
case HIP_AD_FORMAT_SIGNED_INT16:
416-
case HIP_AD_FORMAT_HALF:
417-
return 2;
418-
case HIP_AD_FORMAT_UNSIGNED_INT32:
419-
case HIP_AD_FORMAT_SIGNED_INT32:
420-
case HIP_AD_FORMAT_FLOAT:
421-
return 4;
422-
default:
423-
detail::ur::die("Invalid Hip format specified.");
424-
}
425-
};
426-
427405
switch (propName) {
428406
case UR_IMAGE_INFO_FORMAT:
429407
return ReturnValue(ur_image_format_t{UR_IMAGE_CHANNEL_ORDER_RGBA,
@@ -435,7 +413,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory,
435413
case UR_IMAGE_INFO_DEPTH:
436414
return ReturnValue(ArrayInfo.Depth);
437415
case UR_IMAGE_INFO_ELEMENT_SIZE:
438-
return ReturnValue(hipFormatToElementSize(ArrayInfo.Format));
416+
return ReturnValue(imageElementByteSize(ArrayInfo.Format));
439417
case UR_IMAGE_INFO_ROW_PITCH:
440418
case UR_IMAGE_INFO_SLICE_PITCH:
441419
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;

source/adapters/level_zero/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ add_ur_adapter(${TARGET_NAME}
124124

125125
# TODO: fix level_zero adapter conversion warnings
126126
target_compile_options(${TARGET_NAME} PRIVATE
127-
$<$<CXX_COMPILER_ID:MSVC>:/wd4267 /wd4805 /wd4244 /D_CRT_SECURE_NO_WARNINGS>
127+
$<$<CXX_COMPILER_ID:MSVC>:/wd4805 /wd4244>
128128
)
129129

130130
set_target_properties(${TARGET_NAME} PROPERTIES

source/adapters/native_cpu/context.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
#include "common.hpp"
1818
#include "context.hpp"
1919

20-
UR_APIEXPORT ur_result_t UR_APICALL
21-
urContextCreate(uint32_t DeviceCount, const ur_device_handle_t *phDevices,
22-
const ur_context_properties_t *pProperties,
23-
ur_context_handle_t *phContext) {
20+
UR_APIEXPORT ur_result_t UR_APICALL urContextCreate(
21+
[[maybe_unused]] uint32_t DeviceCount, const ur_device_handle_t *phDevices,
22+
const ur_context_properties_t *pProperties,
23+
ur_context_handle_t *phContext) {
2424
std::ignore = pProperties;
2525
assert(DeviceCount == 1);
2626

0 commit comments

Comments
 (0)