[libc-commits] [libc] [libc] Clean up GPU math implementations (PR #83133)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Tue Feb 27 08:01:58 PST 2024
================
@@ -0,0 +1,16 @@
+//===-- Implementation of the GPU trunc function --------------------------===//
+//
+// 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 "src/math/trunc.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(double, trunc, (double x)) { return __builtin_trunc(x); }
----------------
jhuber6 wrote:
Interested in @lntue's perspective on a lot of these built-ins as well. Most of what's special about these built-ins is that they use more hardware specific instructions, though a lot of the time this comes at the cost of precision. We could possibly wrap some of the hardware specific stuff in utility functions kind of like FMA (though that's hardly unsupported these days) and try to have a more generic implementation if we really want everything to be correctly rounded even on the GPU.
https://github.com/llvm/llvm-project/pull/83133
More information about the libc-commits
mailing list