[libc-commits] [PATCH] D152575: Added modf for NVPTX and AMDGPU targets to implement 'libmgpu.a' for math on the GPU

Anton Rydahl via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Jun 12 10:35:40 PDT 2023


AntonRydahl updated this revision to Diff 530585.
AntonRydahl added a comment.

#Updating D152575 <https://reviews.llvm.org/D152575>: Added modf for NVPTX and AMDGPU targets to implement 'libmgpu.a' for math on the GPU

The OpenMP specifics have been removed, the namespace changed to `internal`, and `git clang-format` has been run.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152575/new/

https://reviews.llvm.org/D152575

Files:
  libc/src/math/gpu/CMakeLists.txt
  libc/src/math/gpu/amdgpu/amdgpu.h


Index: libc/src/math/gpu/amdgpu/amdgpu.h
===================================================================
--- libc/src/math/gpu/amdgpu/amdgpu.h
+++ libc/src/math/gpu/amdgpu/amdgpu.h
@@ -15,23 +15,15 @@
 #include "src/__support/macros/attributes.h"
 
 namespace __llvm_libc {
-namespace vendor {
+namespace internal {
 
 LIBC_INLINE double modf(double x, double *iptr) {
-  double tmp;
-#ifdef __OPENMP_AMDGCN__
-#pragma omp allocate(tmp) allocator(omp_thread_mem_alloc)
-#endif
-  double r =
-      __ocml_modf_f64(x, (__attribute__((address_space(5))) double *)&tmp);
-  *iptr = tmp;
-
-  return r;
+  return __ocml_modf_f64(x, iptr);
 }
 
 LIBC_INLINE double sin(double x) { return __ocml_sin_f64(x); }
 
-} // namespace vendor
+} // namespace internal
 } // namespace __llvm_libc
 
 #endif // LLVM_LIBC_SRC_MATH_GPU_AMDGPU_H
Index: libc/src/math/gpu/CMakeLists.txt
===================================================================
--- libc/src/math/gpu/CMakeLists.txt
+++ libc/src/math/gpu/CMakeLists.txt
@@ -44,10 +44,7 @@
   HDRS
     ../modf.h
   COMPILE_OPTIONS
-    # FIXME: We need a way to pass the flag to only the NVTPX / AMDGPU build.
-    # This shouldn't cause issues because we only link in needed symbols, but it
-    # will link in identity metadata from both libraries.
     -Wno-linker-warnings
     ${bitcode_link_flags}
     -O2
-)
\ No newline at end of file
+)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152575.530585.patch
Type: text/x-patch
Size: 1390 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230612/d6fb6d1b/attachment.bin>


More information about the libc-commits mailing list