[libclc] libclc: fix convert with half (PR #99481)

Romaric Jodin via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 18 05:26:35 PDT 2024


https://github.com/rjodinchr created https://github.com/llvm/llvm-project/pull/99481

Fix following update of libclc introducing more fp16 support: https://github.com/llvm/llvm-project/commit/7e6a73959ae97b1f9476a90290a492ba90cb950d

>From 63f5f5a57c55dce7c2cdcbddff8f80817104f48e Mon Sep 17 00:00:00 2001
From: Romaric Jodin <rjodin at chromium.org>
Date: Thu, 18 Jul 2024 14:25:05 +0200
Subject: [PATCH] libclc: fix convert with half

Fix following update of libclc introducing more fp16 support:
https://github.com/llvm/llvm-project/commit/7e6a73959ae97b1f9476a90290a492ba90cb950d
---
 libclc/generic/include/clc/convert.h | 1 +
 libclc/generic/lib/gen_convert.py    | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libclc/generic/include/clc/convert.h b/libclc/generic/include/clc/convert.h
index db7bb0402491e..8219df47ad2c6 100644
--- a/libclc/generic/include/clc/convert.h
+++ b/libclc/generic/include/clc/convert.h
@@ -62,6 +62,7 @@
 #define _CLC_VECTOR_CONVERT_TO(SUFFIX)                                         \
   _CLC_VECTOR_CONVERT_TO1(SUFFIX)                                              \
   _CLC_VECTOR_CONVERT_FROM(half, SUFFIX)
+#else
 #define _CLC_VECTOR_CONVERT_TO(SUFFIX) \
   _CLC_VECTOR_CONVERT_TO1(SUFFIX)
 #endif
diff --git a/libclc/generic/lib/gen_convert.py b/libclc/generic/lib/gen_convert.py
index bd36faa4e9197..41bd8cebf88b6 100644
--- a/libclc/generic/lib/gen_convert.py
+++ b/libclc/generic/lib/gen_convert.py
@@ -142,7 +142,10 @@ def conditional_guard(src, dst):
         float64_count = float64_count + 1
     elif dst in float16_types:
         float16_count = float16_count + 1
-    if float64_count > 0:
+    if float64_count > 0 and float16_count > 0:
+        print("#if defined(cl_khr_fp16) && defined(cl_khr_fp64)")
+        return True
+    elif float64_count > 0:
         # In embedded profile, if cl_khr_fp64 is supported cles_khr_int64 has to be
         print("#ifdef cl_khr_fp64")
         return True



More information about the cfe-commits mailing list