[libclc] libclc: Use elementwise exp for exp functions (PR #185626)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 10 04:56:42 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
For amdgpu use the exp intrinisc. Really, this should be
the default generic implementation. But we're stuck in a
mess where essentially nothing works. All of the exp
intrinsics work for AMDGPU, but aren't really implemented
for spirv or nvptx. Ideally the intrinsic and/or libm call
would be the default implementation.
---
Full diff: https://github.com/llvm/llvm-project/pull/185626.diff
4 Files Affected:
- (modified) libclc/clc/lib/amdgpu/CMakeLists.txt (+3)
- (added) libclc/clc/lib/amdgpu/math/clc_exp.cl (+15)
- (added) libclc/clc/lib/amdgpu/math/clc_exp10.cl (+15)
- (added) libclc/clc/lib/amdgpu/math/clc_exp2.cl (+15)
``````````diff
diff --git a/libclc/clc/lib/amdgpu/CMakeLists.txt b/libclc/clc/lib/amdgpu/CMakeLists.txt
index cfed021d8fc26..f593bc6fdd8cf 100644
--- a/libclc/clc/lib/amdgpu/CMakeLists.txt
+++ b/libclc/clc/lib/amdgpu/CMakeLists.txt
@@ -1,6 +1,9 @@
libclc_configure_source_list(CLC_AMDGPU_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}
address_space/qualifier.cl
+ math/clc_exp.cl
+ math/clc_exp2.cl
+ math/clc_exp10.cl
math/clc_half_exp.cl
math/clc_half_exp2.cl
math/clc_half_exp10.cl
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp.cl b/libclc/clc/lib/amdgpu/math/clc_exp.cl
new file mode 100644
index 0000000000000..33c47bf5037e0
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <clc/internal/clc.h>
+
+#define __CLC_FUNCTION __clc_exp
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp10.cl b/libclc/clc/lib/amdgpu/math/clc_exp10.cl
new file mode 100644
index 0000000000000..fcc739fbb7fbd
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp10.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <clc/internal/clc.h>
+
+#define __CLC_FUNCTION __clc_exp10
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp10
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>
diff --git a/libclc/clc/lib/amdgpu/math/clc_exp2.cl b/libclc/clc/lib/amdgpu/math/clc_exp2.cl
new file mode 100644
index 0000000000000..ec65b93b6b52e
--- /dev/null
+++ b/libclc/clc/lib/amdgpu/math/clc_exp2.cl
@@ -0,0 +1,15 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <clc/internal/clc.h>
+
+#define __CLC_FUNCTION __clc_exp2
+#define __CLC_IMPL_FUNCTION(x) __builtin_elementwise_exp2
+#define __CLC_BODY <clc/shared/unary_def.inc>
+
+#include <clc/math/gentype.inc>
``````````
</details>
https://github.com/llvm/llvm-project/pull/185626
More information about the cfe-commits
mailing list