update READMe.md

This commit is contained in:
Han Ruobing 2022-05-04 21:11:25 -04:00
parent a7969e8f74
commit e503709480
1 changed files with 63 additions and 43 deletions

106
README.md
View File

@ -1,62 +1,82 @@
# COX: CUDA on X86 # CuPBoP: Cuda for Parallelized and Broad-range Processors
## Introduction ## Introduction
This project consists of two parts: a series of LLVM passes that CuPBoP is a framework which support executing unmodified CUDA source code
achieve a SPMD NVVM IR as input, and output the corresponding on non-NVIDIA devices.
MPMD+SIMD version of LLVM IR which can be execute on CPU devices. Currently, CuPBoP support serveral CPU backends, including x86, AArch64, and RISC-V.
## Install ## Install
### Prerequisites ### Prerequisites
* Linux: Verified on Ubuntu 18.04 - Linux: Verified on Ubuntu 18.04
* LLVM10.0 - LLVM10.0
* NVIDIA CUDA-toolkit - NVIDIA CUDA-toolkit
* x86 CPU - x86 CPU
* pthread - pthread
* GCC 7.5.0 - GCC 7.5.0
### Installation ### Installation
1. Clone from github 1. Clone from github
```bash ```bash
git clone https://github.com/drcut/open_source_template git clone https://github.com/cupbop/CuPBoP
cd open_source_template cd CuPBoP
``` export CuPBoP_PATH=`pwd`
export LD_LIBRARY_PATH=$CuPBoP_PATH/build/runtime:$CuPBoP_PATH/build/runtime/threadPool:$LD_LIBRARY_PATH
```
2. Build the transformer for NVVM IR to LLVM IR for X86 2. As CuPBoP relies on CUDA structures, we need to download the CUDA header file
```bash ```bash
mkdir build && cd build wget https://www.dropbox.com/s/r18io0zu3idke5p/cuda-header.tar.gz?dl=1
cmake .. -DLLVM_CONFIG_PATH=`which llvm-config` # need path to llvm-config tar -xzf 'cuda-header.tar.gz?dl=1'
make cp -r include/* runtime/threadPool/include/
``` ```
## Run Vecadd samples 3. Other CUDA files are also required for compiling CUDA source code to LLVM IR
```bash
wget https://www.dropbox.com/s/4pckqsjnl920gpn/cuda-10.1.tar.gz?dl=1
tar -xzf 'cuda-10.1.tar.gz?dl=1'
```
4. Build CuPBoP
```bash
mkdir build && cd build
cmake .. -DLLVM_CONFIG_PATH=`which llvm-config` # need path to llvm-config
make
```
## Run HIST application in Hetero-mark benchmark
```bash ```bash
# Generate bitcode from human-readable LLVM IR # Clone Hetero-mark benchmark
llvm-as ../compilation/examples/vecadd/kernel-cuda-nvptx64-nvidia-cuda-sm_61.ll git clone https://github.com/drcut/SC_evaluate
# use LLVM passes to transform NVVM IR (SPMD) to LLVM IR (MPMD+SIMD). cd SC_evaluate/Hetero-cox/src/hist
# NOTE: we hard-code the grid size (1, 1, 1) # Compile CUDA source code to LLVM IR
# and block size (1024, 1, 1) into the generated LLVM IR # this may raise error due to absence of CUDA library, just ignore them
./compilation/nvvm2x86 \ clang++ -std=c++11 cuda/hist_cuda_benchmark.cu \\
../compilation/examples/vecadd/kernel-cuda-nvptx64-nvidia-cuda-sm_61.bc \ -I../.. --cuda-path=$CuPBoP_PATH/cuda-10.1 \\
kernel.bc 1 1 1 32 1 1 --cuda-gpu-arch=sm_50 -L$CuPBoP_PATH/cuda-10.1/lib64 \\
# generate object file from LLVM IR -lcudart_static -ldl -lrt -pthread -save-temps -v || true
llc --filetype=obj kernel.bc # Translate host/kernel LLVM IR to formats that suitable for CPU
# link generated kernel function $CuPBoP_PATH/build/compilation/kernelTranslator hist_cuda_benchmark-cuda-nvptx64-nvidia-cuda-sm_50.bc kernel.bc
# with host function and generate excutable file $CuPBoP_PATH/build/compilation/hostTranslator hist_cuda_benchmark-host-x86_64-unknown-linux-gnu.bc host.bc
g++ ../compilation/examples/vecadd/host.cpp \ # generate object files
kernel.o -lpthread -o vecadd_example llc --relocation-model=pic --filetype=obj kernel.bc
# execute the executable file llc --relocation-model=pic --filetype=obj host.bc
./vecadd_example # generate CPU executable file
g++ -o hist -fPIC -no-pie \\
-I$CuPBoP_PATH/runtime/threadPool/include \\
-L$CuPBoP_PATH/build/runtime \\
-L$CuPBoP_PATH/build/runtime/threadPool \\
cuda/main.cc host.o kernel.o *.cc ../common/benchmark/*.cc \\
../common/command_line_option/*.cc ../common/time_measurement/*.cc \\
-I../.. -lpthread -lc -lx86Runtime -lthreadPool
# execute and verify
./hist -q -v
``` ```
## Author
[Ruobing Han](https://drcut.github.io/) is a CS phd student in
Georgia Institute Technology, under the supervision
of Prof. [Hyesoon Kim](https://www.cc.gatech.edu/~hyesoon/).