From 21d8d08a31ed8ecd9919fc08c0bd3aeaea0571da Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Tue, 12 Nov 2024 05:51:45 -0800 Subject: [PATCH 1/5] [SYCL] Add -f-offload-fp32-prec-[div/sqrt] FE option handling in JIT It matches -cl-fp32-correctly-rounded-divide-[div/sqrt] option for OpenCL and -ze-fp32-correctly-rounded-divide-[div/sqrt] for L0. Signed-off-by: Sidorov, Dmitry --- source/adapters/cuda/platform.cpp | 5 +++++ source/adapters/hip/platform.cpp | 5 +++++ source/adapters/level_zero/platform.cpp | 8 ++++++++ source/adapters/opencl/platform.cpp | 8 ++++++++ 4 files changed, 26 insertions(+) diff --git a/source/adapters/cuda/platform.cpp b/source/adapters/cuda/platform.cpp index 218cf9b0db..ef36381b58 100644 --- a/source/adapters/cuda/platform.cpp +++ b/source/adapters/cuda/platform.cpp @@ -168,5 +168,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetBackendOption( *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } + if (pFrontendOption == "-foffload-fp32-prec-div" || + pFrontendOption == "-foffload-fp32-prec-sqrt") { + *ppPlatformOption = ""; + return UR_RESULT_SUCCESS; + } return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/hip/platform.cpp b/source/adapters/hip/platform.cpp index 23aee0000b..2587baa9a7 100644 --- a/source/adapters/hip/platform.cpp +++ b/source/adapters/hip/platform.cpp @@ -154,5 +154,10 @@ urPlatformGetBackendOption(ur_platform_handle_t, const char *pFrontendOption, *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } + if (pFrontendOption == "-foffload-fp32-prec-div" || + pFrontendOption == "-foffload-fp32-prec-sqrt") { + *ppPlatformOption = ""; + return UR_RESULT_SUCCESS; + } return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 721db3c359..8cfa6b3b4d 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -196,6 +196,14 @@ ur_result_t urPlatformGetBackendOption( *PlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } + if (pFrontendOption == "-foffload-fp32-prec-div") { + *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-div"; + return UR_RESULT_SUCCESS; + } + if (pFrontendOption == "-foffload-fp32-prec-sqrt") { + *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; + return UR_RESULT_SUCCESS; + } return UR_RESULT_ERROR_INVALID_VALUE; } diff --git a/source/adapters/opencl/platform.cpp b/source/adapters/opencl/platform.cpp index 218a5e7f00..f80364cc42 100644 --- a/source/adapters/opencl/platform.cpp +++ b/source/adapters/opencl/platform.cpp @@ -144,5 +144,13 @@ urPlatformGetBackendOption(ur_platform_handle_t, const char *pFrontendOption, *ppPlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } + if (pFrontendOption == "-foffload-fp32-prec-div") { + *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-div"; + return UR_RESULT_SUCCESS; + } + if (pFrontendOption == "-foffload-fp32-prec-sqrt") { + *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-sqrt"; + return UR_RESULT_SUCCESS; + } return UR_RESULT_ERROR_INVALID_VALUE; } From 1f23083d735d94ec596e149d47cd1c28f21a001c Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Wed, 13 Nov 2024 08:56:49 -0800 Subject: [PATCH 2/5] formt Signed-off-by: Sidorov, Dmitry --- source/adapters/level_zero/platform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 8cfa6b3b4d..ed92f0284e 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -198,7 +198,7 @@ ur_result_t urPlatformGetBackendOption( } if (pFrontendOption == "-foffload-fp32-prec-div") { *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-div"; - return UR_RESULT_SUCCESS; + return UR_RESULT_SUCCESS; } if (pFrontendOption == "-foffload-fp32-prec-sqrt") { *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; From ab1e5dfde9b25ea36f2d3187f52b728976ab1efa Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Wed, 13 Nov 2024 08:57:49 -0800 Subject: [PATCH 3/5] fix build Signed-off-by: Sidorov, Dmitry --- source/adapters/level_zero/platform.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index ed92f0284e..894c0efa40 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -196,12 +196,12 @@ ur_result_t urPlatformGetBackendOption( *PlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-div") { - *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-div"; + if (FrontendOption == "-foffload-fp32-prec-div") { + *PlatformOption = "-ze-fp32-correctly-rounded-divide-div"; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-sqrt") { - *ppPlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; + if (FrontendOption == "-foffload-fp32-prec-sqrt") { + *PlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; return UR_RESULT_SUCCESS; } return UR_RESULT_ERROR_INVALID_VALUE; From 61aa63eed5c182c3baa0588155cb592db35f675e Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Thu, 14 Nov 2024 04:09:17 -0800 Subject: [PATCH 4/5] fix build Signed-off-by: Sidorov, Dmitry --- source/adapters/cuda/platform.cpp | 4 ++-- source/adapters/hip/platform.cpp | 4 ++-- source/adapters/level_zero/platform.cpp | 4 ++-- source/adapters/opencl/platform.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/adapters/cuda/platform.cpp b/source/adapters/cuda/platform.cpp index ef36381b58..7ce0bba9e7 100644 --- a/source/adapters/cuda/platform.cpp +++ b/source/adapters/cuda/platform.cpp @@ -168,8 +168,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urPlatformGetBackendOption( *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-div" || - pFrontendOption == "-foffload-fp32-prec-sqrt") { + if (pFrontendOption == "-foffload-fp32-prec-div"sv || + pFrontendOption == "-foffload-fp32-prec-sqrt"sv) { *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/hip/platform.cpp b/source/adapters/hip/platform.cpp index 2587baa9a7..007889f138 100644 --- a/source/adapters/hip/platform.cpp +++ b/source/adapters/hip/platform.cpp @@ -154,8 +154,8 @@ urPlatformGetBackendOption(ur_platform_handle_t, const char *pFrontendOption, *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-div" || - pFrontendOption == "-foffload-fp32-prec-sqrt") { + if (pFrontendOption == "-foffload-fp32-prec-div"sv || + pFrontendOption == "-foffload-fp32-prec-sqrt"sv) { *ppPlatformOption = ""; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index 894c0efa40..ba47e4b691 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -196,11 +196,11 @@ ur_result_t urPlatformGetBackendOption( *PlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } - if (FrontendOption == "-foffload-fp32-prec-div") { + if (FrontendOption == "-foffload-fp32-prec-div"sv) { *PlatformOption = "-ze-fp32-correctly-rounded-divide-div"; return UR_RESULT_SUCCESS; } - if (FrontendOption == "-foffload-fp32-prec-sqrt") { + if (FrontendOption == "-foffload-fp32-prec-sqrt"sv) { *PlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/platform.cpp b/source/adapters/opencl/platform.cpp index f80364cc42..88dd23611d 100644 --- a/source/adapters/opencl/platform.cpp +++ b/source/adapters/opencl/platform.cpp @@ -144,11 +144,11 @@ urPlatformGetBackendOption(ur_platform_handle_t, const char *pFrontendOption, *ppPlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-div") { + if (pFrontendOption == "-foffload-fp32-prec-div"sv) { *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-div"; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-sqrt") { + if (pFrontendOption == "-foffload-fp32-prec-sqrt"sv) { *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-sqrt"; return UR_RESULT_SUCCESS; } From 8dc3d2b4906f2fc34b4117a92fced839c449ae0b Mon Sep 17 00:00:00 2001 From: "Sidorov, Dmitry" Date: Fri, 15 Nov 2024 04:10:17 -0800 Subject: [PATCH 5/5] fix logical error Signed-off-by: Sidorov, Dmitry --- source/adapters/level_zero/platform.cpp | 7 ++----- source/adapters/opencl/platform.cpp | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/source/adapters/level_zero/platform.cpp b/source/adapters/level_zero/platform.cpp index ba47e4b691..4655229baf 100644 --- a/source/adapters/level_zero/platform.cpp +++ b/source/adapters/level_zero/platform.cpp @@ -196,11 +196,8 @@ ur_result_t urPlatformGetBackendOption( *PlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } - if (FrontendOption == "-foffload-fp32-prec-div"sv) { - *PlatformOption = "-ze-fp32-correctly-rounded-divide-div"; - return UR_RESULT_SUCCESS; - } - if (FrontendOption == "-foffload-fp32-prec-sqrt"sv) { + if (FrontendOption == "-foffload-fp32-prec-div"sv || + FrontendOption == "-foffload-fp32-prec-sqrt"sv) { *PlatformOption = "-ze-fp32-correctly-rounded-divide-sqrt"; return UR_RESULT_SUCCESS; } diff --git a/source/adapters/opencl/platform.cpp b/source/adapters/opencl/platform.cpp index 88dd23611d..b6d3a77cee 100644 --- a/source/adapters/opencl/platform.cpp +++ b/source/adapters/opencl/platform.cpp @@ -144,11 +144,8 @@ urPlatformGetBackendOption(ur_platform_handle_t, const char *pFrontendOption, *ppPlatformOption = "-igc_opts 'PartitionUnit=1,SubroutineThreshold=50000'"; return UR_RESULT_SUCCESS; } - if (pFrontendOption == "-foffload-fp32-prec-div"sv) { - *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-div"; - return UR_RESULT_SUCCESS; - } - if (pFrontendOption == "-foffload-fp32-prec-sqrt"sv) { + if (pFrontendOption == "-foffload-fp32-prec-div"sv || + pFrontendOption == "-foffload-fp32-prec-sqrt"sv) { *ppPlatformOption = "-cl-fp32-correctly-rounded-divide-sqrt"; return UR_RESULT_SUCCESS; }