Skip to content
Snippets Groups Projects
Commit 10db78d0 authored by Hashim Sharif's avatar Hashim Sharif
Browse files

Merging approx_hpvm_reorg CMake changes in

parents 014fc8d3 448c79fc
No related branches found
No related tags found
No related merge requests found
......@@ -21,12 +21,14 @@ HPVM is currently at version 0.5. For more about what HPVM is, see [our website]
## Dependencies
The following components are required to be installed on your machine to build HPVM.
* GCC (>=5.1.0)
* CMake (>=3.17.0)
* Python (>=2.7)
* GNU Make (>=3.79.1)
* OpenCL (>=1.0.0) or CUDA (>=9.1, only required for GPU support)
* GCC (>=5.1)
* In addition, each version of CUDA-nvcc requires GCC to be not newer than a certain version.
See [here](https://gist.github.com/ax3l/9489132) for the support matrix.
* CMake (>=3.17)
* Python (>=3.7) with Pip
* GNU Make (>=3.79)
* OpenCL (>=1.0.0)
* CUDA (>=9.1)
## Supported Targets
Supported/tested CPU architectures:
......@@ -45,17 +47,20 @@ HPVM has not been tested but might work on other CPUs supported by LLVM Backend,
Checkout HPVM:
```shell
git clone https://gitlab.engr.illinois.edu/llvm/hpvm-release.git/
git clone --recursive https://gitlab.engr.illinois.edu/llvm/hpvm-release.git/
cd hpvm-release/hpvm
```
Before installing HPVM, some paths must be set for installation to succeed. The following variables in set_paths.sh must be set:
HPVM needs to be able to find CUDA.
If CUDA is installed in your system's $PATH (e.g. if it was installed at the default location),
HPVM can find CUDA automatically.
Otherwise, some environment variables are required:
* CUDA_TOOLKIT_PATH --- Path to the CUDA toolkit
* CUDA_INCLUDE_PATH --- Path to the CUDA headers
* CUDA_LIB_PATH -- Path to CUDA libraries
* `CUDA_TOOLKIT_PATH` --- Path to the CUDA toolkit
* `CUDA_INCLUDE_PATH` --- Path to the CUDA headers
* `CUDA_LIB_PATH` --- Path to CUDA libraries
Once the aforementioned variables in set_paths.sh have been specified, run the script.
`hpvm/set_paths.sh` can be used for this. Modify the values of these variables in set_paths.sh and source the script:
```shell
source set_paths.sh
```
......@@ -78,6 +83,9 @@ mkdir build
cd build
cmake ../llvm [options]
```
**Note** that if the installer script was not used,
you must _manually add `build/bin` directory to your $PATH variable_ (as absolute path).
Some common options that can be used with CMake are:
* -DCMAKE_INSTALL_PREFIX=directory --- Specify for directory the full pathname of where you want the HPVM tools and libraries to be installed.
......@@ -112,5 +120,3 @@ We are also providing [unit tests](/hpvm/test/unitTests) and [regression tests](
## Support
All questions can be directed to [hpvm-dev@lists.cs.illinois.edu](mailto:hpvm-dev@lists.cs.illinois.edu).
No preview for this file type
File added
No preview for this file type
File added
......@@ -231,6 +231,8 @@ if [ ! -d $INSTALL_DIR ]; then
mkdir -p $INSTALL_DIR
fi
export PATH=$BUILD_DIR/bin:$PATH
cd $BUILD_DIR
echo cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD=$TARGET -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD=$TARGET -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR
......
......@@ -52,8 +52,8 @@ set(
)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/bin/approxhpvm.py
COMMAND mv ${CMAKE_CURRENT_BINARY_DIR}/main.py ${PROJECT_BINARY_DIR}/bin/approxhpvm.py
COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/main.py ${PROJECT_BINARY_DIR}/bin/approxhpvm.py
COMMAND chmod +x ${PROJECT_BINARY_DIR}/bin/approxhpvm.py
DEPENDS ${DEPS} ${CMAKE_CURRENT_BINARY_DIR}/main.py
)
add_custom_target(approxhpvm.py DEPENDS ${PROJECT_BINARY_DIR}/bin/approxhpvm.py)
add_custom_target(approxhpvm.py ALL DEPENDS ${PROJECT_BINARY_DIR}/bin/approxhpvm.py)
#!/usr/bin/env python
#!/usr/bin/env python3
import argparse
import os
from pathlib import Path
......@@ -7,7 +7,7 @@ from typing import List, Union, Optional
PathLike = Union[Path, str]
HPVM_PROJECT_DIR = Path("@LLVM_PROJECT_DIR@") / "tools/hpvm"
LLVM_BUILD_DIR = Path("@LLVM_BUILD_DIR@")
LLVM_BUILD_DIR = Path("@LLVM_BUILD_DIR@") / "bin"
CUDA_TOOLKIT_ROOT_DIR = Path("@CUDA_TOOLKIT_ROOT_DIR@")
TENSOR_RUNTIME_LIBS = "@TENSOR_RUNTIME_LIBS@".split(";")
AVAILABLE_PASSES = "@AVAILABLE_PASSES@".split(";")
......@@ -74,7 +74,7 @@ def hpvm_c_to_ll(
includes = [f"-I{path}" for path in INCLUDE_DIRS + extra_includes]
flags = [f"-{flg}" for flg in (flags or []) + COMPILE_FLAGS]
return [
"clang++", *includes, *flags, "-emit-llvm", "-S",
str(LLVM_BUILD_DIR / "clang++"), *includes, *flags, "-emit-llvm", "-S",
str(src_file), "-o", str(target_file)
]
......@@ -114,14 +114,14 @@ def opt_codegen_tensor(
def link_hpvm_rt(src_file: PathLike, target_file: PathLike) -> List[str]:
return ["llvm-link", str(src_file), HPVM_RT_PATH, "-o", str(target_file)]
return [str(LLVM_BUILD_DIR / "llvm-link"), str(src_file), HPVM_RT_PATH, "-o", str(target_file)]
def link_binary(src_file: PathLike, target_file: PathLike) -> List[str]:
linker_dir_flags = [f"-L{path}" for path in LINK_DIRS]
linker_lib_flags = [f"-l{lib}" for lib in LINK_LIBS]
return [
"clang++", str(src_file), *TENSOR_RUNTIME_LIBS, "-o", str(target_file),
str(LLVM_BUILD_DIR / "clang++"), str(src_file), *TENSOR_RUNTIME_LIBS, "-o", str(target_file),
*linker_dir_flags, *linker_lib_flags
]
......@@ -138,7 +138,7 @@ def _run_opt(
load_passes_strs = [s for pass_ in pass_names for s in ["-load", f"{pass_}.so"]]
pass_flags_strs = [f"-{flag}" for flag in pass_flags]
return [
"opt", *load_passes_strs, *pass_flags_strs,
str(LLVM_BUILD_DIR / "opt"), *load_passes_strs, *pass_flags_strs,
"-S", str(src_file), "-o", str(target_file)
]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment