ATTENTION: Remember to check branch for every repository, cause the project are under development, if you get any build errors, feel free to give an issue or just contact authors
2: Build all the programs
Our program is based on LLVM, so the need packages to build ventus are almost the same as what are needed to build LLVM, you can refer to official website for detailed llvm building guidance, we just list most important needed packages here.
ccache
cmake
ninja
clang(optional)
If you see any packages missing information, just install them
The following packages are needed for other repositories:
device-tree-compiler
bsdmainutils
Run ./build-ventus.sh to automatically build all the programs, but we need to run firstly
For developers who want to build Debug version for llvm, export BUILD_TYPE=Debug, since it’s set default to be ‘Release’
export POCL_DIR=<path-to-pocl-dir>, default folder path will be set to be <llvm-ventus-parentFolder>/pocl
export OCL_ICD_DIR=<path-to-ocl-icd-dir>, default folder path will be set to be <llvm-ventus-parentFolder>/ocl-icd
You can dive into build-ventus.sh file to see the detailed information about build process
3: Bridge icd loader
Run export VENTUS_INSTALL_PREFIX=<path_to_install> to set VENTUS_INSTALL_PREFIX environment variable(system environment variable recommended)
Run export LD_LIBRARY_PATH=${VENTUS_INSTALL_PREFIX}/lib to tell OpenCL application to use your own built libOpenCL.so, also to correctly locate LLVM shared libraries
Run export OCL_ICD_VENDORS=${VENTUS_INSTALL_PREFIX}/lib/libpocl.so to tell ocl icd loader where the icd driver is.
Finally, run export POCL_DEVICES="ventus" to tell pocl driver which device is available(should we set ventus as default device?).
You will see Ventus GPGPU device is found if your setup is correct.
NOTE: OpenCL host side program should be linked with icd loader -lOpenCL.
$ <pocl-install-dir>/bin/poclcc -l
LIST OF DEVICES:
0:
Vendor: THU
Name: Ventus GPGPU device
Version: 2.2 HSTR: THU-ventus-gpgpu
Also, you can try to set POCL_DEBUG=all and run example under <pocl-build-dir> to see the full OpenCL software stack execution pipeline. For example(Work in progress).
4: Compiler using example
we can now use our built compiler to generate an ELF file, and using spike to complete the isa simulation.
Cause the address space requirement in spike, we use a customized linker script for our compiler
Take vecadd.cl below as an example :
__kernel void vectorAdd(__global float* A, __global float* B) {
unsigned tid = get_global_id(0);
A[tid] += B[tid];
}
4.1: Generate ELF file
4.1.1 Compile directly
Remember to build libclc too because we need the libclc library
Use command line under the root directory of llvm-ventus
you will see output like below, 0x80000000 is the space address required by spike for _start function, this is the reason why we use a customized linker script
Accordingly, after all the building process, you can change directory to <llvm-ventus-parentFolder>/pocl/build/examples/vecadd directory, then export variables as what Bridge icd loader does, finally just execute the file vecadd
5: Github actions
the workflow file is .github/workflows/ventus-build.yml, including below jobs
This is the Ventus GPGPU port of LLVM Compiler Infrastructure
Ventus GPGPU is based on RISCV RV32IMAZfinxZve32f ISA with fully redefined concept of V-extension.
The Ventus GPGPU OpenCL compiler based on LLVM is developed by Terapines Technology (Wuhan) Co., Ltd
承影GPGPU OpenCL编译器由Terapines(兆松科技)负责开发
For more architecture detail, please refer to Ventus GPGPU Arch
Getting Started
1: Programs related repositories
Download all the repositories firstly and place them in the same path.
2: Build all the programs
Our program is based on LLVM, so the need packages to build ventus are almost the same as what are needed to build LLVM, you can refer to official website for detailed llvm building guidance, we just list most important needed packages here.
The following packages are needed for other repositories:
Run
./build-ventus.sh
to automatically build all the programs, but we need to run firstlyDebug
version for llvm,export BUILD_TYPE=Debug
, since it’s set default to be ‘Release’export POCL_DIR=<path-to-pocl-dir>
, default folder path will be set to be<llvm-ventus-parentFolder>
/poclexport OCL_ICD_DIR=<path-to-ocl-icd-dir>
, default folder path will be set to be<llvm-ventus-parentFolder>
/ocl-icdYou can dive into
build-ventus.sh
file to see the detailed information about build process3: Bridge icd loader
Run
export VENTUS_INSTALL_PREFIX=<path_to_install>
to setVENTUS_INSTALL_PREFIX
environment variable(system environment variable recommended)Run
export LD_LIBRARY_PATH=${VENTUS_INSTALL_PREFIX}/lib
to tell OpenCL application to use your own builtlibOpenCL.so
, also to correctly locate LLVM shared librariesRun
export OCL_ICD_VENDORS=${VENTUS_INSTALL_PREFIX}/lib/libpocl.so
to tell ocl icd loader where the icd driver is.Finally, run
export POCL_DEVICES="ventus"
to tell pocl driver which device is available(should we set ventus as default device?).You will see Ventus GPGPU device is found if your setup is correct.
NOTE: OpenCL host side program should be linked with icd loader
-lOpenCL
.Also, you can try to set
POCL_DEBUG=all
and run example under<pocl-build-dir>
to see the full OpenCL software stack execution pipeline. For example(Work in progress).4: Compiler using example
we can now use our built compiler to generate an ELF file, and using spike to complete the isa simulation.
Take
vecadd.cl
below as an example :4.1: Generate ELF file
4.1.1 Compile directly
Use command line under the root directory of
llvm-ventus
4.1.2 Compile step-by-step
riscv32clc.o
4.1.3 compile assembly code to object file (
.s
to.o
)Take custome instructions
custome.s
as an example :4.2: Dump file
you will see output like below,
0x80000000
is the space address required by spike for_start
function, this is the reason why we use a customized linker scriptor you can check encoding of custom instructions
4.3: Running in spike
We need to run the isa simulator to verify our compiler
Use spike from THU and follow the
README.md
4.4: Driver using example
Accordingly, after all the building process, you can change directory to
<llvm-ventus-parentFolder>/pocl/build/examples/vecadd
directory, then export variables as what Bridge icd loader does, finally just execute the filevecadd
5: Github actions
the workflow file is
.github/workflows/ventus-build.yml
, including below jobs