[MLIR][GPU] Link in device libraries during HSA compilation if needed
authorKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Thu, 18 Nov 2021 22:37:53 +0000 (22:37 +0000)
committerKrzysztof Drewniak <Krzysztof.Drewniak@amd.com>
Fri, 19 Nov 2021 22:29:37 +0000 (22:29 +0000)
commita6f53afbcb4d995139064276b5ad971ad7ced5e2
tree3fa863d526c1c06edd9a5aac8f9ce936e49eace2
parent3f3bee42d22988d018834c58af244dee08a52d9c
[MLIR][GPU] Link in device libraries during HSA compilation if needed

To perform some operations, such as sin() or printf(), code compiled
for AMD GPUs must be linked to a series of device libraries. This
commit adds support for linking in these libraries.

However, since these device libraries are delivered as LLVM bitcode,
raising the possibility of version incompatibilities, this commit only
links in libraries when the functions from those libraries are called
by the code being compiled.

This code also sets the math flags to their most conservative values,
as MLIR doesn't have a `-ffast-math` equivalent.

Depends on D114114

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D114117
mlir/lib/Dialect/GPU/CMakeLists.txt
mlir/lib/Dialect/GPU/Transforms/SerializeToHsaco.cpp