Skip to content

Commit

Permalink
Merge branch 'amd-staging' of hipify into amd-mainline
Browse files Browse the repository at this point in the history
Change-Id: Ia35d23b666c7d6c02ef4d89a739d79ebb0842e57
  • Loading branch information
aakanksha555 authored and searlmc1 committed Oct 26, 2023
2 parents 7a0aaac + 89520b6 commit ff14c01
Show file tree
Hide file tree
Showing 54 changed files with 16,183 additions and 14,924 deletions.
7 changes: 1 addition & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,7 @@ if (NOT HIPIFY_CLANG_TESTS_ONLY)
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} ${addr_var}")

# [ToDo] Remove D125860 related guards from CMakeLists.txt with the LLVM 16.0.0 official release.
option (D125860 "Enables treating clang's resource dir as lib/clang/X.Y.Z, as it was before clang's change D125860, merged as e1b88c8a09be25b86b13f98755a9bd744b4dbf14" OFF)
if(D125860)
add_definitions(-D125860)
endif()
if((LLVM_PACKAGE_VERSION VERSION_EQUAL "16.0.0" OR LLVM_PACKAGE_VERSION VERSION_GREATER "16.0.0") AND (NOT D125860))
if(LLVM_PACKAGE_VERSION VERSION_EQUAL "16.0.0" OR LLVM_PACKAGE_VERSION VERSION_GREATER "16.0.0")
set(LIB_CLANG_RES ${LLVM_VERSION_MAJOR})
else()
set(LIB_CLANG_RES ${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH})
Expand Down
2 changes: 1 addition & 1 deletion bin/hipconvertinplace-perl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# (this is useful for testing improvements to the hipify-perl toolset).

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../../libexec/hipify"
SEARCH_DIR=$1
shift
$SCRIPT_DIR/hipify-perl -inplace -print-stats "$@" `$PRIV_SCRIPT_DIR/findcode.sh $SEARCH_DIR`
2 changes: 1 addition & 1 deletion bin/hipconvertinplace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# preserves the existing directory structure.

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../../libexec/hipify"
SEARCH_DIR=$1

hipify_args=''
Expand Down
2 changes: 1 addition & 1 deletion bin/hipexamine-perl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@


SCRIPT_DIR="$(dirname "$(realpath "$0")")"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../../libexec/hipify"
SEARCH_DIR=$1
shift
$SCRIPT_DIR/hipify-perl -no-output -print-stats "$@" `$PRIV_SCRIPT_DIR/findcode.sh $SEARCH_DIR`
2 changes: 1 addition & 1 deletion bin/hipexamine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Generate CUDA->HIP conversion statistics for all the code files in the specified directory.

SCRIPT_DIR="$(dirname "$(realpath "$0")")"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../libexec/hipify"
PRIV_SCRIPT_DIR="$SCRIPT_DIR/../../libexec/hipify"
SEARCH_DIR=$1

hipify_args=''
Expand Down
693 changes: 373 additions & 320 deletions bin/hipify-perl

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/.sphinx/requirements.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rocm-docs-core==0.24.2
rocm-docs-core==0.26.0
2 changes: 1 addition & 1 deletion docs/.sphinx/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ requests==2.28.2
# via
# pygithub
# sphinx
rocm-docs-core==0.24.2
rocm-docs-core==0.26.0
# via -r requirements.in
smmap==5.0.0
# via gitdb
Expand Down
125 changes: 80 additions & 45 deletions docs/hipify-clang.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ 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: [**17.0.1**](https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.1).
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: [**17.0.3**](https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.3).

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 [**12.2.2**](https://developer.nvidia.com/cuda-downloads).

Expand Down Expand Up @@ -174,7 +174,9 @@ After applying all the matchers, the output HIP source is produced.
<td>+</td>
</tr>
<tr align="center">
<td bgcolor="eefaeb"><a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.1"><b>17.0.1</b></a></td>
<td bgcolor="eefaeb"><a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.1">17.0.1</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.2">17.0.2</a>,
<a href="https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.3"><b>17.0.3</b></a></td>
<td bgcolor="eefaeb"><a href="https://developer.nvidia.com/cuda-downloads"><b>12.2.2</b></a></td>
<td colspan=2 bgcolor="eefaeb"><font color="green"><b>LATEST STABLE CONFIG</b></font></td>
</tr>
Expand All @@ -196,7 +198,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\17.0.1\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\17.0.3\dist`

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

Expand Down Expand Up @@ -296,7 +298,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-17.0.1) sources;
1. download [`LLVM project`](https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.3) sources;
2. build [`LLVM project`](http://llvm.org/docs/CMake.html):

```bash
Expand Down Expand Up @@ -337,47 +339,51 @@ 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/v12.2"`
- ***Windows***: `-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2"`

`-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2"`
`-DCUDA_SDK_ROOT_DIR="C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2"`

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-12.2-windows-x64-v8.9.5`
- ***Windows***: `-DCUDA_DNN_ROOT_DIR=D:/CUDA/cuDNN/8.9.5`

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

* Path to CUB should be specified by the `CUDA_CUB_ROOT_DIR` option:

- ***Linux***: `-DCUDA_CUB_ROOT_DIR=/srv/git/CUB`

- ***Windows***: `-DCUDA_CUB_ROOT_DIR=d:/GIT/cub`
- ***Windows***: `-DCUDA_CUB_ROOT_DIR=D:/CUDA/CUB/cub-2.1.0`

6. Ensure [`python`](https://www.python.org/downloads) of minimum required version 2.7 is installed.

7. Ensure `lit` and `FileCheck` are installed - these are distributed with `LLVM`.

* Install `lit` into `python`:

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

- ***Windows***: `python d:/LLVM/17.0.1/llvm-project/llvm/utils/lit/setup.py install`
- ***Windows***: `python D:/LLVM/17.0.3/llvm-project/llvm/utils/lit/setup.py install`

In case of errors, similar to `ModuleNotFoundError: No module named 'setuptools'`, upgrade the `setuptools` package:

`python -m pip install --upgrade pip setuptools`

* 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/17.0.1/build/bin/llvm-lit`
- ***Linux***: `-DLLVM_EXTERNAL_LIT=/usr/llvm/17.0.3/build/bin/llvm-lit`

- ***Windows***: `-DLLVM_EXTERNAL_LIT=d:/LLVM/17.0.1/build/Release/bin/llvm-lit.py`
- ***Windows***: `-DLLVM_EXTERNAL_LIT=D:/LLVM/17.0.3/build/Release/bin/llvm-lit.py`

* `FileCheck`:

- ***Linux***: copy from `/usr/llvm/17.0.1/build/bin/` to `CMAKE_INSTALL_PREFIX/dist/bin`
- ***Linux***: copy from `/usr/llvm/17.0.3/build/bin/` to `CMAKE_INSTALL_PREFIX/dist/bin`

- ***Windows***: copy from `d:/LLVM/17.0.1/build/Release/bin` to `CMAKE_INSTALL_PREFIX/dist/bin`
- ***Windows***: copy from `D:/LLVM/17.0.3/build/Release/bin` to `CMAKE_INSTALL_PREFIX/dist/bin`

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

Expand All @@ -399,9 +405,9 @@ 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 - 17.0.1, CUDA 8.0 - 12.2.2, cuDNN 5.1.10 - 8.9.5
Ubuntu 20-21: LLVM 9.0.0 - 17.0.3, CUDA 8.0 - 12.2.2, cuDNN 5.1.10 - 8.9.5

Ubuntu 22: LLVM 13.0.0 - 17.0.1, CUDA 10.0 - 12.2.2, cuDNN 8.0.5 - 8.9.5
Ubuntu 22: LLVM 13.0.0 - 17.0.3, CUDA 10.0 - 12.2.2, cuDNN 8.0.5 - 8.9.5

Minimum build system requirements for the above configurations:

Expand All @@ -418,11 +424,11 @@ cmake
-DHIPIFY_CLANG_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../dist \
-DCMAKE_PREFIX_PATH=/usr/llvm/17.0.1/dist \
-DCMAKE_PREFIX_PATH=/usr/llvm/17.0.3/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/17.0.1/build/bin/llvm-lit \
-DLLVM_EXTERNAL_LIT=/usr/llvm/17.0.3/build/bin/llvm-lit \
../hipify
```

Expand All @@ -442,14 +448,14 @@ 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 17.0.1:
-- - CMake module path: /usr/llvm/17.0.1/dist/lib/cmake/llvm
-- - Include path : /usr/llvm/17.0.1/dist/include
-- - Binary path : /usr/llvm/17.0.1/dist/bin
-- Found LLVM 17.0.3:
-- - CMake module path: /usr/llvm/17.0.3/dist/lib/cmake/llvm
-- - Include path : /usr/llvm/17.0.3/dist/include
-- - Binary path : /usr/llvm/17.0.3/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/17.0.1/dist/bin/FileCheck
-- Found FileCheck: /usr/llvm/17.0.3/dist/bin/FileCheck
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
Expand All @@ -470,7 +476,7 @@ make test-hipify
Running HIPify regression tests
========================================
CUDA 12.2 - will be used for testing
LLVM 17.0.1 - will be used for testing
LLVM 17.0.3 - 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 @@ -589,14 +595,14 @@ Testing Time: 7.90s
| 14.0.0 - 14.0.6 | 7.0 - 11.7.1 | 8.0.5 - 8.4.1 | 2017.15.9.57*, 2019.16.11.17, 2022.17.2.6 | 3.24.0 | 3.10.6 |
| 15.0.0 - 15.0.7 | 7.0 - 11.8.0 | 8.0.5 - 8.8.1 | 2019.16.11.25, 2022.17.5.2 | 3.26.0 | 3.11.2 |
| 16.0.0 - 16.0.6 | 7.0 - 12.2.2 | 8.0.5 - 8.9.5 | 2019.16.11.29, 2022.17.7.1 | 3.27.3 | 3.11.4 |
| 17.0.1** | 7.0 - 12.2.2 | 8.0.5 - 8.9.5 | 2019.16.11.30, 2022.17.7.4 | 3.27.6 | 3.11.5 |
| 18.0.0git | 7.0 - 12.2.2 | 8.0.5 - 8.9.5 | 2019.16.11.30, 2022.17.7.4 | 3.27.6 | 3.11.5 |
| 17.0.1** 17.0.3 | 7.0 - 12.2.2 | 8.0.5 - 8.9.5 | 2019.16.11.30, 2022.17.7.4 | 3.27.6 | 3.12.0 |
| 18.0.0git | 7.0 - 12.2.2 | 8.0.5 - 8.9.5 | 2019.16.11.30, 2022.17.7.4 | 3.27.6 | 3.12.0 |

`*` LLVM 14.x.x is the latest major release supporting Visual Studio 2017.
To build LLVM 14.x.x correctly by Visual Studio 2017, `-DLLVM_FORCE_USE_OLD_TOOLCHAIN=ON` should be added to a corresponding cmake command line.
LLVM < 14.x.x can be built correctly by Visual Studio 2017 without the `LLVM_FORCE_USE_OLD_TOOLCHAIN` option.

`**` Note that LLVM 17.0.0 was withdrawn due to an issue, please use 17.0.1 instead.
`**` Note that LLVM 17.0.0 was withdrawn due to an issue, please use 17.0.1 or newer instead.

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

Expand All @@ -608,27 +614,56 @@ cmake
-DHIPIFY_CLANG_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../dist \
-DCMAKE_PREFIX_PATH=d:/LLVM/17.0.1/dist \
-DCUDA_TOOLKIT_ROOT_DIR="c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2" \
-DCUDA_SDK_ROOT_DIR="c:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2" \
-DCUDA_DNN_ROOT_DIR=d:/CUDNN/cudnn-12.2-windows-x64-v8.9.5 \
-DCUDA_CUB_ROOT_DIR=d:/GIT/cub \
-DLLVM_EXTERNAL_LIT=d:/LLVM/17.0.1/build/Release/bin/llvm-lit.py \
-DCMAKE_PREFIX_PATH=D:/LLVM/17.0.3/dist \
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2" \
-DCUDA_SDK_ROOT_DIR="C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2" \
-DCUDA_DNN_ROOT_DIR=D:/CUDA/cuDNN/8.9.5 \
-DCUDA_CUB_ROOT_DIR=D:/CUDA/CUB/cub-2.1.0 \
-DLLVM_EXTERNAL_LIT=D:/LLVM/17.0.3/build/Release/bin/llvm-lit.py \
../hipify
```
*A corresponding successful output:*
```shell
-- Found LLVM 17.0.1:
-- - CMake module path: d:/LLVM/17.0.1/dist/lib/cmake/llvm
-- - Include path : d:/LLVM/17.0.1/dist/include
-- - Binary path : d:/LLVM/17.0.1/dist/bin
-- Found PythonInterp: c:/Program Files/Python311/python.exe (found suitable version "3.11.5", minimum required is "3.6")
-- Found lit: c:/Program Files/Python311/Scripts/lit.exe
-- Found FileCheck: d:/LLVM/17.0.1/dist/bin/FileCheck.exe
-- Found CUDA: c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2 (found version "12.2")
-- Configuring done
-- Generating done
-- Build files have been written to: d:/hipify/build
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.37.32824.0
-- The CXX compiler identification is MSVC 19.37.32824.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- HIPIFY config:
-- - Build hipify-clang : ON
-- - Test hipify-clang : ON
-- - Is part of HIP SDK : OFF
-- Found LLVM 17.0.3:
-- - CMake module path : D:/LLVM/17.0.3/dist/lib/cmake/llvm
-- - Clang include path : D:/LLVM/17.0.3/dist/include
-- - LLVM Include path : D:/LLVM/17.0.3/dist/include
-- - Binary path : D:/LLVM/17.0.3/dist/bin
-- ---- The below configuring for hipify-clang testing only ----
-- Found Python: C:/Users/TT/AppData/Local/Programs/Python/Python312/python.exe (found version "3.12.0") found components: Interpreter
-- Found lit: C:/Users/TT/AppData/Local/Programs/Python/Python312/Scripts/lit.exe
-- Found FileCheck: D:/LLVM/17.0.3/dist/bin/FileCheck.exe
-- Initial CUDA to configure:
-- - CUDA Toolkit path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2
-- - CUDA Samples path : C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2
-- - cuDNN path : D:/CUDA/cuDNN/8.9.5
-- - CUB path : D:/CUDA/CUB/cub-2.1.0
-- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/include (found version "12.2.140")
-- Found CUDA config:
-- - CUDA Toolkit path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2
-- - CUDA Samples path : C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.2
-- - cuDNN path : D:/CUDA/cuDNN/8.9.5
-- - CUB path : D:/CUDA/CUB/cub-2.1.0
-- Configuring done (1.4s)
-- Generating done (0.1s)
-- Build files have been written to: D:/HIPIFY/build
```

Run `Visual Studio 17 2022`, open the generated `hipify-clang.sln`, build project `test-hipify`.
Run `Visual Studio 17 2022`, open the generated `hipify-clang.sln`, build the project `test-hipify`.
Loading

0 comments on commit ff14c01

Please sign in to comment.