Skip to content

Commit

Permalink
merge amd-staging into amd-mainline
Browse files Browse the repository at this point in the history
fixes SWDEV-365649, SWDEV-364233, others

Change-Id: I368b9df88b5795747928e73f5b4a977d41887621
  • Loading branch information
searlmc1 committed Nov 8, 2022
2 parents b78d8b3 + 0050fa2 commit 4fcb1fe
Show file tree
Hide file tree
Showing 31 changed files with 4,319 additions and 2,011 deletions.
9 changes: 8 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ if(MSVC AND MSVC_VERSION VERSION_LESS "1900")
endif()

include_directories(${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
add_definitions(${LLVM_DEFINITIONS})

file(GLOB_RECURSE HIPIFY_SOURCES src/*.cpp)
file(GLOB_RECURSE HIPIFY_HEADERS src/*.h)
add_llvm_executable(hipify-clang ${HIPIFY_SOURCES} ${HIPIFY_HEADERS})
target_link_directories(hipify-clang PRIVATE ${LLVM_LIBRARY_DIRS})

set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++)
set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
Expand Down Expand Up @@ -131,7 +131,14 @@ install(
PATTERN "openmp_wrappers" EXCLUDE)

option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" ON)

if(UNIX)

#get rid of any RPATH definations already
set_target_properties(hipify-clang PROPERTIES INSTALL_RPATH "")
#set RPATH for the binary
set_target_properties(hipify-clang PROPERTIES LINK_FLAGS "-Wl,--disable-new-dtags -Wl,--rpath,$ORIGIN/../lib" )

if(FILE_REORG_BACKWARD_COMPATIBILITY)
include(hipify-backward-compat.cmake)
endif()
Expand Down
94 changes: 49 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ After applying all the matchers, the output HIP source is produced.

`hipify-clang` requires:

1. [**LLVM+CLANG**](http://releases.llvm.org) of at least version [4.0.0](http://releases.llvm.org/download.html#4.0.0); the latest stable and recommended release: [**15.0.0**](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0).
1. [**LLVM+CLANG**](http://releases.llvm.org) of at least version [4.0.0](http://releases.llvm.org/download.html#4.0.0); the latest stable and recommended release: [**15.0.4**](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.4).

2. [**CUDA**](https://developer.nvidia.com/cuda-downloads) of at least version [8.0](https://developer.nvidia.com/cuda-80-ga2-download-archive), the latest supported version is [**11.7.1**](https://developer.nvidia.com/cuda-downloads).
2. [**CUDA**](https://developer.nvidia.com/cuda-downloads) of at least version [8.0](https://developer.nvidia.com/cuda-80-ga2-download-archive), the latest supported version is [**11.8.0**](https://developer.nvidia.com/cuda-downloads).

<table align="center">
<thead>
Expand Down Expand Up @@ -160,7 +160,7 @@ After applying all the matchers, the output HIP source is produced.
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.2">14.0.2</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.3">14.0.3</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.4">14.0.4</a>
<td bgcolor="eefaeb"><a href="https://developer.nvidia.com/cuda-downloads">11.7.1</a></td>
<td><a href="https://developer.nvidia.com/cuda-11-7-1-download-archive">11.7.1</a></td>
<td>works only with the patch <br> due to the clang's bug <a href="https://github.com/llvm/llvm-project/issues/54609">54609</a><br>
<a href="patches/patch_for_clang_14.0.0_bug_54609.zip">patch for 14.0.0</a>**<br>
<a href="patches/patch_for_clang_14.0.1_bug_54609.zip">patch for 14.0.1</a>**<br>
Expand All @@ -170,9 +170,13 @@ After applying all the matchers, the output HIP source is produced.
<td><b>+</b></td>
<tr align="center">
<td><a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.5">14.0.5</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.6">14.0.6</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0"><b>15.0.0</b></a></td>
<td bgcolor="eefaeb"><a href="https://developer.nvidia.com/cuda-downloads"><b>11.7.1</b></a></td>
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-14.0.6">14.0.6</a>,<br>
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0">15.0.0</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.1">15.0.1</a>,<br>
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.2">15.0.2</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.3">15.0.3</a>,<br>
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.4"><b>15.0.4</b></a></td>
<td bgcolor="eefaeb"><a href="https://developer.nvidia.com/cuda-downloads"><b>11.8.0</b></a></td>
<td colspan=2 bgcolor="eefaeb"><font color="green"><b>LATEST STABLE CONFIG</b></font></td>
</tr>
</tbody>
Expand All @@ -187,7 +191,7 @@ After applying all the matchers, the output HIP source is produced.
In most cases, you can get a suitable version of `LLVM+CLANG` with your package manager.

Failing that or having multiple versions of `LLVM`, you can [download a release archive](http://releases.llvm.org/), build or install it, and set
[CMAKE_PREFIX_PATH](https://cmake.org/cmake/help/v3.5/variable/CMAKE_PREFIX_PATH.html) so `cmake` can find it; for instance: `-DCMAKE_PREFIX_PATH=d:\LLVM\15.0.0\dist`
[CMAKE_PREFIX_PATH](https://cmake.org/cmake/help/v3.5/variable/CMAKE_PREFIX_PATH.html) so `cmake` can find it; for instance: `-DCMAKE_PREFIX_PATH=d:\LLVM\15.0.4\dist`

### <a name="hipify-clang-usage"></a> hipify-clang: usage

Expand All @@ -196,14 +200,14 @@ To process a file, `hipify-clang` needs access to the same headers that would be
For example:

```shell
./hipify-clang square.cu --cuda-path=/usr/local/cuda-11.7 -I /usr/local/cuda-11.7/samples/common/inc
./hipify-clang square.cu --cuda-path=/usr/local/cuda-11.8 -I /usr/local/cuda-11.8/samples/common/inc
```

`hipify-clang` arguments are given first, followed by a separator `'--'`, and then the arguments you'd pass to `clang` if you
were compiling the input file. For example:

```bash
./hipify-clang cpp17.cu --cuda-path=/usr/local/cuda-11.7 -- -std=c++17
./hipify-clang cpp17.cu --cuda-path=/usr/local/cuda-11.8 -- -std=c++17
```

The [Clang manual for compiling CUDA](https://llvm.org/docs/CompileCudaWithLLVM.html#compiling-cuda-code) may be useful.
Expand Down Expand Up @@ -285,7 +289,7 @@ Run `Visual Studio 16 2019`, open the generated `LLVM.sln`, build all, and build

**LLVM >= 10.0.0:**

1. download [`LLVM project`](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0) sources;
1. download [`LLVM project`](https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.4) sources;
2. build [`LLVM project`](http://llvm.org/docs/CMake.html):

```bash
Expand Down Expand Up @@ -324,17 +328,17 @@ Run `Visual Studio 17 2022`, open the generated `LLVM.sln`, build all, build pro

- ***Linux***: `-DCUDA_TOOLKIT_ROOT_DIR=/usr/include`

- ***Windows***: `-DCUDA_TOOLKIT_ROOT_DIR="c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7"`
- ***Windows***: `-DCUDA_TOOLKIT_ROOT_DIR="c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8"`

`-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v11.7"`
`-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v11.8"`

4. Ensure [`cuDNN`](https://developer.nvidia.com/rdp/cudnn-archive) of the version corresponding to CUDA's version is installed.

* Path to [`cuDNN`](https://developer.nvidia.com/rdp/cudnn-download) should be specified by the `CUDA_DNN_ROOT_DIR` option:

- ***Linux***: `-DCUDA_DNN_ROOT_DIR=/usr/include`

- ***Windows***: `-DCUDA_DNN_ROOT_DIR=d:/CUDNN/cudnn-11.7-windows-x64-v8.4.1`
- ***Windows***: `-DCUDA_DNN_ROOT_DIR=d:/CUDNN/cudnn-11.8-windows-x64-v8.6.0`

5. Ensure [`CUB`](https://github.com/NVlabs/cub) of the version corresponding to CUDA's version is installed.

Expand All @@ -350,21 +354,21 @@ Run `Visual Studio 17 2022`, open the generated `LLVM.sln`, build all, build pro

* Install `lit` into `python`:

- ***Linux***: `python /usr/llvm/15.0.0/llvm-project/llvm/utils/lit/setup.py install`
- ***Linux***: `python /usr/llvm/15.0.4/llvm-project/llvm/utils/lit/setup.py install`

- ***Windows***: `python d:/LLVM/15.0.0/llvm-project/llvm/utils/lit/setup.py install`
- ***Windows***: `python d:/LLVM/15.0.4/llvm-project/llvm/utils/lit/setup.py install`

* Starting with LLVM 6.0.1 path to `llvm-lit` python script should be specified by the `LLVM_EXTERNAL_LIT` option:

- ***Linux***: `-DLLVM_EXTERNAL_LIT=/usr/llvm/15.0.0/build/bin/llvm-lit`
- ***Linux***: `-DLLVM_EXTERNAL_LIT=/usr/llvm/15.0.4/build/bin/llvm-lit`

- ***Windows***: `-DLLVM_EXTERNAL_LIT=d:/LLVM/15.0.0/build/Release/bin/llvm-lit.py`
- ***Windows***: `-DLLVM_EXTERNAL_LIT=d:/LLVM/15.0.4/build/Release/bin/llvm-lit.py`

* `FileCheck`:

- ***Linux***: copy from `/usr/llvm/15.0.0/build/bin/` to `CMAKE_INSTALL_PREFIX/dist/bin`
- ***Linux***: copy from `/usr/llvm/15.0.4/build/bin/` to `CMAKE_INSTALL_PREFIX/dist/bin`

- ***Windows***: copy from `d:/LLVM/15.0.0/build/Release/bin` to `CMAKE_INSTALL_PREFIX/dist/bin`
- ***Windows***: copy from `d:/LLVM/15.0.4/build/Release/bin` to `CMAKE_INSTALL_PREFIX/dist/bin`

- Or specify the path to `FileCheck` in `CMAKE_INSTALL_PREFIX` option

Expand All @@ -386,7 +390,7 @@ Ubuntu 14: LLVM 4.0.0 - 7.1.0, CUDA 7.0 - 9.0, cuDNN 5.0.5 - 7.6.5

Ubuntu 16-18: LLVM 8.0.0 - 14.0.6, CUDA 8.0 - 10.2, cuDNN 5.1.10 - 8.0.5

Ubuntu 20-21: LLVM 9.0.0 - 15.0.0, CUDA 8.0 - 11.7.1, cuDNN 5.1.10 - 8.4.1
Ubuntu 20-21: LLVM 9.0.0 - 15.0.4, CUDA 8.0 - 11.8.0, cuDNN 5.1.10 - 8.6.0

Minimum build system requirements for the above configurations:

Expand All @@ -403,11 +407,11 @@ cmake
-DHIPIFY_CLANG_TESTS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../dist \
-DCMAKE_PREFIX_PATH=/usr/llvm/15.0.0/dist \
-DCMAKE_PREFIX_PATH=/usr/llvm/15.0.4/dist \
-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda \
-DCUDA_DNN_ROOT_DIR=/usr/local/cuda \
-DCUDA_CUB_ROOT_DIR=/usr/CUB \
-DLLVM_EXTERNAL_LIT=/usr/llvm/15.0.0/build/bin/llvm-lit \
-DLLVM_EXTERNAL_LIT=/usr/llvm/15.0.4/build/bin/llvm-lit \
../hipify
```
*A corresponding successful output:*
Expand All @@ -425,20 +429,20 @@ cmake
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11")
-- Found LLVM 15.0.0:
-- - CMake module path: /usr/llvm/15.0.0/dist/lib/cmake/llvm
-- - Include path : /usr/llvm/15.0.0/dist/include
-- - Binary path : /usr/llvm/15.0.0/dist/bin
-- Found LLVM 15.0.4:
-- - CMake module path: /usr/llvm/15.0.4/dist/lib/cmake/llvm
-- - Include path : /usr/llvm/15.0.4/dist/include
-- - Binary path : /usr/llvm/15.0.4/dist/bin
-- Linker detection: GNU ld
-- Found PythonInterp: /usr/bin/python (found suitable version "3.9.7", minimum required is "2.7")
-- Found lit: /usr/local/bin/lit
-- Found FileCheck: /usr/llvm/15.0.0/dist/bin/FileCheck
-- Found FileCheck: /usr/llvm/15.0.4/dist/bin/FileCheck
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found CUDA: /usr/local/cuda (found version "11.7")
-- Found CUDA: /usr/local/cuda (found version "11.8")
-- Configuring done
-- Generating done
-- Build files have been written to: /usr/hipify/build
Expand All @@ -450,8 +454,8 @@ make test-hipify
```shell
Running HIPify regression tests
========================================
CUDA 11.7 - will be used for testing
LLVM 15.0.0 - will be used for testing
CUDA 11.8 - will be used for testing
LLVM 15.0.4 - will be used for testing
x86_64 - Platform architecture
Linux 5.13.0-21-generic - Platform OS
64 - hipify-clang binary bitness
Expand Down Expand Up @@ -565,8 +569,8 @@ Testing Time: 6.22s
| 11.0.1 - 11.1.0 | 7.0 - 11.2.2 | 7.6.5 - 8.0.5 | 2017.15.9.31, 2019.16.8.4 | 3.19.3 | 3.9.2 |
| 12.0.0 - 13.0.1 | 7.0 - 11.5.1 | 7.6.5 - 8.3.2 | 2017.15.9.43, 2019.16.11.9 | 3.22.2 | 3.10.2 |
| 14.0.0 - 14.0.6 | 7.0 - 11.7.1 | 8.0.5 - 8.4.1 | 2017.15.9.49, 2019.16.11.17, 2022.17.2.6 | 3.24.0 | 3.10.6 |
| 15.0.0 | 7.0 - 11.7.1 | 8.0.5 - 8.4.1 | 2017.15.9.50, 2019.16.11.18, 2022.17.3.3 | 3.24.1 | 3.10.6 |
| 16.0.0git | 7.0 - 11.7.1 | 8.0.5 - 8.4.1 | 2017.15.9.50, 2019.16.11.18, 2022.17.3.3 | 3.24.1 | 3.10.6 |
| 15.0.0 - 15.0.4 | 7.0 - 11.8.0 | 8.0.5 - 8.6.0 | 2017.15.9.50, 2019.16.11.20, 2022.17.3.6 | 3.24.2 | 3.11.0 |
| 16.0.0git | 7.0 - 11.8.0 | 8.0.5 - 8.6.0 | 2017.15.9.50, 2019.16.11.20, 2022.17.3.6 | 3.24.2 | 3.11.0 |

*Building with testing support by `Visual Studio 17 2022` on `Windows 10`:*

Expand All @@ -578,24 +582,24 @@ cmake
-DHIPIFY_CLANG_TESTS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../dist \
-DCMAKE_PREFIX_PATH=d:/LLVM/15.0.0/dist \
-DCUDA_TOOLKIT_ROOT_DIR="c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7" \
-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v11.7" \
-DCUDA_DNN_ROOT_DIR=d:/CUDNN/cudnn-11.7-windows-x64-v8.4.1 \
-DCMAKE_PREFIX_PATH=d:/LLVM/15.0.4/dist \
-DCUDA_TOOLKIT_ROOT_DIR="c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8" \
-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v11.8" \
-DCUDA_DNN_ROOT_DIR=d:/CUDNN/cudnn-11.8-windows-x64-v8.6.0 \
-DCUDA_CUB_ROOT_DIR=d:/GIT/cub \
-DLLVM_EXTERNAL_LIT=d:/LLVM/15.0.0/build/Release/bin/llvm-lit.py \
-DLLVM_EXTERNAL_LIT=d:/LLVM/15.0.4/build/Release/bin/llvm-lit.py \
../hipify
```
*A corresponding successful output:*
```shell
-- Found LLVM 15.0.0:
-- - CMake module path: d:/LLVM/15.0.0/dist/lib/cmake/llvm
-- - Include path : d:/LLVM/15.0.0/dist/include
-- - Binary path : d:/LLVM/15.0.0/dist/bin
-- Found PythonInterp: c:/Program Files/Python39/python.exe (found suitable version "3.9.5", minimum required is "3.6")
-- Found lit: c:/Program Files/Python39/Scripts/lit.exe
-- Found FileCheck: d:/LLVM/15.0.0/dist/bin/FileCheck.exe
-- Found CUDA: c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.7 (found version "11.7")
-- Found LLVM 15.0.4:
-- - CMake module path: d:/LLVM/15.0.4/dist/lib/cmake/llvm
-- - Include path : d:/LLVM/15.0.4/dist/include
-- - Binary path : d:/LLVM/15.0.4/dist/bin
-- Found PythonInterp: c:/Program Files/Python311/python.exe (found suitable version "3.11.0", minimum required is "3.6")
-- Found lit: c:/Program Files/Python311/Scripts/lit.exe
-- Found FileCheck: d:/LLVM/15.0.4/dist/bin/FileCheck.exe
-- Found CUDA: c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.8 (found version "11.8")
-- Configuring done
-- Generating done
-- Build files have been written to: d:/hipify/build
Expand Down
Loading

0 comments on commit 4fcb1fe

Please sign in to comment.