[libc-commits] [PATCH] D152603: [libc] Add math functions to AMD/NVPTX libm

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Wed Jun 21 11:10:39 PDT 2023


sivachandra added inline comments.


================
Comment at: libc/src/math/gpu/cos.cpp:14
 
-extern "C" {
-double __nv_sin(double);
-}
+LLVM_LIBC_FUNCTION(double, cos, (double x)) { return __builtin_cos(x); }
 
----------------
I am not sure the GPUs would have instructions to do trignometric functions.


================
Comment at: libc/src/math/gpu/exp2f.cpp:14
 
-extern "C" {
-double __nv_sin(double);
-}
+LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { return __builtin_exp2f(x); }
 
----------------
AMD gpus seem to be having `exp2f`. Can we assume other GPUs also have them? Even if they do have, what guarantees and promises they come with? The reason I am asking is to understand how we should set up tests for them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152603



More information about the libc-commits mailing list