From ec8f19215f5d02932c70a6484e99ced4ec85e990 Mon Sep 17 00:00:00 2001 From: "Yuan, Pengxin" Date: Fri, 8 Mar 2024 04:23:57 +0000 Subject: [PATCH] fix windows build issue with numeric_limits --- sdk/src/utils/ze_utils.h | 4 ++-- tools/oneprof/prof_options.h | 4 ++-- utils/ze_utils.h | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sdk/src/utils/ze_utils.h b/sdk/src/utils/ze_utils.h index dfa11f3..fce7711 100644 --- a/sdk/src/utils/ze_utils.h +++ b/sdk/src/utils/ze_utils.h @@ -510,7 +510,7 @@ inline uint64_t GetDeviceTimestampMask(ze_device_handle_t device) { o_api_string.c_str()); }; PTI_ASSERT(status == ZE_RESULT_SUCCESS); - return ((props.kernelTimestampValidBits == 64) ? std::numeric_limits::max() + return ((props.kernelTimestampValidBits == 64) ? (std::numeric_limits::max)() : ((1ull << props.kernelTimestampValidBits) - 1ull)); } @@ -533,7 +533,7 @@ inline uint64_t GetMetricTimestampMask(ze_device_handle_t device) { if ((devicemask == 0x5600) || (devicemask == 0x4F00) || (devicemask == 0x0B00)) { return (1ull << (props.kernelTimestampValidBits - 1)) - 1ull; } else { - return ((props.kernelTimestampValidBits == 64) ? std::numeric_limits::max() + return ((props.kernelTimestampValidBits == 64) ? (std::numeric_limits::max)() : ((1ull << props.kernelTimestampValidBits) - 1ull)); } #endif diff --git a/tools/oneprof/prof_options.h b/tools/oneprof/prof_options.h index de3457d..6426dc6 100644 --- a/tools/oneprof/prof_options.h +++ b/tools/oneprof/prof_options.h @@ -60,7 +60,7 @@ class ProfOptions { } std::string GetLogFileName( - uint32_t pid = std::numeric_limits::max()) const { + uint32_t pid = (std::numeric_limits::max)()) const { if (log_file_.empty()) { return std::string(); } @@ -74,7 +74,7 @@ class ProfOptions { result << log_file_.substr(0, pos); } - if (pid == std::numeric_limits::max()) { + if (pid == (std::numeric_limits::max)()) { pid = utils::GetPid(); } result << "." + std::to_string(pid); diff --git a/utils/ze_utils.h b/utils/ze_utils.h index 50f983b..dd66f77 100644 --- a/utils/ze_utils.h +++ b/utils/ze_utils.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -356,7 +357,7 @@ inline uint64_t GetDeviceTimestampMask(ze_device_handle_t device) { ze_device_properties_t props{ZE_STRUCTURE_TYPE_DEVICE_PROPERTIES_1_2, }; ze_result_t status = zeDeviceGetProperties(device, &props); PTI_ASSERT(status == ZE_RESULT_SUCCESS); - return ((props.kernelTimestampValidBits == 64) ? std::numeric_limits::max() + return ((props.kernelTimestampValidBits == 64) ? (std::numeric_limits::max)() : ((1ull << props.kernelTimestampValidBits) - 1ull)); } @@ -372,7 +373,7 @@ inline uint64_t GetMetricTimestampMask(ze_device_handle_t device) { return (1ull << (props.kernelTimestampValidBits - 1)) - 1ull; } else { - return ((props.kernelTimestampValidBits == 64) ? std::numeric_limits::max() + return ((props.kernelTimestampValidBits == 64) ? (std::numeric_limits::max)() : ((1ull << props.kernelTimestampValidBits) - 1ull)); } #endif