23 Commits

Author SHA1 Message Date
Yaxun (Sam) Liu
661d91a0fd [clang] Make amdgpu-arch tool work on Windows
Currently amdgpu-arch tool detects AMD GPU by dynamically
loading HSA runtime shared library and using HSA API's,
which is not available on Windows.

This patch makes it work on Windows by dynamically loading
HIP runtime dll and using HIP API's.

Reviewed by: Matt Arsenault, Joseph Huber, Johannes Doerfert

Differential Revision: https://reviews.llvm.org/D153725
2023-07-08 00:01:02 -04:00
Joseph Huber
66da9ec073 [Clang] Remove direct linking of offloading runtimes from the arch tools
The tools `amdgpu-arch` and `nvptx-arch` are used to query the supported
GPUs on a system to implement features like `--offload-arch=native` as
well as generally being useful for setting up tests. However, we
currently directly link these if they are availible. This patch removes
this because it causes many problems on the user not having the libaries
present or misconfigured at build time. Since these are built
unconditionally we shoudl keep the dependencies away from clang.

Fixes https://github.com/llvm/llvm-project/issues/62784

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D150807
2023-05-17 17:47:49 -05:00
Joseph Huber
1b40df1de7 [Clang] Fix not including clangBasic in the dynamic build
Summary:
The previous patch only included the needed library if you had HSA and
CUDA installed. Fix that.
2023-03-13 12:41:16 -05:00
Joseph Huber
a26aabefe5 [Clang] Add --version and --help messages to amdgpu/nvptx-arch
Summray:
These clang tools should print some basic help and version messages so
they are less opaque.

Reviewed By: ye-luo

Differential Revision: https://reviews.llvm.org/D145944
2023-03-13 12:32:42 -05:00
Joseph Huber
067a5c6884 [amdgpu-arch] Fix build of amdgpu-arch with CLANG_LINK_CLANG_DYLIB
The function clang_target_link_libraries must only be used with real
Clang libraries; with CLANG_LINK_CLANG_DYLIB, it will instead link in
clang-cpp. We must use the standard CMake target_link_libraries for
the HSA library.
2023-02-10 08:23:49 -06:00
Joseph Huber
472393eff4 [Clang] Disable building tools for 32-bit hosts as well
Summary:
Offloading is not supported on 32-bit applications. We already disable
this for 32-bit cross-compiling but we also need to disable it for
32-bit native machines as well.
2023-02-07 21:18:50 -06:00
Joseph Huber
9f64fbb882 [Clang] Do not attempt to directly link arch tools in 32-bit mode
Summary:
We offer almost no support for offloading on 32-bit systems. This causes
some problems when cross-compiling for 32-bit machines as it will find
the CUDA from the host that is incompatible. Instead we force these to
always use the dynamically loaded version, which should always compile.
2023-01-31 11:56:24 -06:00
Jon Chesterfield
bfe4514add [amdgpuarch] Delete stray hsa #include line 2023-01-25 21:40:35 +00:00
Joseph Huber
679c352ff4 [Clang][NFC] Tweak error message for GPU architecture tools
Summary:
There shouldn't be an extra newline in these messages.
2023-01-19 12:48:28 -06:00
Joseph Huber
4ce454c654 [Clang] Configure definitions for amdgpu/nvptx arch query tools
Summary:
These tools are built unconditionally now. However, there seemed to be
problems where the headers would be found during cross compilation, but
no libraries present. To combat this we should elect to make the CMake
indicate whether or not we should use the dynamic library method or link
it directly rather than using `__has_include`.
2023-01-17 14:27:12 -06:00
Joseph Huber
f6ace23172 [amdgpu-arch] Dynamically load the HSA runtime if not found during the build
We use the `amdgpu-arch` tool to query the installed GPUs at runtime.
One problem is that this tool is currently not build if the person
building the LLVM binary does not have the HSA runtime on their system.
This means that if someone built and distrubted an installation of LLVM
without HSA, then the user will not be able to use it even if they have
it on their system.

This patch makes us build this tool unconditionally and adds extra logic
to dynamically load HSA if it's present.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D141859
2023-01-16 13:13:45 -06:00
Matt Arsenault
39a83ebd47 amdgpu-arch: Prefer hsa/hsa.h over hsa.h
The header now prints a warning if you include hsa.h telling you to
include hsa/hsa.h
2023-01-04 20:51:51 -05:00
Pushpinder Singh
c711aa0f6f [amdgpu-arch] Guard hsa.h with __has_include
This patch is suppose to fix the issue of hsa.h not found.
Issue was reported in D99949

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D102067
2021-05-10 07:33:30 +00:00
Jon Chesterfield
b24e9f82b7 [amdgpu-arch] Fix rpath to run from build dir
[amdgpu-arch] Fix rpath to run from build dir

Prior to this, amdgpu-arch has RUNPATH set to $ORIGIN/../lib which works
for some installs, but not from the build directory where clang executes
the tool from when running tests.

This cmake option adds the location of the rocr runtime to the RUNPATH
(note, it amends RUNPATH here, despite the cmake option referring to RPATH)
to create a binary that runs from build or install location.

Before:
RUNPATH [$ORIGIN/../lib]
After:
RUNPATH [$ORIGIN/../lib:$HOME/llvm-install/lib]

Credit to Greg for knowing this trick and pointing to examples of it in use
for the aomp build scripts.

Reviewed By: pdhaliwal

Differential Revision: https://reviews.llvm.org/D101926
2021-05-06 13:07:00 +01:00
Pushpinder Singh
59ad4e0f01 Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 93604305bb72201641f31cc50a6e7b2fe65d3af3.
2021-04-27 10:47:05 +00:00
Pushpinder Singh
93604305bb Revert "Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed""
This reverts commit 15be0c41d2e59fb4599c9aebf21ede498c61f51d.
2021-04-27 02:23:44 +00:00
Jon Chesterfield
15be0c41d2 Reapply "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 24c1ed3b34f7602b955e52cd8a362f4e27eb5f20.
2021-04-23 01:07:16 +01:00
Jon Chesterfield
24c1ed3b34 Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 722d4d8e7585457d407d0639a4ae2610157e06a8.

Unclear where hsa.h should be included from, see report in D99949
2021-04-22 19:39:37 +01:00
Pushpinder Singh
722d4d8e75 [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-22 05:20:28 +00:00
Pushpinder Singh
0ad50bf27f Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 3194761d2763a471dc6426a3e77c1445cb9ded3b.
2021-04-21 08:05:38 +00:00
Pushpinder Singh
3194761d27 [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-21 05:05:49 +00:00
Pushpinder Singh
efc013ec4d Revert "[AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed"
This reverts commit 7029cffc4e78556cfe820791c612968bb15b2ffb.
2021-04-16 09:16:58 +00:00
Pushpinder Singh
7029cffc4e [AMDGPU][OpenMP] Add amdgpu-arch tool to list AMD GPUs installed
This patch adds new clang tool named amdgpu-arch which uses
HSA to detect installed AMDGPU and report back latter's march.
This tool is built only if system has HSA installed.

The value printed by amdgpu-arch is used to fill -march when
latter is not explicitly provided in -Xopenmp-target.

Reviewed By: JonChesterfield, gregrodgers

Differential Revision: https://reviews.llvm.org/D99949
2021-04-16 05:26:20 +00:00