Building hipify-clang on Windows#
Building LLVM >= 10.0.0 (Recommended)#
# Assuming commands are being run in Windows CMD.
# Use "$env:ROOT_DIR = (Get-Location).Path" to set the environment variable for PowerShell and use $env:ROOT_DIR to access it.
set ROOT_DIR=%cd%
# If you would like to clone LLVM with the full git history, remove the `--depth 1` option.
git clone --depth 1 https://github.com/llvm/llvm-project.git
mkdir build dist
cd build
cmake -G "Visual Studio 17 2022" -A x64 -Thost=x64 -DCMAKE_INSTALL_PREFIX=../dist -DLLVM_TARGETS_TO_BUILD="" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_INCLUDE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm
# Run Visual Studio 17 2022, open the generated LLVM.sln, build all, and build project "INSTALL".
# Alternatively, you can build using "msbuild INSTALL.vcxproj /m" using the developer command prompt.
Note
If LLVM and Clang are built in Debug mode (with -DCMAKE_BUILD_TYPE=Debug), please build HIPIFY in Debug mode as well.
We support 64-bit build mode (-Thost=x64). Please build LLVM and Clang in 64-bit mode.
Building LLVM < 10.0.0#
Download older LLVM + Clang sources.
set ROOT_DIR=%cd%
mkdir build dist
cd build
cmake -G "Visual Studio 16 2019" -A x64 -Thost=x64 -DCMAKE_INSTALL_PREFIX=../dist -DLLVM_TARGETS_TO_BUILD="" -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_INCLUDE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release ../llvm-project/llvm
# Run Visual Studio 16 2019, open the generated "LLVM.sln", build all, and build the "INSTALL" project.
Building HIPIFY#
cd %ROOT_DIR%
git clone https://github.com/ROCm/HIPIFY.git
cd build
# To ensure LLVM is found, or in the case of multiple LLVM instances,
# specify the path to the root folder containing the LLVM distribution.
cmake -G "Visual Studio 17 2022" -A x64 -Thost=x64 -DCMAKE_PREFIX_PATH="../dist" -DCMAKE_INSTALL_PREFIX="../dist" -DCMAKE_BUILD_TYPE=Release ../hipify
# Run Visual Studio 17 2022, open the generated LLVM.sln, build all, and build project "INSTALL".
# Alternatively, you can build using "msbuild INSTALL.vcxproj /m" using the developer command prompt.
You can find the binary at ./dist/bin/hipify-clang or at the folder specified by the -DCMAKE_INSTALL_PREFIX option.
Testing hipify-clang#
hipify-clang is equipped with unit tests using LLVM
lit or FileCheck.
We recommend that you build LLVM+Clang from sources, as prebuilt binaries are not exhaustive for testing.
Install CUDA version 7.0 or greater.
In case of multiple CUDA installations, specify the particular version using
DCUDA_TOOLKIT_ROOT_DIRoption:-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9" -DCUDA_SDK_ROOT_DIR="C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.9"
[Optional] Install cuTensor:
To specify the path to cuTensor, use the
CUDA_TENSOR_ROOT_DIRoption:-DCUDA_TENSOR_ROOT_DIR=D:/CUDA/cuTensor/2.4.0.0[Optional] Install cuDNN belonging to the version corresponding to the CUDA version:
To specify the path to cuDNN, use the
CUDA_DNN_ROOT_DIRoption:-DCUDA_DNN_ROOT_DIR=D:/CUDA/cuDNN/9.15.0[Optional] Install CUB 1.9.8 for
CUDA < 11.0only; forCUDA >= 11.0, the CUB shipped with CUDA will be used for testing.To specify the path to CUB, use the
CUDA_CUB_ROOT_DIRoption (only forCUDA < 11.0):-DCUDA_CUB_ROOT_DIR=D:/CUDA/CUBInstall Python version 3.0 or greater.
Install
litandFileCheck; these are distributed with LLVM.lit:python %ROOT_DIR%/llvm-project/llvm/utils/lit/setup.py install
Starting with LLVM 6.0.1, specify the path to the
llvm-litPython script using theLLVM_EXTERNAL_LIToption:-DLLVM_EXTERNAL_LIT=%ROOT_DIR%/llvm-project/llvm/utils/lit/llvm-lit.pyFileCheck:Copy from
%ROOT_DIR%/llvm-project/llvm/utils/FileChecktoCMAKE_INSTALL_PREFIX/dist/bin.To run OpenGL tests successfully, you need to install OpenGL headers and libraries.
No installation required. All the required headers are shipped with the Windows SDK.
Set the
HIPIFY_CLANG_TESTSoption toON:-DHIPIFY_CLANG_TESTS=ON.Build and run tests. Run
Visual Studio 17 2022, open the generatedhipify-clang.sln, to build the projecttest-hipify.
Windows testing#
Tested configurations:
LLVM |
CUDA |
cuDNN |
Visual Studio |
CMake |
Python |
|---|---|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 LLVM 14.x.x is the latest major release supporting Visual Studio 2017.
To build LLVM 14.x.x correctly using Visual Studio 2017, add -DLLVM_FORCE_USE_OLD_TOOLCHAIN=ON
to corresponding CMake command line.
You can also build LLVM < 14.x.x correctly using Visual Studio 2017 without the
LLVM_FORCE_USE_OLD_TOOLCHAIN option.
6 Note that LLVM 17.0.0 was withdrawn due to an issue; use 17.0.1 or newer instead.
7 Note that LLVM 18.0.0 has never been released; use 18.1.0 or newer instead.
Building with testing support using Visual Studio 17 2022 on Windows 11:
cmake \
-G "Visual Studio 17 2022" \
-A x64 \
-Thost=x64 \
-DHIPIFY_CLANG_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=../dist \
-DCMAKE_PREFIX_PATH=%ROOT_DIR%/dist \
-DCUDA_TOOLKIT_ROOT_DIR="C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9" \
-DCUDA_SDK_ROOT_DIR="C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.9" \
-DCUDA_DNN_ROOT_DIR=D:/CUDA/cuDNN/9.15.0 \
-DCUDA_TENSOR_ROOT_DIR=D:/CUDA/cuTensor/2.4.0.0 \
-DLLVM_EXTERNAL_LIT=%ROOT_DIR%/build/Release/bin/llvm-lit.py \
../hipify
The corresponding successful output is (assuming %ROOT_DIR% is D:/LLVM/21.1.7):
-- The C compiler identification is MSVC 19.44.35216.0
-- The CXX compiler identification is MSVC 19.44.35216.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.44.35207/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.44.35207/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
-- - Install clang headers : ON
-- Found LLVM 21.1.7:
-- - CMake module path : D:/LLVM/21.1.7/dist/lib/cmake/llvm
-- - Clang include path : D:/LLVM/21.1.7/dist/include
-- - LLVM Include path : D:/LLVM/21.1.7/dist/include
-- - Binary path : D:/LLVM/21.1.7/dist/bin
-- ---- The below configuring for hipify-clang testing only ----
-- Found Python: C:/Users/TT/AppData/Local/Programs/Python/Python314/python.exe (found suitable version "3.14.0", required range is "3.0...3.15") found components: Interpreter
-- Found lit: C:/Users/TT/AppData/Local/Programs/Python/Python314/Scripts/lit.exe
-- Found FileCheck: D:/LLVM/21.1.7/dist/bin/FileCheck.exe
-- Initial CUDA to configure:
-- - CUDA Toolkit path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9
-- - CUDA Samples path : C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.9
-- - cuDNN path : D:/CUDA/cuDNN/9.15.0
-- - cuTENSOR path : D:/CUDA/cuTensor/2.4.0.0
-- - CUB path :
-- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9/include (found version "12.9.86")
-- Found CUDA config:
-- - CUDA Toolkit path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9
-- - CUDA Samples path : C:/ProgramData/NVIDIA Corporation/CUDA Samples/v12.9
-- - cuDNN path : D:/CUDA/cuDNN/9.15.0/include
-- - cuTENSOR path : D:/CUDA/cuTensor/2.4.0.0/include
-- - CUB path : C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.9/include/cub
-- Configuring done (4.4s)
-- Generating done (0.1s)
-- Build files have been written to: D:/HIPIFY/build