Skip to content
Snippets Groups Projects
Commit 20478dcb authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Make each compile step depends on their own pass/libs so that pass update triggers recompilation

parent edc43964
No related branches found
No related tags found
No related merge requests found
...@@ -48,7 +48,7 @@ set(HPVM_RT_PATH ${PROJECT_BINARY_DIR}/tools/hpvm/projects/hpvm-rt/hpvm-rt.ll) ...@@ -48,7 +48,7 @@ set(HPVM_RT_PATH ${PROJECT_BINARY_DIR}/tools/hpvm/projects/hpvm-rt/hpvm-rt.ll)
# Compile flags (clang++) # Compile flags (clang++)
set(CLANG_FLAGS -fno-exceptions -std=c++11 -O3) set(CLANG_FLAGS -fno-exceptions -std=c++11 -O3)
# All compilation uses HPVM_DEFAULT_PASSES, some can pick from HPVM_OPTIONAL_PASSES # All compilation uses HPVM_DEFAULT_PASSES.
set( set(
HPVM_DEFAULT_PASSES HPVM_DEFAULT_PASSES
LLVMBuildDFG LLVMBuildDFG
...@@ -58,13 +58,6 @@ set( ...@@ -58,13 +58,6 @@ set(
LLVMClearDFG LLVMClearDFG
LLVMGenHPVM LLVMGenHPVM
) )
set(
HPVM_OPTIONAL_PASSES
LLVMDFG2LLVM_CUDNN
LLVMDFG2LLVM_WrapperAPI
)
# Manually specify dependencies because we're not using cmake "normally"
list(APPEND DEPEND clang opt llvm-link hpvm-rt.ll ${HPVM_DEFAULT_PASSES} ${HPVM_OPTIONAL_PASSES})
set(WORK_DIR ${CMAKE_CURRENT_BINARY_DIR}) set(WORK_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(test_compile_targets "") set(test_compile_targets "")
...@@ -78,34 +71,37 @@ function(compile_single_benchmark target src_file extra_passes extra_dfg_flags) ...@@ -78,34 +71,37 @@ function(compile_single_benchmark target src_file extra_passes extra_dfg_flags)
) )
add_custom_command( add_custom_command(
OUTPUT "${WORK_DIR}/${target}.ll" DEPENDS ${src_file} OUTPUT "${WORK_DIR}/${target}.ll" DEPENDS ${src_file} clang
COMMAND ${CMAKE_CXX_COMPILER} ${INCLUDE_COMPILER_STRINGS} ${CLANG_FLAGS} -emit-llvm -S ${src_file} COMMAND ${CMAKE_CXX_COMPILER} ${INCLUDE_COMPILER_STRINGS} ${CLANG_FLAGS} -emit-llvm -S ${src_file}
-o ${WORK_DIR}/${target}.ll -o ${WORK_DIR}/${target}.ll
) )
add_custom_command( add_custom_command(
OUTPUT "${WORK_DIR}/${target}.hpvm.ll" DEPENDS "${WORK_DIR}/${target}.ll" OUTPUT "${WORK_DIR}/${target}.hpvm.ll"
DEPENDS "${WORK_DIR}/${target}.ll" opt LLVMGenHPVM
COMMAND ${LLVM_OPT} -load LLVMGenHPVM.so -genhpvm -globaldce -S ${WORK_DIR}/${target}.ll COMMAND ${LLVM_OPT} -load LLVMGenHPVM.so -genhpvm -globaldce -S ${WORK_DIR}/${target}.ll
-o ${WORK_DIR}/${target}.hpvm.ll -o ${WORK_DIR}/${target}.hpvm.ll
) )
add_custom_command( add_custom_command(
OUTPUT "${WORK_DIR}/${target}.llvm.ll" DEPENDS "${WORK_DIR}/${target}.hpvm.ll" OUTPUT "${WORK_DIR}/${target}.llvm.ll"
DEPENDS "${WORK_DIR}/${target}.hpvm.ll" opt ${HPVM_DEFAULT_PASSES} ${extra_passes}
COMMAND ${LLVM_OPT} ${HPVM_PASSES} -S ${WORK_DIR}/${target}.hpvm.ll COMMAND ${LLVM_OPT} ${HPVM_PASSES} -S ${WORK_DIR}/${target}.hpvm.ll
-o ${WORK_DIR}/${target}.llvm.ll -o ${WORK_DIR}/${target}.llvm.ll
) )
add_custom_command( add_custom_command(
OUTPUT "${WORK_DIR}/${target}.linked.bc" DEPENDS "${WORK_DIR}/${target}.llvm.ll" OUTPUT "${WORK_DIR}/${target}.linked.bc"
DEPENDS "${WORK_DIR}/${target}.llvm.ll" hpvm-rt.ll llvm-link
COMMAND ${LLVM_LINK} ${WORK_DIR}/${target}.llvm.ll ${HPVM_RT_PATH} COMMAND ${LLVM_LINK} ${WORK_DIR}/${target}.llvm.ll ${HPVM_RT_PATH}
-o ${WORK_DIR}/${target}.linked.bc -o ${WORK_DIR}/${target}.linked.bc
) )
add_custom_command( add_custom_command(
OUTPUT "${WORK_DIR}/${target}" DEPENDS "${WORK_DIR}/${target}.linked.bc" OUTPUT "${WORK_DIR}/${target}"
DEPENDS "${WORK_DIR}/${target}.linked.bc" tensor_runtime gpu_profiler promise_profiler
COMMAND ${CMAKE_CXX_COMPILER} COMMAND ${CMAKE_CXX_COMPILER}
${WORK_DIR}/${target}.linked.bc ${WORK_DIR}/${target}.linked.bc
$<TARGET_FILE:tensor_runtime> $<TARGET_FILE:gpu_profiler> $<TARGET_FILE:promise_profiler> $<TARGET_FILE:tensor_runtime> $<TARGET_FILE:gpu_profiler> $<TARGET_FILE:promise_profiler>
-o ${WORK_DIR}/${target} ${LINKER_FLAGS} -o ${WORK_DIR}/${target} ${LINKER_FLAGS}
) )
add_custom_target(${target} DEPENDS "${WORK_DIR}/${target}") add_custom_target(${target} DEPENDS "${WORK_DIR}/${target}")
add_dependencies(${target} ${DEPEND})
set(test_compile_targets ${test_compile_targets} ${target} PARENT_SCOPE) set(test_compile_targets ${test_compile_targets} ${target} PARENT_SCOPE)
endfunction(compile_single_benchmark) endfunction(compile_single_benchmark)
......
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