-
Yifan Zhao authoredYifan Zhao authored
compilation.md 1.78 KiB
HPVM Compilation Process
Compilation of an HPVM program involves the following steps:
-
clangtakes an HPVM-C/C++ program (e.g.main.c) and produces an LLVM IR (main.ll) file that contains the HPVM-C function calls. The declarations of these functions are defined intest/benchmark/include/hpvm.h, which must be included in the program. -
opttakes (main.ll) and invoke the GenHPVM pass on it, which converts the HPVM-C function calls to HPVM intrinsics. This generates the HPVM textual representation (main.hpvm.ll). -
opttakes the HPVM textual representation (main.hpvm.ll) and invokes the following passes in sequence:- BuildDFG: Converts the textual representation to the internal HPVM representation.
- LocalMem and DFG2LLVM_OpenCL: Invoked only when GPU target is selected. Generates the kernel module (
main.kernels.ll) and the portion of the host code that invokes the kernel into the host module (main.host.ll). - DFG2LLVM_CPU: Generates either all, or the remainder of the host module (
main.host.ll) depending on the chosen target. - ClearDFG: Deletes the internal HPVM representation from memory.
-
clangis used to to compile any remaining project files that would be later linked with the host module. -
llvm-linktakes the host module and all the other generatellfiles, and links them with the HPVM runtime module (hpvm-rt.bc), to generate the linked host module (main.host.linked.ll). - Generate the executable code from the generated
llfiles for all parts of the program:- GPU target:
llvm-cbetakes the kernel module (main.kernels.ll) and generates an OpenCL representation of the kernels that will be invoked by the host. - CPU target:
clangtakes the linked host module (main.host.linked.ll) and generates the CPU binary.
- GPU target: