[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
Wed Jun 14 09:47:07 PDT 2023


AntonRydahl added a comment.

In D152575#4421651 <https://reviews.llvm.org/D152575#4421651>, @JonChesterfield wrote:

> In D152575#4420284 <https://reviews.llvm.org/D152575#4420284>, @sivachandra wrote:
>
>> I would rather implement the functions added by this patch as builtin wrappers instead of vendor wrappers. See the `round` example in D152468 <https://reviews.llvm.org/D152468>.
>
> I think we're missing a canonicalisation opportunity in libm. It's never totally clear whether an optimisation should target a C function with a known name or an intrinsic. Fair chance O0 C++ produces a wrapper to handle the overload with a different name. Openmp variants introduce another name mangling scheme. Then we have the nv_sin ocml_cos set. I don't know what Fortran calls it, maybe _sin.
>
> I think we should have an IR intrinsic for each (or at least most) libm functions, transform the various source names to the intrinsics in the front end or generally as aggressively as we can. Then optimise them - at least constant fold, but trig identities might be fair game as well. Then lower to whatever mix of libm functions and native instructions the backend sees fit.
>
> Errno is a pain here, but if errno is not disabled we can still constant fold cases that don't error. Likewise there's various fast math flags which are a mess but it seems more likely that we can handle them consistently and correctly if it's all localised to one place.
>
> This diff isn't the right venue to propose that, I should probably try the forum that replaced mailing lists.

On the discussion forum, it has been proposed that we should test which versions perform better on GPUs: https://discourse.llvm.org/t/libm-conformance-and-timing-ci-for-gpus/71362

Maybe that would be a better fit for this discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152575



More information about the libc-commits mailing list