[libc-commits] [PATCH] D156263: Populated libmgpu.a with both built-in, HIP Math, and CUDA Math functions and changed the CMake logic to allow selecting different subsets of the math functions to be included in the archive.

Anton Rydahl via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jul 25 14:26:56 PDT 2023


AntonRydahl created this revision.
AntonRydahl added reviewers: jdoerfert, jhuber6, elmcdonough, sivachandra.
Herald added subscribers: libc-commits, mattd, asavonic, kerbowa, yaxunl, jvesely.
Herald added projects: libc-project, All.
AntonRydahl requested review of this revision.

I made this patch to compare the generic implementations from LIBC with builti-in functions, HIP Math, and CUDA math. I think this could potentially go into LIBC. Compared to the previous patches we 
have iterated over, I have added some very basic CMake logic to be able to prioritize including vendor wrappers, built-in wrappers, or generic functions in the archive. With the CMake flag 
`LIBC_GPU_BUILTIN_MATH` one can select whether built-in or generic functions have higher priority. This is a very large patch, so please let me know if it should be split into smaller patches, and if 
some things should be renamed, for instance the flag `LIBC_GPU_BUILTIN_MATH`.

We previously discussed whether long double functions should be included or not. I have not included them, but I have added some functions that return `long` or `long long` since I found that the CUDA 
math library has support for those functions, for instance `__nv_llrint` and `__nv_llround`.

Ideally, I think we should still aim at being able to select between functions on an individual level based on performance and accuracy analysis, but this patch at least allows for collecting 
measurements for making such an analysis.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156263

Files:
  libc/config/gpu/entrypoints.txt
  libc/src/math/CMakeLists.txt
  libc/src/math/acos.h
  libc/src/math/acosh.h
  libc/src/math/asin.h
  libc/src/math/asinh.h
  libc/src/math/atan.h
  libc/src/math/atan2.h
  libc/src/math/atan2f.h
  libc/src/math/atanh.h
  libc/src/math/cosh.h
  libc/src/math/erf.h
  libc/src/math/exp.h
  libc/src/math/exp10.h
  libc/src/math/exp2.h
  libc/src/math/expm1.h
  libc/src/math/gpu/CMakeLists.txt
  libc/src/math/gpu/acos.cpp
  libc/src/math/gpu/acosf.cpp
  libc/src/math/gpu/acosh.cpp
  libc/src/math/gpu/acoshf.cpp
  libc/src/math/gpu/asin.cpp
  libc/src/math/gpu/asinf.cpp
  libc/src/math/gpu/asinh.cpp
  libc/src/math/gpu/asinhf.cpp
  libc/src/math/gpu/atan.cpp
  libc/src/math/gpu/atan2.cpp
  libc/src/math/gpu/atan2f.cpp
  libc/src/math/gpu/atanf.cpp
  libc/src/math/gpu/atanh.cpp
  libc/src/math/gpu/atanhf.cpp
  libc/src/math/gpu/ceil.cpp
  libc/src/math/gpu/ceilf.cpp
  libc/src/math/gpu/copysign.cpp
  libc/src/math/gpu/copysignf.cpp
  libc/src/math/gpu/cos.cpp
  libc/src/math/gpu/cosf.cpp
  libc/src/math/gpu/cosh.cpp
  libc/src/math/gpu/coshf.cpp
  libc/src/math/gpu/erf.cpp
  libc/src/math/gpu/erff.cpp
  libc/src/math/gpu/exp.cpp
  libc/src/math/gpu/exp2.cpp
  libc/src/math/gpu/exp2f.cpp
  libc/src/math/gpu/expf.cpp
  libc/src/math/gpu/expm1.cpp
  libc/src/math/gpu/expm1f.cpp
  libc/src/math/gpu/fabs.cpp
  libc/src/math/gpu/fabsf.cpp
  libc/src/math/gpu/fdim.cpp
  libc/src/math/gpu/fdimf.cpp
  libc/src/math/gpu/floor.cpp
  libc/src/math/gpu/floorf.cpp
  libc/src/math/gpu/fma.cpp
  libc/src/math/gpu/fmaf.cpp
  libc/src/math/gpu/fmax.cpp
  libc/src/math/gpu/fmaxf.cpp
  libc/src/math/gpu/fmin.cpp
  libc/src/math/gpu/fminf.cpp
  libc/src/math/gpu/fmod.cpp
  libc/src/math/gpu/fmodf.cpp
  libc/src/math/gpu/frexp.cpp
  libc/src/math/gpu/frexpf.cpp
  libc/src/math/gpu/hypot.cpp
  libc/src/math/gpu/hypotf.cpp
  libc/src/math/gpu/ilogb.cpp
  libc/src/math/gpu/ilogbf.cpp
  libc/src/math/gpu/ldexp.cpp
  libc/src/math/gpu/ldexpf.cpp
  libc/src/math/gpu/llrint.cpp
  libc/src/math/gpu/llrintf.cpp
  libc/src/math/gpu/llround.cpp
  libc/src/math/gpu/llroundf.cpp
  libc/src/math/gpu/log.cpp
  libc/src/math/gpu/log10.cpp
  libc/src/math/gpu/log10f.cpp
  libc/src/math/gpu/log1p.cpp
  libc/src/math/gpu/log1pf.cpp
  libc/src/math/gpu/log2.cpp
  libc/src/math/gpu/log2f.cpp
  libc/src/math/gpu/logb.cpp
  libc/src/math/gpu/logbf.cpp
  libc/src/math/gpu/logf.cpp
  libc/src/math/gpu/lrint.cpp
  libc/src/math/gpu/lrintf.cpp
  libc/src/math/gpu/lround.cpp
  libc/src/math/gpu/lroundf.cpp
  libc/src/math/gpu/modf.cpp
  libc/src/math/gpu/modff.cpp
  libc/src/math/gpu/nearbyint.cpp
  libc/src/math/gpu/nearbyintf.cpp
  libc/src/math/gpu/nextafter.cpp
  libc/src/math/gpu/nextafterf.cpp
  libc/src/math/gpu/pow.cpp
  libc/src/math/gpu/powf.cpp
  libc/src/math/gpu/remainder.cpp
  libc/src/math/gpu/remainderf.cpp
  libc/src/math/gpu/remquo.cpp
  libc/src/math/gpu/remquof.cpp
  libc/src/math/gpu/rint.cpp
  libc/src/math/gpu/rintf.cpp
  libc/src/math/gpu/roundl.cpp
  libc/src/math/gpu/scalbn.cpp
  libc/src/math/gpu/scalbnf.cpp
  libc/src/math/gpu/sin.cpp
  libc/src/math/gpu/sinf.cpp
  libc/src/math/gpu/sinh.cpp
  libc/src/math/gpu/sinhf.cpp
  libc/src/math/gpu/sqrt.cpp
  libc/src/math/gpu/sqrtf.cpp
  libc/src/math/gpu/tan.cpp
  libc/src/math/gpu/tanf.cpp
  libc/src/math/gpu/tanh.cpp
  libc/src/math/gpu/tanhf.cpp
  libc/src/math/gpu/tgamma.cpp
  libc/src/math/gpu/tgammaf.cpp
  libc/src/math/gpu/trunc.cpp
  libc/src/math/gpu/truncf.cpp
  libc/src/math/gpu/vendor/CMakeLists.txt
  libc/src/math/gpu/vendor/acos.cpp
  libc/src/math/gpu/vendor/acosf.cpp
  libc/src/math/gpu/vendor/acosh.cpp
  libc/src/math/gpu/vendor/acoshf.cpp
  libc/src/math/gpu/vendor/amdgpu/amdgpu.h
  libc/src/math/gpu/vendor/amdgpu/declarations.h
  libc/src/math/gpu/vendor/asin.cpp
  libc/src/math/gpu/vendor/asinf.cpp
  libc/src/math/gpu/vendor/asinh.cpp
  libc/src/math/gpu/vendor/asinhf.cpp
  libc/src/math/gpu/vendor/atan.cpp
  libc/src/math/gpu/vendor/atan2.cpp
  libc/src/math/gpu/vendor/atan2f.cpp
  libc/src/math/gpu/vendor/atanf.cpp
  libc/src/math/gpu/vendor/atanh.cpp
  libc/src/math/gpu/vendor/atanhf.cpp
  libc/src/math/gpu/vendor/ceil.cpp
  libc/src/math/gpu/vendor/ceilf.cpp
  libc/src/math/gpu/vendor/copysign.cpp
  libc/src/math/gpu/vendor/copysignf.cpp
  libc/src/math/gpu/vendor/cos.cpp
  libc/src/math/gpu/vendor/cosf.cpp
  libc/src/math/gpu/vendor/cosh.cpp
  libc/src/math/gpu/vendor/coshf.cpp
  libc/src/math/gpu/vendor/erf.cpp
  libc/src/math/gpu/vendor/erff.cpp
  libc/src/math/gpu/vendor/exp.cpp
  libc/src/math/gpu/vendor/exp10.cpp
  libc/src/math/gpu/vendor/exp10f.cpp
  libc/src/math/gpu/vendor/exp2.cpp
  libc/src/math/gpu/vendor/exp2f.cpp
  libc/src/math/gpu/vendor/expf.cpp
  libc/src/math/gpu/vendor/expm1.cpp
  libc/src/math/gpu/vendor/expm1f.cpp
  libc/src/math/gpu/vendor/fabs.cpp
  libc/src/math/gpu/vendor/fabsf.cpp
  libc/src/math/gpu/vendor/fdim.cpp
  libc/src/math/gpu/vendor/fdimf.cpp
  libc/src/math/gpu/vendor/floor.cpp
  libc/src/math/gpu/vendor/floorf.cpp
  libc/src/math/gpu/vendor/fma.cpp
  libc/src/math/gpu/vendor/fmaf.cpp
  libc/src/math/gpu/vendor/fmax.cpp
  libc/src/math/gpu/vendor/fmaxf.cpp
  libc/src/math/gpu/vendor/fmin.cpp
  libc/src/math/gpu/vendor/fminf.cpp
  libc/src/math/gpu/vendor/fmod.cpp
  libc/src/math/gpu/vendor/fmodf.cpp
  libc/src/math/gpu/vendor/frexp.cpp
  libc/src/math/gpu/vendor/frexpf.cpp
  libc/src/math/gpu/vendor/hypot.cpp
  libc/src/math/gpu/vendor/hypotf.cpp
  libc/src/math/gpu/vendor/ilogb.cpp
  libc/src/math/gpu/vendor/ilogbf.cpp
  libc/src/math/gpu/vendor/ldexp.cpp
  libc/src/math/gpu/vendor/ldexpf.cpp
  libc/src/math/gpu/vendor/llrint.cpp
  libc/src/math/gpu/vendor/llrintf.cpp
  libc/src/math/gpu/vendor/llround.cpp
  libc/src/math/gpu/vendor/llroundf.cpp
  libc/src/math/gpu/vendor/log.cpp
  libc/src/math/gpu/vendor/log10.cpp
  libc/src/math/gpu/vendor/log10f.cpp
  libc/src/math/gpu/vendor/log1p.cpp
  libc/src/math/gpu/vendor/log1pf.cpp
  libc/src/math/gpu/vendor/log2.cpp
  libc/src/math/gpu/vendor/log2f.cpp
  libc/src/math/gpu/vendor/logb.cpp
  libc/src/math/gpu/vendor/logbf.cpp
  libc/src/math/gpu/vendor/logf.cpp
  libc/src/math/gpu/vendor/lrint.cpp
  libc/src/math/gpu/vendor/lrintf.cpp
  libc/src/math/gpu/vendor/lround.cpp
  libc/src/math/gpu/vendor/lroundf.cpp
  libc/src/math/gpu/vendor/modf.cpp
  libc/src/math/gpu/vendor/modff.cpp
  libc/src/math/gpu/vendor/nearbyint.cpp
  libc/src/math/gpu/vendor/nearbyintf.cpp
  libc/src/math/gpu/vendor/nextafter.cpp
  libc/src/math/gpu/vendor/nextafterf.cpp
  libc/src/math/gpu/vendor/nvptx/declarations.h
  libc/src/math/gpu/vendor/nvptx/nvptx.h
  libc/src/math/gpu/vendor/pow.cpp
  libc/src/math/gpu/vendor/powf.cpp
  libc/src/math/gpu/vendor/remainder.cpp
  libc/src/math/gpu/vendor/remainderf.cpp
  libc/src/math/gpu/vendor/remquo.cpp
  libc/src/math/gpu/vendor/remquof.cpp
  libc/src/math/gpu/vendor/rint.cpp
  libc/src/math/gpu/vendor/rintf.cpp
  libc/src/math/gpu/vendor/round.cpp
  libc/src/math/gpu/vendor/roundf.cpp
  libc/src/math/gpu/vendor/scalbn.cpp
  libc/src/math/gpu/vendor/scalbnf.cpp
  libc/src/math/gpu/vendor/sincos.cpp
  libc/src/math/gpu/vendor/sincosf.cpp
  libc/src/math/gpu/vendor/sinf.cpp
  libc/src/math/gpu/vendor/sinh.cpp
  libc/src/math/gpu/vendor/sinhf.cpp
  libc/src/math/gpu/vendor/sqrt.cpp
  libc/src/math/gpu/vendor/sqrtf.cpp
  libc/src/math/gpu/vendor/tan.cpp
  libc/src/math/gpu/vendor/tanf.cpp
  libc/src/math/gpu/vendor/tanh.cpp
  libc/src/math/gpu/vendor/tanhf.cpp
  libc/src/math/gpu/vendor/tgamma.cpp
  libc/src/math/gpu/vendor/tgammaf.cpp
  libc/src/math/gpu/vendor/trunc.cpp
  libc/src/math/gpu/vendor/truncf.cpp
  libc/src/math/pow.h
  libc/src/math/powf.h
  libc/src/math/sincos.h
  libc/src/math/sinh.h
  libc/src/math/tanh.h
  libc/src/math/tgamma.h
  libc/src/math/tgammaf.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156263.544096.patch
Type: text/x-patch
Size: 273960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230725/24b2d9f8/attachment-0001.bin>


More information about the libc-commits mailing list