From 2133ce3d5a20d29b93cf11326575e40b9bf92208 Mon Sep 17 00:00:00 2001 From: Tianqi Chen Date: Sun, 10 Jun 2018 22:00:33 -0700 Subject: [PATCH] [BUILD] Switch to CMake only Infra (#1254) --- .gitignore | 7 +- CMakeLists.txt | 227 ++++------- Jenkinsfile | 124 +++--- Makefile | 374 +++--------------- cmake/config.cmake | 87 ++++ cmake/modules/CUDA.cmake | 76 ++++ cmake/modules/LLVM.cmake | 26 ++ cmake/modules/Metal.cmake | 18 + cmake/modules/OpenCL.cmake | 19 + cmake/modules/OpenGL.cmake | 19 + cmake/modules/ROCM.cmake | 34 ++ cmake/modules/Vulkan.cmake | 31 ++ cmake/modules/contrib/BLAS.cmake | 24 ++ cmake/modules/contrib/NNPack.cmake | 14 + cmake/modules/contrib/Random.cmake | 5 + cmake/modules/contrib/Sort.cmake | 5 + cmake/util/FindLLVM.cmake | 39 ++ cmake/{ => util}/Util.cmake | 22 +- docs/install/index.rst | 41 +- docs/install/nnpack.md | 3 +- include/tvm/runtime/config.h | 30 -- .../src/main/assembly/assembly.xml | 2 +- .../src/main/assembly/assembly.xml | 2 +- .../src/main/assembly/assembly.xml | 2 +- jvm/core/pom.xml | 4 +- make/config.mk | 95 ----- make/contrib/cblas.mk | 17 - make/contrib/cublas.mk | 8 - make/contrib/cudnn.mk | 8 - make/contrib/miopen.mk | 8 - make/contrib/mps.mk | 20 - make/contrib/nnpack.mk | 12 - make/contrib/random.mk | 6 - make/contrib/rocblas.mk | 8 - make/contrib/sort.mk | 6 - src/codegen/codegen_cuda.cc | 1 - src/codegen/codegen_metal.cc | 1 - src/codegen/codegen_opencl.cc | 1 - src/codegen/codegen_opengl.cc | 1 - src/codegen/llvm/codegen_amdgpu.cc | 1 - src/codegen/llvm/codegen_nvptx.cc | 2 - src/codegen/opt/README | 1 + src/codegen/opt/build_cuda_off.cc | 18 + .../{build_cuda.cc => opt/build_cuda_on.cc} | 15 +- .../{build_metal.cc => opt/build_metal.h} | 15 +- src/codegen/opt/build_metal_off.cc | 6 + src/codegen/opt/build_metal_on.cc | 6 + .../{build_opencl.cc => opt/build_opencl.h} | 14 +- src/codegen/opt/build_opencl_off.cc | 6 + src/codegen/opt/build_opencl_on.cc | 6 + .../{build_opengl.cc => opt/build_opengl.h} | 10 +- src/codegen/opt/build_opengl_off.cc | 6 + src/codegen/opt/build_opengl_on.cc | 6 + src/runtime/cuda/cuda_common.h | 6 +- src/runtime/cuda/cuda_device_api.cc | 3 - src/runtime/cuda/cuda_module.cc | 3 - src/runtime/cuda/cuda_module.h | 1 - src/runtime/metal/metal_common.h | 1 - src/runtime/metal/metal_device_api.mm | 6 +- src/runtime/metal/metal_module.h | 1 - src/runtime/metal/metal_module.mm | 6 +- src/runtime/opencl/opencl_common.h | 3 - src/runtime/opencl/opencl_device_api.cc | 7 +- src/runtime/opencl/opencl_module.cc | 10 +- src/runtime/opencl/opencl_module.h | 1 - src/runtime/opengl/opengl_common.h | 1 - src/runtime/opengl/opengl_device_api.cc | 9 +- src/runtime/opengl/opengl_module.cc | 8 +- src/runtime/opengl/opengl_module.h | 1 - src/runtime/rocm/rocm_common.h | 20 +- src/runtime/rocm/rocm_device_api.cc | 3 - src/runtime/rocm/rocm_module.cc | 6 +- src/runtime/rocm/rocm_module.h | 1 - src/runtime/vulkan/vulkan_common.h | 4 - src/runtime/vulkan/vulkan_device_api.cc | 8 +- src/runtime/vulkan/vulkan_module.cc | 6 +- src/runtime/vulkan/vulkan_module.h | 1 - tests/scripts/task_build.sh | 7 +- tests/scripts/task_clean.sh | 5 +- tests/scripts/task_cpp_unittest.sh | 4 +- tests/scripts/task_java_unittest.sh | 3 +- tests/scripts/task_python_integration.sh | 2 +- 82 files changed, 729 insertions(+), 947 deletions(-) create mode 100644 cmake/config.cmake create mode 100644 cmake/modules/CUDA.cmake create mode 100644 cmake/modules/LLVM.cmake create mode 100644 cmake/modules/Metal.cmake create mode 100644 cmake/modules/OpenCL.cmake create mode 100644 cmake/modules/OpenGL.cmake create mode 100644 cmake/modules/ROCM.cmake create mode 100644 cmake/modules/Vulkan.cmake create mode 100644 cmake/modules/contrib/BLAS.cmake create mode 100644 cmake/modules/contrib/NNPack.cmake create mode 100644 cmake/modules/contrib/Random.cmake create mode 100644 cmake/modules/contrib/Sort.cmake create mode 100644 cmake/util/FindLLVM.cmake rename cmake/{ => util}/Util.cmake (72%) delete mode 100644 include/tvm/runtime/config.h delete mode 100644 make/config.mk delete mode 100644 make/contrib/cblas.mk delete mode 100644 make/contrib/cublas.mk delete mode 100644 make/contrib/cudnn.mk delete mode 100644 make/contrib/miopen.mk delete mode 100644 make/contrib/mps.mk delete mode 100644 make/contrib/nnpack.mk delete mode 100644 make/contrib/random.mk delete mode 100644 make/contrib/rocblas.mk delete mode 100644 make/contrib/sort.mk create mode 100644 src/codegen/opt/README create mode 100644 src/codegen/opt/build_cuda_off.cc rename src/codegen/{build_cuda.cc => opt/build_cuda_on.cc} (91%) rename src/codegen/{build_metal.cc => opt/build_metal.h} (80%) create mode 100644 src/codegen/opt/build_metal_off.cc create mode 100644 src/codegen/opt/build_metal_on.cc rename src/codegen/{build_opencl.cc => opt/build_opencl.h} (78%) create mode 100644 src/codegen/opt/build_opencl_off.cc create mode 100644 src/codegen/opt/build_opencl_on.cc rename src/codegen/{build_opengl.cc => opt/build_opengl.h} (80%) create mode 100644 src/codegen/opt/build_opengl_off.cc create mode 100644 src/codegen/opt/build_opengl_on.cc diff --git a/.gitignore b/.gitignore index 1d5db4cfebfdb..7080502aaf86e 100644 --- a/.gitignore +++ b/.gitignore @@ -172,16 +172,19 @@ cscope* # TVM generated code perf - +.bash_history *.json *.params *.onnx *.h5 synset.txt cat.jpg - +docs.tgz +cat.png +*.mlmodel # Mac OS X .DS_Store +build* # Jetbrain .idea diff --git a/CMakeLists.txt b/CMakeLists.txt index f3521433a6548..84ce87d84e765 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,14 @@ -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.5) project(tvm C CXX) +# Utility functions +include(cmake/util/Util.cmake) +include(cmake/util/FindLLVM.cmake) + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake) endif() -include(cmake/Util.cmake) - if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake) else() @@ -19,31 +21,43 @@ endif() # You can create a config.cmake at build folder # and add set(OPTION VALUE) to override these build options. # Alernatively, use cmake -DOPTION=VALUE through command-line. - tvm_option(USE_CUDA "Build with CUDA" OFF) tvm_option(USE_OPENCL "Build with OpenCL" OFF) tvm_option(USE_VULKAN "Build with Vulkan" OFF) tvm_option(USE_OPENGL "Build with OpenGL" OFF) tvm_option(USE_METAL "Build with Metal" OFF) +tvm_option(USE_ROCM "Build with ROCM" OFF) +tvm_option(ROCM_PATH "The path to rocm" /opt/rocm) tvm_option(USE_RPC "Build with RPC" ON) +tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" OFF) tvm_option(USE_GRAPH_RUNTIME "Build with tiny graph runtime" ON) -tvm_option(USE_LLVM "Build with LLVM" OFF) +tvm_option(USE_GRAPH_RUNTIME_DEBUG "Build with tiny graph runtime debug mode" OFF) tvm_option(USE_RTTI "Build with RTTI" ON) tvm_option(USE_MSVC_MT "Build with MT" OFF) tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF) +# Contrib library options +tvm_option(USE_BLAS "The blas library to be linked" none) tvm_option(USE_CUDNN "Build with cuDNN" OFF) - +tvm_option(USE_CUBLAS "Build with cuBLAS" OFF) +tvm_option(USE_MIOPEN "Build with ROCM:MIOpen" OFF) +tvm_option(USE_ROCBLAS "Build with ROCM:RoCBLAS" OFF) +tvm_option(USE_SORT "Build with sort support" OFF) +tvm_option(USE_NNPACK "Build with nnpack support" OFF) +tvm_option(USE_RANDOM "Build with random support" OFF) + +# include directories include_directories(BEFORE "nnvm/include") include_directories("include") include_directories("HalideIR/src") include_directories("dlpack/include") +include_directories("topi/include") - +# initial variables set(TVM_LINKER_LIBS "") set(TVM_RUNTIME_LINKER_LIBS "") -# compile +# Generic compilation options if(MSVC) add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-D_CRT_SECURE_NO_WARNINGS) @@ -70,11 +84,12 @@ endif(MSVC) # add source group FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp" "nnvm/src/*.cc") -FILE(GLOB_RECURSE GROUP_Include "src/*.h" "include/*.h" "HalideIR/src/*.h" +FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h" "HalideIR/src/*.h" "nnvm/src/*.h" "nnvm/include/*.h") assign_source_group("Source" ${GROUP_SOURCE}) -assign_source_group("Include" ${GROUP_Include}) +assign_source_group("Include" ${GROUP_INCLUDE}) +# Source file lists file(GLOB COMPILER_SRCS src/api/*.cc src/arithmetic/*.cc @@ -86,6 +101,11 @@ file(GLOB COMPILER_SRCS src/schedule/*.cc ) +if(NOT MSVC) + file(GLOB COMPILER_VERILOG_SRCS src/codegen/verilog/*.cc) + list(APPEND COMPILER_SRCS ${COMPILER_VERILOG_SRCS}) +endif() + file(GLOB_RECURSE NNVM_COMPILER_SRCS nnvm/src/c_api/*.cc nnvm/src/core/*.cc @@ -94,157 +114,34 @@ file(GLOB_RECURSE NNVM_COMPILER_SRCS nnvm/src/top/*.cc ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/topi/include) file(GLOB TOPI_SRCS topi/src/*.cc ) file(GLOB_RECURSE HALIDEIR_SRCS HalideIR/src/*.cpp) list(APPEND COMPILER_SRCS ${HALIDEIR_SRCS}) file(GLOB RUNTIME_SRCS src/runtime/*.cc) -file(GLOB COMPILER_LLVM_SRCS src/codegen/llvm/*.cc) -file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc) -file(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc) -file(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) -file(GLOB RUNTIME_OPENGL_SRCS src/runtime/opengl/*.cc) -file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/*.cc) -file(GLOB RUNTIME_METAL_SRCS src/runtime/metal/*.mm) -file(GLOB RUNTIME_RPC_SRCS src/runtime/rpc/*.cc) -file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc) - -if(USE_CUDA) -find_package(CUDA) -# Find CUDA doesn't find all the libraries we need, add the extra ones -find_library(CUDA_CUDA_LIBRARIES cuda - PATHS ${CUDA_TOOLKIT_ROOT_DIR} - PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs) -find_library(CUDA_NVRTC_LIBRARIES nvrtc - PATHS ${CUDA_TOOLKIT_ROOT_DIR} - PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs) - set(CUDA_CUDA_LIBRARY ${CUDA_CUDA_LIBRARIES}) - find_package(CUDA QUIET REQUIRED) - message(STATUS "Build with CUDA support") - include_directories(${CUDA_INCLUDE_DIRS}) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDART_LIBRARY}) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDA_LIBRARY}) - list(APPEND RUNTIME_SRCS ${RUNTIME_CUDA_SRCS}) - if(MSVC) - find_library(CUDA_NVRTC_LIB nvrtc - ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) - list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB}) - else(MSVC) - find_library(CUDA_NVRTC_LIB nvrtc - ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib) - list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB}) - endif(MSVC) - - if(USE_CUDNN) - message(STATUS "Build with cuDNN support") - file(GLOB CONTRIB_CUDNN_SRCS src/contrib/cudnn/*.cc) - list(APPEND RUNTIME_SRCS ${CONTRIB_CUDNN_SRCS}) - if(MSVC) - find_library(CUDA_CUDNN_LIB cudnn - ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB}) - else(MSVC) - find_library(CUDA_CUDNN_LIB cudnn - ${CUDA_TOOLKIT_ROOT_DIR}/lib64 - ${CUDA_TOOLKIT_ROOT_DIR}/lib) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB}) - endif(MSVC) - endif(USE_CUDNN) - - add_definitions(-DTVM_CUDA_RUNTIME=1) -else(USE_CUDA) - add_definitions(-DTVM_CUDA_RUNTIME=0) -endif(USE_CUDA) - -if(USE_OPENCL) - find_package(OpenCL QUIET REQUIRED) - message(STATUS "Build with OpenCL support") - include_directories(${OpenCL_INCLUDE_DIRS}) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES}) - list(APPEND RUNTIME_SRCS ${RUNTIME_OPENCL_SRCS}) - add_definitions(-DTVM_OPENCL_RUNTIME=1) -else(USE_OPENCL) - add_definitions(-DTVM_OPENCL_RUNTIME=0) -endif(USE_OPENCL) - -if(USE_OPENGL) - find_package(OpenGL QUIET REQUIRED) - find_package(glfw3 QUIET REQUIRED) - message(STATUS "Build with OpenGL support") - include_directories(${OPENGL_INCLUDE_DIRS}) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenGL_LIBRARIES} glfw) - list(APPEND RUNTIME_SRCS ${RUNTIME_OPENGL_SRCS}) - add_definitions(-DTVM_OPENGL_RUNTIME=1) -else(USE_OPENGL) - add_definitions(-DTVM_OPENGL_RUNTIME=0) -endif(USE_OPENGL) - -if(USE_VULKAN) - find_package(Vulkan REQUIRED) - message(STATUS "Build with VULKAN support") - include_directories(${Vulkan_INCLUDE_DIRS}) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${Vulkan_LIBRARIES}) - list(APPEND RUNTIME_SRCS ${RUNTIME_VULKAN_SRCS}) - list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS}) - get_filename_component(VULKAN_LIB_PATH ${Vulkan_LIBRARY} DIRECTORY) - find_library(SPIRV_TOOLS_LIB SPIRV-Tools - ${VULKAN_LIB_PATH}/spirv-tools) - list(APPEND TVM_LINKER_LIBS ${SPIRV_TOOLS_LIB}) - add_definitions(-DTVM_VULKAN_RUNTIME=1) -else(USE_VULKAN) - add_definitions(-DTVM_VULKAN_RUNTIME=0) -endif(USE_VULKAN) - -if(USE_METAL) - find_package(OpenCL QUIET REQUIRED) - message(STATUS "Build with Metal support") - FIND_LIBRARY(METAL_LIB Metal) - FIND_LIBRARY(FOUNDATION_LIB Foundation) - list(APPEND TVM_RUNTIME_LINKER_LIBS ${METAL_LIB} ${FOUNDATION_LIB}) - list(APPEND RUNTIME_SRCS ${RUNTIME_METAL_SRCS}) - add_definitions(-DTVM_METAL_RUNTIME=1) -else(USE_METAL) - add_definitions(-DTVM_METAL_RUNTIME=0) -endif(USE_METAL) +# Package runtime rules +if(NOT USE_RTTI) + add_definitions(-DDMLC_ENABLE_RTTI=0) +endif() if(USE_RPC) message(STATUS "Build with RPC support...") + file(GLOB RUNTIME_RPC_SRCS src/runtime/rpc/*.cc) list(APPEND RUNTIME_SRCS ${RUNTIME_RPC_SRCS}) endif(USE_RPC) if(USE_GRAPH_RUNTIME) message(STATUS "Build with Graph runtime support...") + file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc) list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_SRCS}) -endif(USE_GRAPH_RUNTIME) - -if(USE_LLVM) - find_package(LLVM CONFIG REQUIRED) - include_directories(${LLVM_INCLUDE_DIRS}) - add_definitions(${LLVM_DEFINITIONS}) - set(TVM_LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}) - message(STATUS "Build with LLVM " ${LLVM_PACKAGE_VERSION}) - message(STATUS "Set TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION}) - add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION}) - add_definitions(-DDMLC_USE_FOPEN64=0) - llvm_map_components_to_libnames(LLVM_LIBS all) - list(REMOVE_ITEM LLVM_LIBS LTO) - list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS}) - list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS}) - if(NOT MSVC) - set_property(SOURCE ${COMPILER_LLVM_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS - "-fno-rtti -DDMLC_ENABLE_RTTI=0") - endif() -endif(USE_LLVM) -if(NOT USE_RTTI) - add_definitions(-DDMLC_ENABLE_RTTI=0) -endif() + if(USE_GRAPH_RUNTIME_DEBUG) + set_source_files_properties(${RUNTIME_GRAPH_SRCS} + PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_RUNTIME_DEBUG") + endif(USE_GRAPH_RUNTIME_DEBUG) +endif(USE_GRAPH_RUNTIME) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/CMakeLists.txt) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/include) @@ -259,18 +156,55 @@ elseif(DMLC_CORE_PATH) include_directories(${DMLC_CORE_PATH}/include) endif() -list(APPEND RUNTIME_SRCS ${GROUP_Include}) +# Module rules +include(cmake/modules/CUDA.cmake) +include(cmake/modules/OpenCL.cmake) +include(cmake/modules/OpenGL.cmake) +include(cmake/modules/Vulkan.cmake) +include(cmake/modules/Metal.cmake) +include(cmake/modules/ROCM.cmake) +include(cmake/modules/LLVM.cmake) +include(cmake/modules/contrib/BLAS.cmake) +include(cmake/modules/contrib/Random.cmake) +include(cmake/modules/contrib/Sort.cmake) +include(cmake/modules/contrib/NNPack.cmake) + +# Target rrules add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(tvm_topi SHARED ${TOPI_SRCS}) add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) add_library(nnvm_compiler SHARED ${NNVM_COMPILER_SRCS}) + target_link_libraries(tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(tvm_topi tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(tvm_runtime ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(nnvm_compiler tvm) -install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX}) +# Tests +set(TEST_EXECS "") +file(GLOB TEST_SRCS tests/cpp/*.cc) +find_library(GTEST_LIB gtest) + +if(GTEST_LIB) + foreach(__srcpath ${TEST_SRCS}) + get_filename_component(__srcname ${__srcpath} NAME) + string(REPLACE ".cc" "" __execname ${__srcname}) + add_executable(${__execname} ${__srcpath}) + list(APPEND TEST_EXECS ${__execname}) + target_link_libraries(${__execname} + tvm ${GTEST_LIB} ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS} pthread) + set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1) + set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1) + endforeach() + add_custom_target(cpptest DEPENDS ${TEST_EXECS}) +endif() +# Custom targets +add_custom_target(runtime DEPENDS tvm_runtime) + + +# Installation rulse +install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX}) if(WIN32) install(TARGETS nnvm_compiler RUNTIME DESTINATION bin) install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib) @@ -313,6 +247,7 @@ else(INSTALL_DEV) ) endif(INSTALL_DEV) +# More target definitions if(MSVC) target_compile_definitions(tvm PRIVATE -DHalide_EXPORTS) target_compile_definitions(tvm_runtime PRIVATE -DHalide_EXPORTS) diff --git a/Jenkinsfile b/Jenkinsfile index 3378a02ca2d3f..5822058a5c6aa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -4,11 +4,11 @@ // See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/ // tvm libraries -tvm_runtime = "lib/libtvm_runtime.so, config.mk" -tvm_lib = "lib/libtvm.so, " + tvm_runtime +tvm_runtime = "build/libtvm_runtime.so, build/config.cmake" +tvm_lib = "build/libtvm.so, " + tvm_runtime // LLVM upstream lib -tvm_multilib = "lib/libtvm_llvm40.so, lib/libtvm_llvm50.so, lib/libtvm_llvm60.so, " + - "lib/libtvm_topi.so, nnvm/lib/libnnvm_compiler.so, " + tvm_runtime +tvm_multilib = "build/libtvm.so, " + + "build/libtvm_topi.so, build/libnnvm_compiler.so, " + tvm_runtime // command to start a docker container docker_run = 'tests/ci_build/ci_build.sh' @@ -48,14 +48,14 @@ stage("Sanity Check") { // Run make. First try to do an incremental make from a previous workspace in hope to // accelerate the compilation. If something wrong, clean the workspace and then // build from scratch. -def make(docker_type, make_flag) { +def make(docker_type, path, make_flag) { timeout(time: max_time, unit: 'MINUTES') { try { - sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}" + sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${path} ${make_flag}" } catch (exc) { echo 'Incremental compilation failed. Fall back to build from scratch' - sh "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh" - sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}" + sh "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh ${path}" + sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${path} ${make_flag}" } } } @@ -85,33 +85,30 @@ stage('Build') { ws('workspace/tvm/build-gpu') { init_git() sh """ - cp make/config.mk . - echo USE_CUDNN=1 >> config.mk - echo USE_CUDA=1 >> config.mk - echo USE_OPENGL=1 >> config.mk - echo LLVM_CONFIG=llvm-config-4.0 >> config.mk - echo USE_RPC=1 >> config.mk - echo USE_SORT=1 >> config.mk - echo USE_GRAPH_RUNTIME=1 >> config.mk - echo USE_BLAS=openblas >> config.mk - rm -f lib/libtvm_runtime.so lib/libtvm.so + mkdir -p build + cd build + cp ../cmake/config.cmake . + echo set\\(USE_CUDNN ON\\) >> config.cmake + echo set\\(USE_CUDA ON\\) >> config.cmake + echo set\\(USE_OPENGL ON\\) >> config.cmake + echo set\\(USE_LLVM llvm-config-6.0\\) >> config.cmake + echo set\\(USE_RPC ON\\) >> config.cmake + echo set\\(USE_SORT ON\\) >> config.cmake + echo set\\(USE_GRAPH_RUNTIME ON\\) >> config.cmake + echo set\\(USE_BLAS openblas\\) >> config.cmake """ - make('gpu', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm40.so" - sh "echo LLVM_CONFIG=llvm-config-5.0 >> config.mk" - make('gpu', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm50.so" - sh "echo LLVM_CONFIG=llvm-config-6.0 >> config.mk" - make('gpu', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm60.so" + make('gpu', 'build', '-j2') pack_lib('gpu', tvm_multilib) + // compiler test sh """ - echo USE_OPENCL=1 >> config.mk - echo USE_ROCM=1 >> config.mk - echo ROCM_PATH=/opt/rocm >> config.mk - echo USE_VULKAN=1 >> config.mk + mkdir -p build2 + cd build2 + cp ../cmake/config.cmake . + echo set\\(USE_OPENCL ON\\) >> config.cmake + echo set\\(USE_ROCM ON\\) >> config.cmake + echo set\\(USE_VULKAN ON\\) >> config.cmake """ - make('gpu', '-j2') + make('gpu', 'build2', '-j2') } } }, @@ -120,17 +117,17 @@ stage('Build') { ws('workspace/tvm/build-cpu') { init_git() sh """ - cp make/config.mk . - echo USE_CUDA=0 >> config.mk - echo USE_OPENCL=0 >> config.mk - echo USE_RPC=0 >> config.mk - echo USE_SORT=1 >> config.mk - echo USE_OPENGL=1 >> config.mk - echo LLVM_CONFIG=llvm-config-4.0 >> config.mk - echo USE_SORT=1 >> config.mk + mkdir -p build + cd build + cp ../cmake/config.cmake . + echo set\\(USE_SORT ON\\) >> config.cmake + echo set\\(USE_LLVM llvm-config-4.0\\) >> config.cmake """ - make('cpu', '-j2') + make('cpu', 'build', '-j2') pack_lib('cpu', tvm_lib) + timeout(time: max_time, unit: 'MINUTES') { + sh "${docker_run} cpu ./tests/scripts/task_cpp_unittest.sh" + } } } }, @@ -139,21 +136,14 @@ stage('Build') { ws('workspace/tvm/build-i386') { init_git() sh """ - cp make/config.mk . - echo USE_CUDA=0 >> config.mk - echo USE_OPENCL=0 >> config.mk - echo LLVM_CONFIG=llvm-config-4.0 >> config.mk - echo USE_RPC=1 >> config.mk - echo USE_SORT=1 >> config.mk + mkdir -p build + cd build + cp ../cmake/config.cmake . + echo set\\(USE_SORT ON\\) >> config.cmake + echo set\\(USE_RPC ON\\) >> config.cmake + echo set\\(USE_LLVM llvm-config-5.0\\) >> config.cmake """ - make('i386', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm40.so" - sh "echo LLVM_CONFIG=llvm-config-5.0 >> config.mk" - make('i386', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm50.so" - sh "echo LLVM_CONFIG=llvm-config-6.0 >> config.mk" - make('i386', '-j2') - sh "mv lib/libtvm.so lib/libtvm_llvm60.so" + make('i386', 'build', '-j2') pack_lib('i386', tvm_multilib) } } @@ -166,12 +156,6 @@ stage('Unit Test') { ws('workspace/tvm/ut-python-gpu') { init_git() unpack_lib('gpu', tvm_multilib) - sh "cp lib/libtvm_llvm40.so lib/libtvm.so" - timeout(time: max_time, unit: 'MINUTES') { - sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh" - } - // Test on the lastest mainline. - sh "cp lib/libtvm_llvm60.so lib/libtvm.so" timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh" } @@ -183,27 +167,10 @@ stage('Unit Test') { ws('workspace/tvm/ut-python-i386') { init_git() unpack_lib('i386', tvm_multilib) - sh "cp lib/libtvm_llvm40.so lib/libtvm.so" timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} i386 ./tests/scripts/task_python_unittest.sh" sh "${docker_run} i386 ./tests/scripts/task_python_integration.sh" } - // Test on llvm 5.0 - sh "cp lib/libtvm_llvm50.so lib/libtvm.so" - timeout(time: max_time, unit: 'MINUTES') { - sh "${docker_run} i386 ./tests/scripts/task_python_integration.sh" - } - } - } - }, - 'cpp': { - node('CPU' && 'linux') { - ws('workspace/tvm/ut-cpp') { - init_git() - unpack_lib('cpu', tvm_lib) - timeout(time: max_time, unit: 'MINUTES') { - sh "${docker_run} cpu ./tests/scripts/task_cpp_unittest.sh" - } } } }, @@ -212,7 +179,6 @@ stage('Unit Test') { ws('workspace/tvm/ut-java') { init_git() unpack_lib('gpu', tvm_multilib) - sh "cp lib/libtvm_llvm40.so lib/libtvm.so" timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} gpu ./tests/scripts/task_java_unittest.sh" } @@ -227,7 +193,6 @@ stage('Integration Test') { ws('workspace/tvm/it-python-gpu') { init_git() unpack_lib('gpu', tvm_multilib) - sh "cp lib/libtvm_llvm40.so lib/libtvm.so" timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} gpu ./tests/scripts/task_python_integration.sh" sh "${docker_run} gpu ./tests/scripts/task_python_topi.sh" @@ -242,7 +207,6 @@ stage('Integration Test') { ws('workspace/tvm/docs-python-gpu') { init_git() unpack_lib('gpu', tvm_multilib) - sh "cp lib/libtvm_llvm40.so lib/libtvm.so" timeout(time: max_time, unit: 'MINUTES') { sh "${docker_run} gpu ./tests/scripts/task_python_docs.sh" } diff --git a/Makefile b/Makefile index 4529ecc05ee09..3cab59d5d6b7a 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,7 @@ ROOTDIR = $(CURDIR) -ifndef config -ifneq ("$(wildcard ./config.mk)","") - config ?= config.mk -else - config ?= make/config.mk -endif -endif - -include $(config) - -.PHONY: clean install installdev all test doc pylint cpplint lint\ - verilog cython cython2 cython3 web topi nnvm runtime +.PHONY: clean all test doc pylint cpplint lint\ + cython cython2 cython3 web runtime ifndef DMLC_CORE_PATH DMLC_CORE_PATH = $(ROOTDIR)/dmlc-core @@ -21,316 +11,42 @@ ifndef DLPACK_PATH DLPACK_PATH = $(ROOTDIR)/dlpack endif -UNAME_S := $(shell uname -s) - -# The flags -LLVM_CFLAGS= -fno-rtti -DDMLC_ENABLE_RTTI=0 -DDMLC_USE_FOPEN64=0 -LDFLAGS = -pthread -lm -ldl -Wl,-Bsymbolic-functions INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include -CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC +PKG_CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC PKG_LDFLAGS = -FRAMEWORKS = -OBJCFLAGS = -fno-objc-arc -EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\ - -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\ - -s TOTAL_MEMORY=1073741824\ - -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\ - -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\ - $(INCLUDE_FLAGS) - -# llvm configuration -ifdef LLVM_CONFIG - LLVM_VERSION=$(shell $(LLVM_CONFIG) --version| cut -b 1,3) - LLVM_INCLUDE=$(filter -I%, $(shell $(LLVM_CONFIG) --cxxflags)) - LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags --libs --system-libs) - LLVM_CFLAGS += $(LLVM_INCLUDE) -DTVM_LLVM_VERSION=$(LLVM_VERSION) -else - LLVM_VERSION=00 -endif - -# The source code dependencies -LIB_HALIDEIR = HalideIR/lib/libHalideIR.a - -CC_SRC = $(filter-out src/contrib/%.cc src/runtime/%.cc src/codgen/llvm/%.cc,\ - $(wildcard src/*/*.cc src/*/*/*.cc)) -LLVM_SRC = $(wildcard src/codegen/llvm/*.cc src/codegen/llvm/*/*.cc) -METAL_SRC = $(wildcard src/runtime/metal/*.mm) -CUDA_SRC = $(wildcard src/runtime/cuda/*.cc) -ROCM_SRC = $(wildcard src/runtime/rocm/*.cc) -OPENCL_SRC = $(wildcard src/runtime/opencl/*.cc) -OPENGL_SRC = $(wildcard src/runtime/opengl/*.cc) -VULKAN_SRC = $(wildcard src/runtime/vulkan/*.cc) -SGX_SRC = $(wildcard src/runtime/sgx/untrusted/*.cc) -RPC_SRC = $(wildcard src/runtime/rpc/*.cc) -GRAPH_SRC = $(wildcard src/runtime/graph/*.cc) -RUNTIME_SRC = $(wildcard src/runtime/*.cc) - -# TOPI -TOPI_SRC = $(wildcard topi/src/*.cc) - -# Objectives -LLVM_BUILD = build/llvm${LLVM_VERSION} -LLVM_OBJ = $(patsubst src/%.cc, ${LLVM_BUILD}/%.o, $(LLVM_SRC)) -METAL_OBJ = $(patsubst src/%.mm, build/%.o, $(METAL_SRC)) -CUDA_OBJ = $(patsubst src/%.cc, build/%.o, $(CUDA_SRC)) -ROCM_OBJ = $(patsubst src/%.cc, build/%.o, $(ROCM_SRC)) -OPENCL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENCL_SRC)) -OPENGL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENGL_SRC)) -VULKAN_OBJ = $(patsubst src/%.cc, build/%.o, $(VULKAN_SRC)) -SGX_OBJ = $(patsubst src/%.cc, build/%.o, $(SGX_SRC)) build/runtime/sgx/untrusted/tvm_u.o -RPC_OBJ = $(patsubst src/%.cc, build/%.o, $(RPC_SRC)) -GRAPH_OBJ = $(patsubst src/%.cc, build/%.o, $(GRAPH_SRC)) -CC_OBJ = $(patsubst src/%.cc, build/%.o, $(CC_SRC)) $(LLVM_OBJ) -RUNTIME_OBJ = $(patsubst src/%.cc, build/%.o, $(RUNTIME_SRC)) -TOPI_OBJ = $(patsubst topi/src/%.cc, build/topi/%.o, $(TOPI_SRC)) -CONTRIB_OBJ = - -# Deps -ALL_DEP = $(CC_OBJ) $(CONTRIB_OBJ) $(LIB_HALIDEIR) -RUNTIME_DEP = $(RUNTIME_OBJ) -TOPI_DEP = $(TOPI_OBJ) - -ifeq ($(UNAME_S), Darwin) - PKG_LDFLAGS += -undefined dynamic_lookup -endif - -# Dependency specific rules -ifdef CUDA_PATH - NVCC=$(CUDA_PATH)/bin/nvcc - CFLAGS += -I$(CUDA_PATH)/include - ifeq ($(UNAME_S),Darwin) - LDFLAGS += -L$(CUDA_PATH)/lib - else - LDFLAGS += -L$(CUDA_PATH)/lib64 - endif -endif - -ifeq ($(USE_CUDA), 1) - CFLAGS += -DTVM_CUDA_RUNTIME=1 - LDFLAGS += -lcuda -lcudart -lnvrtc - RUNTIME_DEP += $(CUDA_OBJ) -else - CFLAGS += -DTVM_CUDA_RUNTIME=0 -endif - -ifdef ROCM_PATH - CFLAGS += -I$(ROCM_PATH)/include - LDFLAGS += -L$(ROCM_PATH)/lib -endif - -ifeq ($(USE_ROCM), 1) - CFLAGS += -DTVM_ROCM_RUNTIME=1 -D__HIP_PLATFORM_HCC__=1 - LDFLAGS += -lhip_hcc - RUNTIME_DEP += $(ROCM_OBJ) -else - CFLAGS += -DTVM_ROCM_RUNTIME=0 -endif -ifeq ($(USE_OPENCL), 1) - CFLAGS += -DTVM_OPENCL_RUNTIME=1 - ifeq ($(UNAME_S), Darwin) - FRAMEWORKS += -framework OpenCL - else - LDFLAGS += -lOpenCL - endif - RUNTIME_DEP += $(OPENCL_OBJ) -ifdef OPENCL_PATH - CFLAGS += -I$(OPENCL_PATH)/include - LDFLAGS += -L$(OPENCL_PATH)/lib -endif -else - CFLAGS += -DTVM_OPENCL_RUNTIME=0 -endif - -ifdef VULKAN_SDK - CFLAGS += -I$(VULKAN_SDK)/include - LDFLAGS += -L$(VULKAN_SDK)/lib - LDFLAGS += -L$(VULKAN_SDK)/lib/spirv-tools -endif - -ifeq ($(USE_VULKAN), 1) - CFLAGS += -DTVM_VULKAN_RUNTIME=1 - LDFLAGS += -lvulkan -lSPIRV-Tools - RUNTIME_DEP += $(VULKAN_OBJ) -else - CFLAGS += -DTVM_VULKAN_RUNTIME=0 -endif - -ifeq ($(USE_OPENGL), 1) - CFLAGS += -DTVM_OPENGL_RUNTIME=1 - EMCC_FLAGS += -DTVM_OPENGL_RUNTIME=1 - ifeq ($(UNAME_S), Darwin) - FRAMEWORKS += -framework OpenGL - else - LDFLAGS += -lGL -lglfw - endif - RUNTIME_DEP += $(OPENGL_OBJ) -else - CFLAGS += -DTVM_OPENGL_RUNTIME=0 -endif -ifeq ($(USE_METAL), 1) - CFLAGS += -DTVM_METAL_RUNTIME=1 - LDFLAGS += -lobjc - RUNTIME_DEP += $(METAL_OBJ) - FRAMEWORKS += -framework Metal -framework Foundation -else - CFLAGS += -DTVM_METAL_RUNTIME=0 -endif +all: + @mkdir -p build && cd build && cmake .. && $(MAKE) -ifeq ($(USE_SGX), 1) - EDGER8R = $(SGX_SDK)/bin/x64/sgx_edger8r - ifneq ($(SGX_MODE), HW) - sgx_sim := _sim - endif - urts_library_name := sgx_urts$(sgx_sim) - CFLAGS += -DTVM_SGX_RUNTIME=1 - SGX_CFLAGS = -include "build/runtime/sgx/untrusted/tvm_u.h" -I$(SGX_SDK)/include - LDFLAGS += -L$(SGX_SDK)/lib64 -l$(urts_library_name) - RUNTIME_DEP += $(SGX_OBJ) -else - CFLAGS += -DTVM_SGX_RUNTIME=0 -endif +runtime: -ifeq ($(USE_RPC), 1) - RUNTIME_DEP += $(RPC_OBJ) -endif - -ifeq ($(USE_GRAPH_RUNTIME), 1) - RUNTIME_DEP += $(GRAPH_OBJ) -endif + @mkdir -p build && cd build && cmake .. && $(MAKE) runtime -ifeq ($(USE_GRAPH_RUNTIME_DEBUG), 1) - CFLAGS += -DTVM_GRAPH_RUNTIME_DEBUG -endif +cpptest: + @mkdir -p build && cd build && cmake .. && $(MAKE) cpptest -include make/contrib/cblas.mk -include make/contrib/sort.mk -include make/contrib/random.mk -include make/contrib/nnpack.mk -include make/contrib/cudnn.mk -include make/contrib/miopen.mk -include make/contrib/mps.mk -include make/contrib/cublas.mk -include make/contrib/rocblas.mk - -ifdef ADD_CFLAGS - CFLAGS += $(ADD_CFLAGS) -endif - -ifdef ADD_LDFLAGS - LDFLAGS += $(ADD_LDFLAGS) -endif - -ifeq ($(OS),Windows_NT) - JVM_PKG_PROFILE := windows - SHARED_LIBRARY_SUFFIX := dll -else - UNAME_S := $(shell uname -s) - ifeq ($(UNAME_S), Darwin) - JVM_PKG_PROFILE := osx-x86_64 - SHARED_LIBRARY_SUFFIX := dylib - else - JVM_PKG_PROFILE := linux-x86_64 - SHARED_LIBRARY_SUFFIX := so - endif -endif - -JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true) - -ifeq ($(USE_CUDA), 1) - JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu -else ifeq ($(USE_OPENCL), 1) - JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu -else ifeq ($(USE_METAL), 1) - JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu -else - JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-cpu -endif - -BUILD_TARGETS ?= lib/libtvm.$(SHARED_LIBRARY_SUFFIX) \ - lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) \ - lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX) - -all: ${BUILD_TARGETS} -runtime: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) -web: lib/libtvm_web_runtime.js lib/libtvm_web_runtime.bc -topi: lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX) -nnvm: - $(MAKE) -C nnvm - - -include tests/cpp/unittest.mk - -test: $(TEST) - -include verilog/verilog.mk -verilog: $(VER_LIBS) - -# Special rules for LLVM related modules. -${LLVM_BUILD}/codegen/llvm/%.o: src/codegen/llvm/%.cc - @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(LLVM_CFLAGS) -MM -MT ${LLVM_BUILD}/codegen/llvm/$*.o $< >${LLVM_BUILD}/codegen/llvm/$*.d - $(CXX) -c $(CFLAGS) $(LLVM_CFLAGS) -c $< -o $@ - -build/runtime/metal/%.o: src/runtime/metal/%.mm - @mkdir -p $(@D) - $(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/runtime/metal/$*.o $< >build/runtime/metal/$*.d - $(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@ - -build/runtime/sgx/untrusted/tvm_u.h: src/runtime/sgx/tvm.edl - @mkdir -p $(@D) - $(EDGER8R) $< --untrusted --untrusted-dir $(@D) --search-path $(SGX_SDK)/include - mv $@ $@.in - awk 'NR==4{print "#include "}1' $@.in > $@ - -build/runtime/sgx/untrusted/tvm_u.c: build/runtime/sgx/untrusted/tvm_u.h - -build/runtime/sgx/untrusted/tvm_u.o: build/runtime/sgx/untrusted/tvm_u.c - $(CC) $(CFLAGS) $(SGX_CFLAGS) -c $< -o $@ - -build/runtime/sgx/untrusted/%.o: src/runtime/sgx/untrusted/%.cc build/runtime/sgx/untrusted/tvm_u.h - $(CXX) $(CFLAGS) $(SGX_CFLAGS) -MM -MT build/$*.o $< >build/$*.d - $(CXX) -c $(CFLAGS) $(SGX_CFLAGS) -c $< -o $@ - -build/%.o: src/%.cc - @mkdir -p $(@D) - $(CXX) $(CFLAGS) -MM -MT build/$*.o $< >build/$*.d - $(CXX) -c $(CFLAGS) -c $< -o $@ - -build/topi/%.o: topi/src/%.cc - @mkdir -p $(@D) - $(CXX) $(CFLAGS) -MM -MT build/topi/$*.o $< >build/topi/$*.d - $(CXX) -c $(CFLAGS) -c $< -o $@ - -lib/libtvm.${SHARED_LIBRARY_SUFFIX}: $(ALL_DEP) $(RUNTIME_DEP) - @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) - -lib/libtvm_topi.${SHARED_LIBRARY_SUFFIX}: $(TOPI_DEP) - @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(PKG_LDFLAGS) - -lib/libtvm_runtime.${SHARED_LIBRARY_SUFFIX}: $(RUNTIME_DEP) - @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) +# EMCC; Web related scripts +EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\ + -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\ + -s TOTAL_MEMORY=1073741824\ + -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\ + -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\ + $(INCLUDE_FLAGS) +web: build/libtvm_web_runtime.js build/libtvm_web_runtime.bc -lib/libtvm_web_runtime.bc: web/web_runtime.cc +build/libtvm_web_runtime.bc: web/web_runtime.cc @mkdir -p build/web @mkdir -p $(@D) - emcc $(EMCC_FLAGS) -MM -MT lib/libtvm_web_runtime.bc $< >build/web/web_runtime.d + emcc $(EMCC_FLAGS) -MM -MT build/libtvm_web_runtime.bc $< >build/web/web_runtime.d emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc -lib/libtvm_web_runtime.js: lib/libtvm_web_runtime.bc +build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc @mkdir -p $(@D) - emcc $(EMCC_FLAGS) -o $@ lib/libtvm_web_runtime.bc - -$(LIB_HALIDEIR): LIBHALIDEIR - -LIBHALIDEIR: - + cd HalideIR; make lib/libHalideIR.a DMLC_CORE_PATH=../dmlc-core; cd $(ROOTDIR) + emcc $(EMCC_FLAGS) -o $@ build/libtvm_web_runtime.bc +# Lint scripts cpplint: python dmlc-core/scripts/lint.py topi cpp topi/include; python dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src; @@ -350,18 +66,6 @@ lint: cpplint pylint jnilint doc: doxygen docs/Doxyfile -install: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) - mkdir -p $(DESTDIR)$(PREFIX)/include/tvm/runtime - cp -R include/tvm/runtime/. $(DESTDIR)$(PREFIX)/include/tvm/runtime - cp lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib - -installdev: lib/libtvm.$(SHARED_LIBRARY_SUFFIX) lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) lib/libtvm.a - mkdir -p $(DESTDIR)$(PREFIX)/include - cp -R include/tvm $(DESTDIR)$(PREFIX)/include - cp lib/libtvm.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib - cp lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib - cp lib/libtvm.a $(DESTDIR)$(PREFIX)/lib - # Cython build cython: cd python; python setup.py build_ext --inplace @@ -375,23 +79,35 @@ cython3: cyclean: rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp +# JVM build rules +ifeq ($(OS),Windows_NT) + JVM_PKG_PROFILE := windows + SHARED_LIBRARY_SUFFIX := dll +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S), Darwin) + JVM_PKG_PROFILE := osx-x86_64 + SHARED_LIBRARY_SUFFIX := dylib + else + JVM_PKG_PROFILE := linux-x86_64 + SHARED_LIBRARY_SUFFIX := so + endif +endif + +JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true) +JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu + jvmpkg: (cd $(ROOTDIR)/jvm; \ mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \ - -Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \ - -Dcurrent_libdir="$(ROOTDIR)/lib" $(JVM_TEST_ARGS)) + -Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \ + -Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS)) jvminstall: (cd $(ROOTDIR)/jvm; \ mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \ - -Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \ - -Dcurrent_libdir="$(ROOTDIR)/lib" $(JVM_TEST_ARGS)) + -Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \ + -Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS)) +# clean rule clean: $(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o */*.d */*/*.d */*/*/*.d - cd HalideIR; make clean; cd $(ROOTDIR) - $(MAKE) -C nnvm clean - --include build/*.d --include build/*/*.d --include build/*/*/*.d --include build/*/*/*/*.d diff --git a/cmake/config.cmake b/cmake/config.cmake new file mode 100644 index 0000000000000..b4896da79ef13 --- /dev/null +++ b/cmake/config.cmake @@ -0,0 +1,87 @@ +#-------------------------------------------------------------------- +# Template custom cmake configuration for compiling +# +# This file is used to override the build options in build. +# If you want to change the configuration, please use the following +# steps. Assume you are on the root directory. First copy the this +# file so that any local changes will be ignored by git +# +# $ mkdir build +# $ cp cmake/config.cmake build +# +# Next modify the according entries, and then compile by +# +# $ cd build +# $ cmake .. +# +# Then buld in parallel with 8 threads +# +# $ make -j8 +#-------------------------------------------------------------------- + +#--------------------------------------------- +# Backend runtimes. +#--------------------------------------------- +# whether enable CUDA during compile +set(USE_CUDA OFF) + +# ROCM +set(USE_ROCM OFF) +set(ROCM_PATH "/opt/rocm") + +# Whether enable OpenCL runtime +set(USE_OPENCL OFF) + +# Whether enable Metal runtime +set(USE_METAL OFF) + +# Whether enable Vulkan runtime +set(USE_VULKAN OFF) + +# Whether enable RPC runtime +set(USE_RPC ON) + +# Whether enable tiny embedded graph runtime. +set(USE_GRAPH_RUNTIME ON) + +# Whether enable additional graph debug functions +set(USE_GRAPH_RUNTIME_DEBUG OFF) + +# Whether build with LLVM support +# Requires LLVM version >= 4.0 +# +# Possible values: +# - ON: enable llvm with cmake's find llvm +# - OFF: disbale llvm +# - /path/to/llvm-config enable specific LLVM when multiple llvm-dev is available. +set(USE_LLVM OFF) + +#--------------------------------------------- +# Contrib libraries +#--------------------------------------------- +# Whether use BLAS, choices: openblas, atlas, blas, apple +set(USE_BLAS none) + +# Whether use contrib.random in runtime +set(USE_RANDOM OFF) + +# Whether use NNPack +set(USE_NNPACK OFF) + +# Whether use CuDNN +set(USE_CUDNN OFF) + +# Whether use cuBLAS +set(USE_CUBLAS OFF) + +# Whether use MIOpen +set(USE_MIOPEN OFF) + +# Whether use MPS +set(USE_MPS OFF) + +# Whether use rocBlas +set(USE_ROCBLAS OFF) + +# Whether use contrib sort +set(USE_SORT OFF) diff --git a/cmake/modules/CUDA.cmake b/cmake/modules/CUDA.cmake new file mode 100644 index 0000000000000..83ffac79f54ec --- /dev/null +++ b/cmake/modules/CUDA.cmake @@ -0,0 +1,76 @@ +# CUDA Module +find_package(CUDA QUIET) + +if(CUDA_FOUND) + # always set the includedir when cuda is available + # avoid global retrigger of cmake + include_directories(${CUDA_INCLUDE_DIRS}) +endif(CUDA_FOUND) + +if(USE_CUDA) + find_package(CUDA REQUIRED) + # Find CUDA doesn't find all the libraries we need, add the extra ones + find_library(CUDA_CUDA_LIBRARIES cuda + PATHS ${CUDA_TOOLKIT_ROOT_DIR} + PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs) + find_library(CUDA_NVRTC_LIBRARIES nvrtc + PATHS ${CUDA_TOOLKIT_ROOT_DIR} + PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs) + if(CUDA_CUDA_LIBRARIES) + set(CUDA_CUDA_LIBRARY ${CUDA_CUDA_LIBRARIES}) + endif() + message(STATUS "Build with CUDA support") + file(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDART_LIBRARY}) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDA_LIBRARY}) + list(APPEND RUNTIME_SRCS ${RUNTIME_CUDA_SRCS}) + list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_on.cc) + + if(MSVC) + find_library(CUDA_NVRTC_LIB nvrtc + ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) + list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB}) + else(MSVC) + find_library(CUDA_NVRTC_LIB nvrtc + ${CUDA_TOOLKIT_ROOT_DIR}/lib64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib) + list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB}) + endif(MSVC) + + if(USE_CUDNN) + message(STATUS "Build with cuDNN support") + file(GLOB CONTRIB_CUDNN_SRCS src/contrib/cudnn/*.cc) + list(APPEND RUNTIME_SRCS ${CONTRIB_CUDNN_SRCS}) + if(MSVC) + find_library(CUDA_CUDNN_LIB cudnn + ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB}) + else(MSVC) + find_library(CUDA_CUDNN_LIB cudnn + ${CUDA_TOOLKIT_ROOT_DIR}/lib64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB}) + endif(MSVC) + endif(USE_CUDNN) + + if(USE_CUBLAS) + message(STATUS "Build with cuBLAS support") + file(GLOB CONTRIB_CUBLAS_SRCS src/contrib/cublas/*.cc) + list(APPEND RUNTIME_SRCS ${CONTRIB_CUBLAS_SRCS}) + if(MSVC) + find_library(CUDA_CUBLAS_LIB cublas + ${CUDA_TOOLKIT_ROOT_DIR}/lib/x64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib/win32) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUBLAS_LIB}) + else(MSVC) + find_library(CUDA_CUBLAS_LIB cublas + ${CUDA_TOOLKIT_ROOT_DIR}/lib64 + ${CUDA_TOOLKIT_ROOT_DIR}/lib) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUBLAS_LIB}) + endif(MSVC) + endif(USE_CUBLAS) +else(USE_CUDA) + list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_off.cc) +endif(USE_CUDA) diff --git a/cmake/modules/LLVM.cmake b/cmake/modules/LLVM.cmake new file mode 100644 index 0000000000000..2ea6b6d9e0751 --- /dev/null +++ b/cmake/modules/LLVM.cmake @@ -0,0 +1,26 @@ +# LLVM rules +add_definitions(-DDMLC_USE_FOPEN64=0) + +if(NOT USE_LLVM STREQUAL "OFF") + if(NOT USE_LLVM STREQUAL "ON") + set(LLVM_CONFIG "${USE_LLVM}") + else() + set(LLVM_CONFIG "") + endif() + find_llvm() + include_directories(${LLVM_INCLUDE_DIRS}) + add_definitions(${LLVM_DEFINITIONS}) + message(STATUS "Build with LLVM " ${LLVM_PACKAGE_VERSION}) + message(STATUS "Set TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION}) + # Set flags that are only needed for LLVM target + add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION}) + file(GLOB COMPILER_LLVM_SRCS src/codegen/llvm/*.cc) + list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS}) + list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS}) + if(NOT MSVC) + set_source_files_properties(${COMPILER_LLVM_SRCS} + PROPERTIES COMPILE_DEFINITIONS "DMLC_ENABLE_RTTI=0") + set_source_files_properties(${COMPILER_LLVM_SRCS} + PROPERTIES COMPILE_FLAGS "-fno-rtti") + endif() +endif() diff --git a/cmake/modules/Metal.cmake b/cmake/modules/Metal.cmake new file mode 100644 index 0000000000000..d48155208657f --- /dev/null +++ b/cmake/modules/Metal.cmake @@ -0,0 +1,18 @@ +if(USE_METAL) + message(STATUS "Build with Metal support") + find_library(METAL_LIB Metal) + find_library(FOUNDATION_LIB Foundation) + file(GLOB RUNTIME_METAL_SRCS src/runtime/metal/*.mm) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${METAL_LIB} ${FOUNDATION_LIB}) + list(APPEND RUNTIME_SRCS ${RUNTIME_METAL_SRCS}) + list(APPEND COMPILER_SRCS src/codegen/opt/build_metal_on.cc) + + if(USE_MPS) + file(GLOB MPS_CONTRIB_SRC src/contrib/mps/*.mm) + list(APPEND RUNTIME_SRCS ${MPS_CONTRIB_SRC}) + find_library(MPS_CONTRIB_LIB MetalPerformanceShaders) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${MPS_CONTRIB_LIB}) + endif() +else(USE_METAL) + list(APPEND COMPILER_SRCS src/codegen/opt/build_metal_off.cc) +endif(USE_METAL) diff --git a/cmake/modules/OpenCL.cmake b/cmake/modules/OpenCL.cmake new file mode 100644 index 0000000000000..93e07101b063f --- /dev/null +++ b/cmake/modules/OpenCL.cmake @@ -0,0 +1,19 @@ +# OPENCL Module +find_package(OpenCL QUIET) + +if(OpenCL_FOUND) + # always set the includedir when cuda is available + # avoid global retrigger of cmake + include_directories(${OpenCL_INCLUDE_DIRS}) +endif(OpenCL_FOUND) + +if(USE_OPENCL) + find_package(OpenCL REQUIRED) + message(STATUS "Build with OpenCL support") + file(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES}) + list(APPEND RUNTIME_SRCS ${RUNTIME_OPENCL_SRCS}) + list(APPEND COMPILER_SRCS src/codegen/opt/build_opencl_on.cc) +else() + list(APPEND COMPILER_SRCS src/codegen/opt/build_opencl_off.cc) +endif(USE_OPENCL) diff --git a/cmake/modules/OpenGL.cmake b/cmake/modules/OpenGL.cmake new file mode 100644 index 0000000000000..d43b70351152b --- /dev/null +++ b/cmake/modules/OpenGL.cmake @@ -0,0 +1,19 @@ +find_package(OpenGL QUIET) + +if(OpenGL_FOUND) + # always set the includedir when dir is available + # avoid global retrigger of cmake + include_directories(${OPENGL_INCLUDE_DIRS}) +endif(OpenGL_FOUND) + +if(USE_OPENGL) + find_package(OpenGL REQUIRED) + find_package(glfw3 QUIET REQUIRED) + message(STATUS "Build with OpenGL support") + file(GLOB RUNTIME_OPENGL_SRCS src/runtime/opengl/*.cc) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenGL_LIBRARIES} glfw) + list(APPEND RUNTIME_SRCS ${RUNTIME_OPENGL_SRCS}) + list(APPEND COMPILER_SRCS src/codegen/opt/build_opengl_on.cc) +else(USE_OPENGL) + list(APPEND COMPILER_SRCS src/codegen/opt/build_opengl_off.cc) +endif(USE_OPENGL) diff --git a/cmake/modules/ROCM.cmake b/cmake/modules/ROCM.cmake new file mode 100644 index 0000000000000..d3d4e5cc21f0f --- /dev/null +++ b/cmake/modules/ROCM.cmake @@ -0,0 +1,34 @@ +# ROCM Module +if(NOT ROCM_PATH STREQUAL "") + include_directories(${ROCM_PATH}/include) + set(ROCM_LIB_PATH ${ROCM_PATH}/lib) +else() + set(ROCM_LIB_PATH /lib) +endif() + +if(USE_ROCM) + message(STATUS "Build with ROCM support") + find_library(ROCM_LIBS hip_hcc ${ROCM_LIB_PATH}) + file(GLOB RUNTIME_ROCM_SRCS src/runtime/rocm/*.cc) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${ROCM_LIBS}) + list(APPEND RUNTIME_SRCS ${RUNTIME_ROCM_SRCS}) + add_definitions(-DTVM_ROCM_RUNTIME=1 -D__HIP_PLATFORM_HCC__=1) + + if(USE_MIOPEN) + message(STATUS "Build with MIOpen support") + file(GLOB MIOPEN_CONTRIB_SRCS src/contrib/miopen/*.cc) + list(APPEND RUNTIME_SRCS ${MIOPEN_CONTRIB_SRCS}) + find_library(MIOPEN_LIBS MIOpen ${ROCM_LIB_PATH}) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${MIOPEN_LIBS}) + endif(USE_MIOPEN) + + if(USE_ROCBLAS) + message(STATUS "Build with RocBLAS support") + file(GLOB ROCBLAS_CONTRIB_SRCS src/contrib/rocblas/*.cc) + list(APPEND RUNTIME_SRCS ${ROCBLAS_CONTRIB_SRCS}) + find_library(ROCBLAS_LIBS rocblas ${ROCM_LIB_PATH}) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${ROCBLAS_LIBS}) + endif(USE_ROCBLAS) +else(USE_ROCM) + add_definitions(-DTVM_ROCM_RUNTIME=0) +endif(USE_ROCM) diff --git a/cmake/modules/Vulkan.cmake b/cmake/modules/Vulkan.cmake new file mode 100644 index 0000000000000..0dae5fe1926a1 --- /dev/null +++ b/cmake/modules/Vulkan.cmake @@ -0,0 +1,31 @@ +# Be compatible with older version of CMake +if(NOT $ENV{VULKAN_SDK} STREQUAL "") + set(Vulkan_INCLUDE_DIRS $ENV{VULKAN_SDK}/include) + set(Vulkan_FOUND ON) +else() + find_package(Vulkan QUIET) +endif() + +if(Vulkan_FOUND) + # always set the includedir when cuda is available + # avoid global retrigger of cmake + include_directories(${Vulkan_INCLUDE_DIRS}) +endif(Vulkan_FOUND) + +if(USE_VULKAN) + if(NOT $ENV{VULKAN_SDK} STREQUAL "") + find_library(Vulkan_LIBRARY vulkan $ENV{VULKAN_SDK}/lib) + else() + find_package(Vulkan REQUIRED) + endif() + message(STATUS "Build with VULKAN support") + file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/*.cc) + file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${Vulkan_LIBRARY}) + list(APPEND RUNTIME_SRCS ${RUNTIME_VULKAN_SRCS}) + list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS}) + get_filename_component(VULKAN_LIB_PATH ${Vulkan_LIBRARY} DIRECTORY) + find_library(SPIRV_TOOLS_LIB SPIRV-Tools + ${VULKAN_LIB_PATH}/spirv-tools) + list(APPEND TVM_LINKER_LIBS ${SPIRV_TOOLS_LIB}) +endif(USE_VULKAN) diff --git a/cmake/modules/contrib/BLAS.cmake b/cmake/modules/contrib/BLAS.cmake new file mode 100644 index 0000000000000..423cb9cd5ab34 --- /dev/null +++ b/cmake/modules/contrib/BLAS.cmake @@ -0,0 +1,24 @@ +# Plugin rules for cblas +file(GLOB CBLAS_CONTRIB_SRC src/contrib/cblas/*.cc) + +if(USE_BLAS STREQUAL "openblas") + find_library(BLAS_LIBRARY openblas) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY}) + list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC}) + message(STATUS "Use BLAS library " ${BLAS_LIBRARY}) +elseif(USE_BLAS STREQUAL "atlas" OR USE_BLAS STREQUAL "blas") + find_library(BLAS_LIBRARY cblas) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY}) + list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC}) + message(STATUS "Use BLAS library " ${BLAS_LIBRARY}) +elseif(USE_BLAS STREQUAL "apple") + find_library(BLAS_LIBRARY Accelerate) + include_directories(${BLAS_LIBRARY}/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY}) + list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC}) + message(STATUS "Use BLAS library " ${BLAS_LIBRARY}) +elseif(USE_BLAS STREQUAL "none") + # pass +else() + message(FATAL_ERROR "Invalid option: USE_BLAS=" ${USE_BLAS}) +endif() diff --git a/cmake/modules/contrib/NNPack.cmake b/cmake/modules/contrib/NNPack.cmake new file mode 100644 index 0000000000000..e75d19081defd --- /dev/null +++ b/cmake/modules/contrib/NNPack.cmake @@ -0,0 +1,14 @@ +if(USE_NNPACK) + if(NNPACK_PATH STREQUAL "") + set(NNPACK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/NNPack) + endif() + set(PTHREAD_POOL_PATH ${NNPACK_PATH}/deps/pthreadpool) + file(GLOB NNPACK_CONTRIB_SRC src/contrib/nnpack/*.cc) + list(APPEND RUNTIME_SRCS ${NNPACK_CONTRIB_SRC}) + include_directories(${NNPACK_PATH}/include) + include_directories(${PTHREAD_POOL_PATH}/include) + find_library(NNPACK_CONTRB_LIB nnpack ${NNPACK_PATH}/lib) + find_library(NNPACK_PTHREAD_CONTRIB_LIB pthreadpool ${NNPACK_PATH}/lib) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${NNPACK_CONTRIB_LIB}) + list(APPEND TVM_RUNTIME_LINKER_LIBS ${NNPACK_PTHREAD_CONTRIB_LIB}) +endif(USE_NNPACK) diff --git a/cmake/modules/contrib/Random.cmake b/cmake/modules/contrib/Random.cmake new file mode 100644 index 0000000000000..a6980be8bb5b5 --- /dev/null +++ b/cmake/modules/contrib/Random.cmake @@ -0,0 +1,5 @@ +if(USE_RANDOM) + message(STATUS "Build with contrib.random") + file(GLOB RANDOM_CONTRIB_SRC src/contrib/random/random.cc) + list(APPEND RUNTIME_SRCS ${RANDOM_CONTRIB_SRC}) +endif(USE_RANDOM) diff --git a/cmake/modules/contrib/Sort.cmake b/cmake/modules/contrib/Sort.cmake new file mode 100644 index 0000000000000..9ef637ecd99f9 --- /dev/null +++ b/cmake/modules/contrib/Sort.cmake @@ -0,0 +1,5 @@ +if(USE_SORT) + message(STATUS "Build with contrib.sort") + file(GLOB SORT_CONTRIB_SRC src/contrib/sort/*.cc) + list(APPEND RUNTIME_SRCS ${SORT_CONTRIB_SRC}) +endif(USE_SORT) diff --git a/cmake/util/FindLLVM.cmake b/cmake/util/FindLLVM.cmake new file mode 100644 index 0000000000000..d2707e522c56b --- /dev/null +++ b/cmake/util/FindLLVM.cmake @@ -0,0 +1,39 @@ +####################################################### +# Enhanced version of find llvm that allows set of LLVM_CONFIG +# When LLVM_CONFIG_PATH is AUTO, +# it defaults to system find llvm +# +# Usage: +# find_llvm(LLVM_CONFIG_PATH) +# +# Provide variables: +# - LLVM_INCLUDE_DIRS +# - LLVM_LIBS +# - LLVM_DEFINITIONS +# - LLVM_VERSION_CONCAT +# +macro(find_llvm) + if(LLVM_CONFIG STREQUAL "") + find_package(LLVM REQUIRED CONFIG) + llvm_map_components_to_libnames(LLVM_LIBS all) + list(REMOVE_ITEM LLVM_LIBS LTO) + set(TVM_LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR}) + else() + # use llvm config + message(STATUS "Use llvm-config=" ${LLVM_CONFIG}) + execute_process(COMMAND ${LLVM_CONFIG} --includedir + OUTPUT_VARIABLE LLVM_INCLUDE_DIRS) + execute_process(COMMAND ${LLVM_CONFIG} --libfiles + OUTPUT_VARIABLE LLVM_LIBS) + execute_process(COMMAND ${LLVM_CONFIG} --cxxflags + OUTPUT_VARIABLE __llvm_cxxflags) + execute_process(COMMAND ${LLVM_CONFIG} --version + COMMAND cut -b 1,3 + OUTPUT_VARIABLE TVM_LLVM_VERSION) + string(REGEX MATCHALL "(^| )-D[A-Za-z0-9_]*" LLVM_DEFINITIONS ${__llvm_cxxflags}) + string(STRIP ${LLVM_LIBS} LLVM_LIBS) + separate_arguments(LLVM_LIBS) + string(STRIP ${LLVM_INCLUDE_DIRS} LLVM_INCLUDE_DIRS) + string(STRIP ${TVM_LLVM_VERSION} TVM_LLVM_VERSION) + endif() +endmacro(find_llvm) diff --git a/cmake/Util.cmake b/cmake/util/Util.cmake similarity index 72% rename from cmake/Util.cmake rename to cmake/util/Util.cmake index 0cc3acea5e551..fb3118bde9e01 100644 --- a/cmake/Util.cmake +++ b/cmake/util/Util.cmake @@ -1,8 +1,14 @@ +macro(__tvm_option variable description value) + if(NOT DEFINED ${variable}) + set(${variable} ${value} CACHE STRING ${description}) + endif() +endmacro() + ####################################################### # An option that the user can select. Can accept condition to control when option is available for user. # Usage: # tvm_option( "doc string" [IF ]) -function(tvm_option variable description value) +macro(tvm_option variable description value) set(__value ${value}) set(__condition "") set(__varname "__value") @@ -21,23 +27,23 @@ function(tvm_option variable description value) if(${__condition}) if("${__value}" MATCHES ";") if(${__value}) - option(${variable} "${description}" ON) + __tvm_option(${variable} "${description}" ON) else() - option(${variable} "${description}" OFF) + __tvm_option(${variable} "${description}" OFF) endif() elseif(DEFINED ${__value}) if(${__value}) - option(${variable} "${description}" ON) + __tvm_option(${variable} "${description}" ON) else() - option(${variable} "${description}" OFF) + __tvm_option(${variable} "${description}" OFF) endif() else() - option(${variable} "${description}" ${__value}) + __tvm_option(${variable} "${description}" "${__value}") endif() else() unset(${variable} CACHE) endif() -endfunction() +endmacro() function(assign_source_group group) foreach(_source IN ITEMS ${ARGN}) @@ -50,4 +56,4 @@ function(assign_source_group group) string(REPLACE "/" "\\" _source_path_msvc "${_source_path}") source_group("${group}\\${_source_path_msvc}" FILES "${_source}") endforeach() -endfunction(assign_source_group) \ No newline at end of file +endfunction(assign_source_group) diff --git a/docs/install/index.rst b/docs/install/index.rst index eee2934840a03..076632ac21db2 100644 --- a/docs/install/index.rst +++ b/docs/install/index.rst @@ -38,13 +38,23 @@ Our goal is to build the shared libraries: The minimal building requirements are - A recent c++ compiler supporting C++ 11 (g++-4.8 or higher) +- CMake 3.7 or higher - We highly recommend to build with LLVM to enable all the features. - It is possible to build without llvm dependency if we only want to use CUDA/OpenCL -The configuration of tvm can be modified by `config.mk` +We use cmake to build the library. +The configuration of tvm can be modified by `config.cmake`. -- First copy ``make/config.mk`` to the project root, on which - any local modification will be ignored by git, then modify the according flags. + +- First, check the cmake in your system, you do not have cmake + you can obtain the latest version from `official website `_ +- First create a build directory, copy the ``cmake/config.cmake`` to the directory. + .. code:: bash + + mkdir build + cp cmake/config.cmake build + +- Edit ``build/config.cmake`` to customize the compilation options - On macOS, for some versions of XCode, you need to add ``-lc++abi`` in the LDFLAGS or you'll get link errors. @@ -54,27 +64,22 @@ The configuration of tvm can be modified by `config.mk` - Since LLVM takes long time to build from source, you can download pre-built version of LLVM from [LLVM Download Page](http://releases.llvm.org/download.html). - - Unzip to a certain location, modify ``config.mk`` to add ``LLVM_CONFIG=/path/to/your/llvm/bin/llvm-config`` + + - Unzip to a certain location, modify ``build/config.cmake`` to add ``set(USE_LLVM /path/to/your/llvm/bin/llvm-config)`` + - You can also directly set ``set(USE_LLVM ON)`` and let cmake search for a usable version of LLVM. - You can also use [LLVM Nightly Ubuntu Build](https://apt.llvm.org/) - Note that apt-package append ``llvm-config`` with version number. - For example, set ``LLVM_CONFIG=llvm-config-4.0`` if you installed 4.0 package - -We can then build tvm by `make`. - -.. code:: bash - - make -j4 - -After we build tvm, we can proceed to build nnvm using the following command. - -.. code:: bash + For example, set ``set(LLVM_CONFIG llvm-config-4.0)`` if you installed 4.0 package - make nnvm -j4 +- We can then build tvm and related libraries. + .. code:: bash + cd build + cmake .. + make -j4 -This will creates `libnnvm_compiler.so` under the `nnvm/lib` folder. If everything goes well, we can go to the specific language installation section. @@ -101,7 +106,7 @@ Building ROCm support Currently, ROCm is supported only on linux, so all the instructions are written with linux in mind. -- Set ``USE_ROCM=1``, set ROCM_PATH to the correct path. +- Set ``set(USE_ROCM ON)``, set ROCM_PATH to the correct path. - You need to first install HIP runtime from ROCm. Make sure the installation system has ROCm installed in it. - Install latest stable version of LLVM (v6.0.1), and LLD, make sure ``ld.lld`` is available via command line. diff --git a/docs/install/nnpack.md b/docs/install/nnpack.md index 1e9bd22ba2004..d4e6e39e4023b 100644 --- a/docs/install/nnpack.md +++ b/docs/install/nnpack.md @@ -71,9 +71,8 @@ sudo ldconfig git clone --recursive https://github.com/dmlc/tvm ``` -* Set `USE_NNPACK = 1` in config.mk. +* Set `set(USE_NNPACK ON)` in config.cmake. * Set `NNPACK_PATH` to the $(YOUR_NNPACK_INSTALL_PATH) -* Set `LLVM_CONFIG = llvm-config-4.0` depending of llvm version installed after configuration use `make` to build TVM diff --git a/include/tvm/runtime/config.h b/include/tvm/runtime/config.h deleted file mode 100644 index c288f6048c8d9..0000000000000 --- a/include/tvm/runtime/config.h +++ /dev/null @@ -1,30 +0,0 @@ -/*! - * Copyright (c) 2017 by Contributors - * \file tvm/runtime/config.h - * \brief Runtime library related configurations. - */ -#ifndef TVM_RUNTIME_CONFIG_H_ -#define TVM_RUNTIME_CONFIG_H_ - -/*! - *\brief whether to use CUDA runtime - */ -#ifndef TVM_CUDA_RUNTIME -#define TVM_CUDA_RUNTIME 1 -#endif - -/*! - *\brief whether to use opencl runtime - */ -#ifndef TVM_OPENCL_RUNTIME -#define TVM_OPENCL_RUNTIME 0 -#endif - -/*! - *\brief whether to use metal runtime - */ -#ifndef TVM_METAL_RUNTIME -#define TVM_METAL_RUNTIME 0 -#endif - -#endif // TVM_RUNTIME_CONFIG_H_ diff --git a/jvm/assembly/linux-x86_64-cpu/src/main/assembly/assembly.xml b/jvm/assembly/linux-x86_64-cpu/src/main/assembly/assembly.xml index 936832f430058..6139d94fe5a00 100644 --- a/jvm/assembly/linux-x86_64-cpu/src/main/assembly/assembly.xml +++ b/jvm/assembly/linux-x86_64-cpu/src/main/assembly/assembly.xml @@ -6,7 +6,7 @@ false - ../../../lib/libtvm_runtime.so + ../../../build/libtvm_runtime.so lib/native 0644 diff --git a/jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml b/jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml index c0f5c053d262a..6326ad432ec71 100644 --- a/jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml +++ b/jvm/assembly/linux-x86_64-gpu/src/main/assembly/assembly.xml @@ -6,7 +6,7 @@ false - ../../../lib/libtvm_runtime.so + ../../../build/libtvm_runtime.so lib/native 0644 diff --git a/jvm/assembly/osx-x86_64-cpu/src/main/assembly/assembly.xml b/jvm/assembly/osx-x86_64-cpu/src/main/assembly/assembly.xml index 404f935a1f3e7..0e8e905809575 100644 --- a/jvm/assembly/osx-x86_64-cpu/src/main/assembly/assembly.xml +++ b/jvm/assembly/osx-x86_64-cpu/src/main/assembly/assembly.xml @@ -6,7 +6,7 @@ false - ../../../lib/libtvm_runtime.dylib + ../../../build/libtvm_runtime.dylib lib/native 0644 diff --git a/jvm/core/pom.xml b/jvm/core/pom.xml index 8aed785251890..f8160f29dcd0a 100644 --- a/jvm/core/pom.xml +++ b/jvm/core/pom.xml @@ -81,7 +81,7 @@ true - + org.apache.maven.plugins maven-surefire-plugin 2.7 @@ -91,7 +91,7 @@ 1 -Djava.library.path=${project.parent.basedir}/native/${platform}/target - -Dlibtvm.so.path=${project.parent.basedir}/../lib/${libtvm.so.filename} + -Dlibtvm.so.path=${project.parent.basedir}/../build/${libtvm.so.filename} diff --git a/make/config.mk b/make/config.mk deleted file mode 100644 index 01ab0c4e8a709..0000000000000 --- a/make/config.mk +++ /dev/null @@ -1,95 +0,0 @@ -#------------------------------------------------------------------------------- -# Template configuration for compiling -# -# If you want to change the configuration, please use the following -# steps. Assume you are on the root directory. First copy the this -# file so that any local changes will be ignored by git -# -# $ cp make/config.mk . -# -# Next modify the according entries, and then compile by -# -# $ make -# -# or build in parallel with 8 threads -# -# $ make -j8 -#------------------------------------------------------------------------------- - -# whether compile with debug -DEBUG = 0 - -# the additional link flags you want to add -ADD_LDFLAGS = - -# the additional compile flags you want to add -ADD_CFLAGS = - -#--------------------------------------------- -# Backend runtimes. -#--------------------------------------------- -# whether enable CUDA during compile -USE_CUDA = 0 - -# add the path to CUDA library to link and compile flag -# if you have already add them to environment variable. -# CUDA_PATH = /usr/local/cuda - -# ROCM -USE_ROCM = 0 - -# whether enable OpenCL during compile -USE_OPENCL = 0 - -# whether enable Metal during compile -USE_METAL = 0 - -# whether enable SGX during compile -USE_SGX = 0 -SGX_SDK = /opt/sgxsdk - -# Whether enable RPC during compile -USE_RPC = 1 - -# Whether enable tiny embedded graph runtime. -USE_GRAPH_RUNTIME = 1 - -# Whether enable additional graph debug functions -USE_GRAPH_RUNTIME_DEBUG = 0 - -# whether build with LLVM support -# Requires LLVM version >= 4.0 -# Set LLVM_CONFIG to your version, uncomment to build with llvm support -# -# LLVM_CONFIG = llvm-config - -#--------------------------------------------- -# Contrib optional libraries. -#--------------------------------------------- -# Whether use BLAS, choices: openblas, atlas, blas, apple -USE_BLAS = none - -# Whether use contrib.random in runtime -USE_RANDOM = 0 - -# Whether use NNPack -USE_NNPACK = 0 -# NNPACK_PATH = none - -# Whether use CuDNN -USE_CUDNN = 0 - -# Whether use MIOpen -USE_MIOPEN = 0 - -# Whether use MPS -USE_MPS = 0 - -# Whether use cuBLAS -USE_CUBLAS = 0 - -# Whether use rocBlas -USE_ROCBLAS = 0 - -# Whether use contrib sort -USE_SORT = 0 diff --git a/make/contrib/cblas.mk b/make/contrib/cblas.mk deleted file mode 100644 index b5f3237d72701..0000000000000 --- a/make/contrib/cblas.mk +++ /dev/null @@ -1,17 +0,0 @@ -CBLAS_CONTRIB_SRC = $(wildcard src/contrib/cblas/*.cc) -CBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CBLAS_CONTRIB_SRC)) - -ifeq ($(USE_BLAS), openblas) - ADD_LDFLAGS += -lopenblas - RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ) -else ifeq ($(USE_BLAS), atlas) - ADD_LDFLAGS += -lcblas - RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ) -else ifeq ($(USE_BLAS), blas) - ADD_LDFLAGS += -lblas - RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ) -else ifeq ($(USE_BLAS), apple) - ADD_CFLAGS += -I/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/ - FRAMEWORKS += -framework Accelerate - RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ) -endif diff --git a/make/contrib/cublas.mk b/make/contrib/cublas.mk deleted file mode 100644 index 8274dc0bb3787..0000000000000 --- a/make/contrib/cublas.mk +++ /dev/null @@ -1,8 +0,0 @@ -CUBLAS_CONTRIB_SRC = $(wildcard src/contrib/cublas/*.cc) -CUBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CUBLAS_CONTRIB_SRC)) - -ifeq ($(USE_CUBLAS), 1) -CFLAGS += -DTVM_USE_CUBLAS=1 -ADD_LDFLAGS += -lcublas -RUNTIME_DEP += $(CUBLAS_CONTRIB_OBJ) -endif diff --git a/make/contrib/cudnn.mk b/make/contrib/cudnn.mk deleted file mode 100644 index f3959fe6533ce..0000000000000 --- a/make/contrib/cudnn.mk +++ /dev/null @@ -1,8 +0,0 @@ -CUDNN_CONTRIB_SRC = $(wildcard src/contrib/cudnn/*.cc) -CUDNN_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CUDNN_CONTRIB_SRC)) - -ifeq ($(USE_CUDNN), 1) -CFLAGS += -DTVM_USE_CUDNN=1 -I$(CUDA_PATH)/include -ADD_LDFLAGS += -lcudnn -RUNTIME_DEP += $(CUDNN_CONTRIB_OBJ) -endif diff --git a/make/contrib/miopen.mk b/make/contrib/miopen.mk deleted file mode 100644 index 10ed6cba08019..0000000000000 --- a/make/contrib/miopen.mk +++ /dev/null @@ -1,8 +0,0 @@ -MIOPEN_CONTRIB_SRC = $(wildcard src/contrib/miopen/*.cc) -MIOPEN_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(MIOPEN_CONTRIB_SRC)) - -ifeq ($(USE_MIOPEN), 1) -CFLAGS += -DTVM_USE_MIOPEN=1 -ADD_LDFLAGS += -lMIOpen -RUNTIME_DEP += $(MIOPEN_CONTRIB_OBJ) -endif diff --git a/make/contrib/mps.mk b/make/contrib/mps.mk deleted file mode 100644 index 0fe8a7f128893..0000000000000 --- a/make/contrib/mps.mk +++ /dev/null @@ -1,20 +0,0 @@ -MPS_CONTRIB_SRC = $(wildcard src/contrib/mps/*.mm) -MPS_CONTRIB_OBJ = $(patsubst src/%.mm, build/%.o, $(MPS_CONTRIB_SRC)) - -ifeq ($(USE_MPS), 1) -FRAMEWORKS += -framework MetalPerformanceShaders -CFLAGS += -ADD_LDFLAGS += -RUNTIME_DEP += $(MPS_CONTRIB_OBJ) -CONTRIB_OBJ += $(MPS_CONTRIB_OBJ) -endif - -build/contrib/mps/%.o: src/contrib/mps/%.mm - @mkdir -p $(@D) - $(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/contrib/mps/$*.o $< >build/contrib/mps/$*.d - $(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@ - -build/contrib/mps/%.o: src/contrib/mps/%.cc - @mkdir -p $(@D) - $(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/contrib/mps/$*.o $< >build/contrib/mps/$*.d - $(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@ diff --git a/make/contrib/nnpack.mk b/make/contrib/nnpack.mk deleted file mode 100644 index 718bfe2ae4141..0000000000000 --- a/make/contrib/nnpack.mk +++ /dev/null @@ -1,12 +0,0 @@ -NNPACK_CONTRIB_SRC = $(wildcard src/contrib/nnpack/*.cc) -NNPACK_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(NNPACK_CONTRIB_SRC)) - -ifeq ($(USE_NNPACK), 1) -ifndef NNPACK_PATH - NNPACK_PATH = $(ROOTDIR)/NNPACK -endif - PTHREAD_POOL_PATH = $(NNPACK_PATH)/deps/pthreadpool - CFLAGS += -DTVM_USE_NNPACK=1 -I$(NNPACK_PATH)/include -I$(PTHREAD_POOL_PATH)/include - LDFLAGS += -L$(NNPACK_PATH)/lib -lnnpack -lpthreadpool -lpthread - RUNTIME_DEP += $(NNPACK_CONTRIB_OBJ) -endif diff --git a/make/contrib/random.mk b/make/contrib/random.mk deleted file mode 100644 index 3f8c03f5e4e8a..0000000000000 --- a/make/contrib/random.mk +++ /dev/null @@ -1,6 +0,0 @@ -RANDOM_CONTRIB_SRC = $(wildcard src/contrib/random/random.cc) -RANDOM_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(RANDOM_CONTRIB_SRC)) - -ifeq ($(USE_RANDOM), 1) - RUNTIME_DEP += $(RANDOM_CONTRIB_OBJ) -endif diff --git a/make/contrib/rocblas.mk b/make/contrib/rocblas.mk deleted file mode 100644 index ae5663099d530..0000000000000 --- a/make/contrib/rocblas.mk +++ /dev/null @@ -1,8 +0,0 @@ -ROCBLAS_CONTRIB_SRC = $(wildcard src/contrib/rocblas/*.cc) -ROCBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(ROCBLAS_CONTRIB_SRC)) - -ifeq ($(USE_ROCBLAS), 1) -CFLAGS += -DTVM_USE_ROCBLAS=1 -ADD_LDFLAGS += -lrocblas -RUNTIME_DEP += $(ROCBLAS_CONTRIB_OBJ) -endif diff --git a/make/contrib/sort.mk b/make/contrib/sort.mk deleted file mode 100644 index 40afd1c581dc4..0000000000000 --- a/make/contrib/sort.mk +++ /dev/null @@ -1,6 +0,0 @@ -SORT_CONTRIB_SRC = $(wildcard src/contrib/sort/*.cc) -SORT_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(SORT_CONTRIB_SRC)) - -ifeq ($(USE_SORT), 1) - RUNTIME_DEP += $(SORT_CONTRIB_OBJ) -endif diff --git a/src/codegen/codegen_cuda.cc b/src/codegen/codegen_cuda.cc index 854bdd9931279..f2e038c4a2a46 100644 --- a/src/codegen/codegen_cuda.cc +++ b/src/codegen/codegen_cuda.cc @@ -3,7 +3,6 @@ * \file codegen_cuda.cc */ #include -#include #include #include #include diff --git a/src/codegen/codegen_metal.cc b/src/codegen/codegen_metal.cc index fe8486668da02..54c0fd90814c5 100644 --- a/src/codegen/codegen_metal.cc +++ b/src/codegen/codegen_metal.cc @@ -2,7 +2,6 @@ * Copyright (c) 2017 by Contributors * \file codegen_metal.cc */ -#include #include #include #include diff --git a/src/codegen/codegen_opencl.cc b/src/codegen/codegen_opencl.cc index dd8bf7081a25e..909aacdc4cd23 100644 --- a/src/codegen/codegen_opencl.cc +++ b/src/codegen/codegen_opencl.cc @@ -2,7 +2,6 @@ * Copyright (c) 2017 by Contributors * \file codegen_opencl.cc */ -#include #include #include #include diff --git a/src/codegen/codegen_opengl.cc b/src/codegen/codegen_opengl.cc index 0e9e274b6bba0..3ad87d52b0f44 100644 --- a/src/codegen/codegen_opengl.cc +++ b/src/codegen/codegen_opengl.cc @@ -5,7 +5,6 @@ * We are targeting OpenGL 3.3. The reason of not targeting a recent version * of OpenGL is to have better compatibility of WebGL 2. */ -#include #include #include #include diff --git a/src/codegen/llvm/codegen_amdgpu.cc b/src/codegen/llvm/codegen_amdgpu.cc index 6feb3b379d211..05bc8df355dad 100644 --- a/src/codegen/llvm/codegen_amdgpu.cc +++ b/src/codegen/llvm/codegen_amdgpu.cc @@ -105,7 +105,6 @@ class CodeGenAMDGPU : public CodeGenLLVM { llvm::Value* CreateStorageSync(const Call* op) final { const std::string& sync = op->args[0].as()->value; if (sync == "warp") { - // TODO(tqchen) warp sync in CUDA9 return nullptr; } else if (sync == "shared") { llvm::Function* f = llvm::Intrinsic::getDeclaration( diff --git a/src/codegen/llvm/codegen_nvptx.cc b/src/codegen/llvm/codegen_nvptx.cc index a22494b72909c..3231008e89594 100644 --- a/src/codegen/llvm/codegen_nvptx.cc +++ b/src/codegen/llvm/codegen_nvptx.cc @@ -4,7 +4,6 @@ * \brief NVPTX code generator. */ #ifdef TVM_LLVM_VERSION -#if TVM_CUDA_RUNTIME #include #include "./codegen_llvm.h" @@ -215,5 +214,4 @@ TVM_REGISTER_API("codegen.build_nvptx") } // namespace codegen } // namespace tvm -#endif // TVM_CUDA_RUNTIME #endif // TVM_LLVM_VERSION diff --git a/src/codegen/opt/README b/src/codegen/opt/README new file mode 100644 index 0000000000000..535e8c03d114e --- /dev/null +++ b/src/codegen/opt/README @@ -0,0 +1 @@ +This folder contains optional builds for codegen depending on compilation options. diff --git a/src/codegen/opt/build_cuda_off.cc b/src/codegen/opt/build_cuda_off.cc new file mode 100644 index 0000000000000..4e2bfd03d71ac --- /dev/null +++ b/src/codegen/opt/build_cuda_off.cc @@ -0,0 +1,18 @@ +/*! + * Copyright (c) 2018 by Contributors + * Optional module when build cuda is switched to off + */ +#include "../../runtime/cuda/cuda_module.h" +namespace tvm { +namespace runtime { + +Module CUDAModuleCreate( + std::string data, + std::string fmt, + std::unordered_map fmap, + std::string cuda_source) { + LOG(FATAL) << "CUDA is not enabled"; + return Module(); +} +} // namespace runtime +} // namespace tvm diff --git a/src/codegen/build_cuda.cc b/src/codegen/opt/build_cuda_on.cc similarity index 91% rename from src/codegen/build_cuda.cc rename to src/codegen/opt/build_cuda_on.cc index aaac4115e4d36..267c3447e0519 100644 --- a/src/codegen/build_cuda.cc +++ b/src/codegen/opt/build_cuda_on.cc @@ -1,17 +1,17 @@ /*! * Copyright (c) 2017 by Contributors * Build cuda modules from source. + * requires cuda to be available. + * * \file build_cuda.cc */ #include -#include -#include "./codegen_cuda.h" -#include "./build_common.h" - -#if TVM_CUDA_RUNTIME #include -#include "../runtime/cuda/cuda_common.h" -#include "../runtime/cuda/cuda_module.h" + +#include "../codegen_cuda.h" +#include "../build_common.h" +#include "../../runtime/cuda/cuda_common.h" +#include "../../runtime/cuda/cuda_module.h" namespace tvm { namespace codegen { @@ -79,4 +79,3 @@ TVM_REGISTER_API("codegen.build_cuda") }); } // namespace codegen } // namespace tvm -#endif // TVM_CUDA_RUNTIME diff --git a/src/codegen/build_metal.cc b/src/codegen/opt/build_metal.h similarity index 80% rename from src/codegen/build_metal.cc rename to src/codegen/opt/build_metal.h index 42aa0965ec9d2..a5c7c0ecf6705 100644 --- a/src/codegen/build_metal.cc +++ b/src/codegen/opt/build_metal.h @@ -1,15 +1,17 @@ /*! * Copyright (c) 2017 by Contributors * Build metal modules from source. - * \file build_metal.cc + * \file build_metal.h */ -#include -#include -#include "./codegen_metal.h" -#include "./build_common.h" +#ifndef TVM_CODEGEN_OPT_BUILD_METAL_H_ +#define TVM_CODEGEN_OPT_BUILD_METAL_H_ + +#include +#include "../codegen_metal.h" +#include "../build_common.h" #if TVM_METAL_RUNTIME -#include "../runtime/metal/metal_module.h" +#include "../../runtime/metal/metal_module.h" #endif // TVM_METAL_RUNTIME namespace tvm { @@ -45,3 +47,4 @@ TVM_REGISTER_API("codegen.build_metal") }); } // namespace codegen } // namespace tvm +#endif // TVM_CODEGEN_OPT_BUILD_METAL_H_ diff --git a/src/codegen/opt/build_metal_off.cc b/src/codegen/opt/build_metal_off.cc new file mode 100644 index 0000000000000..a4fc1adc34172 --- /dev/null +++ b/src/codegen/opt/build_metal_off.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build Metal modules off + */ +#define TVM_METAL_RUNTIME 0 +#include "./build_metal.h" diff --git a/src/codegen/opt/build_metal_on.cc b/src/codegen/opt/build_metal_on.cc new file mode 100644 index 0000000000000..65194884ef7f9 --- /dev/null +++ b/src/codegen/opt/build_metal_on.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build Metal modules on + */ +#define TVM_METAL_RUNTIME 1 +#include "./build_metal.h" diff --git a/src/codegen/build_opencl.cc b/src/codegen/opt/build_opencl.h similarity index 78% rename from src/codegen/build_opencl.cc rename to src/codegen/opt/build_opencl.h index c4a53744d4771..5756881ae315a 100644 --- a/src/codegen/build_opencl.cc +++ b/src/codegen/opt/build_opencl.h @@ -1,15 +1,18 @@ /*! * Copyright (c) 2017 by Contributors * Build opencl modules from source. - * \file build_opencl.cc + * \file build_opencl.h */ +#ifndef TVM_CODEGEN_OPT_BUILD_OPENCL_H_ +#define TVM_CODEGEN_OPT_BUILD_OPENCL_H_ + #include -#include -#include "./codegen_opencl.h" -#include "./build_common.h" +#include +#include "../codegen_opencl.h" +#include "../build_common.h" #if TVM_OPENCL_RUNTIME -#include "../runtime/opencl/opencl_module.h" +#include "../../runtime/opencl/opencl_module.h" #endif // TVM_OPENCL_RUNTIME namespace tvm { @@ -42,3 +45,4 @@ TVM_REGISTER_API("codegen.build_opencl") }); } // namespace codegen } // namespace tvm +#endif // TVM_CODEGEN_OPT_BUILD_OPENCL_H_ diff --git a/src/codegen/opt/build_opencl_off.cc b/src/codegen/opt/build_opencl_off.cc new file mode 100644 index 0000000000000..0578d23d1b3f9 --- /dev/null +++ b/src/codegen/opt/build_opencl_off.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build opencl modules off + */ +#define TVM_OPENCL_RUNTIME 0 +#include "./build_opencl.h" diff --git a/src/codegen/opt/build_opencl_on.cc b/src/codegen/opt/build_opencl_on.cc new file mode 100644 index 0000000000000..53c157883cf8c --- /dev/null +++ b/src/codegen/opt/build_opencl_on.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build opencl modules on + */ +#define TVM_OPENCL_RUNTIME 1 +#include "./build_opencl.h" diff --git a/src/codegen/build_opengl.cc b/src/codegen/opt/build_opengl.h similarity index 80% rename from src/codegen/build_opengl.cc rename to src/codegen/opt/build_opengl.h index 5e13676e81117..ed782cc041286 100644 --- a/src/codegen/build_opengl.cc +++ b/src/codegen/opt/build_opengl.h @@ -1,11 +1,14 @@ /*! * Copyright (c) 2017 by Contributors * Build opengl modules from source. - * \file build_opengl.cc + * \file build_opengl.h */ +#ifndef TVM_CODEGEN_OPT_BUILD_OPENGL_H_ +#define TVM_CODEGEN_OPT_BUILD_OPENGL_H_ + #include -#include "./codegen_opengl.h" -#include "./build_common.h" +#include "../codegen_opengl.h" +#include "../build_common.h" namespace tvm { namespace codegen { @@ -33,3 +36,4 @@ TVM_REGISTER_API("codegen.build_opengl") }); } // namespace codegen } // namespace tvm +#endif // TVM_CODEGEN_OPT_BUILD_OPENGL_H_ diff --git a/src/codegen/opt/build_opengl_off.cc b/src/codegen/opt/build_opengl_off.cc new file mode 100644 index 0000000000000..3a88d6863b5e7 --- /dev/null +++ b/src/codegen/opt/build_opengl_off.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build OpenGL modules off + */ +#define TVM_OPENGL_RUNTIME 0 +#include "./build_opengl.h" diff --git a/src/codegen/opt/build_opengl_on.cc b/src/codegen/opt/build_opengl_on.cc new file mode 100644 index 0000000000000..2670feb3d6f2b --- /dev/null +++ b/src/codegen/opt/build_opengl_on.cc @@ -0,0 +1,6 @@ +/*! + * Copyright (c) 2018 by Contributors + * Build OpenGL modules on + */ +#define TVM_OPENGL_RUNTIME 1 +#include "./build_opengl.h" diff --git a/src/runtime/cuda/cuda_common.h b/src/runtime/cuda/cuda_common.h index 0b879dffe6bf7..782fbc5d87e69 100644 --- a/src/runtime/cuda/cuda_common.h +++ b/src/runtime/cuda/cuda_common.h @@ -6,12 +6,9 @@ #ifndef TVM_RUNTIME_CUDA_CUDA_COMMON_H_ #define TVM_RUNTIME_CUDA_CUDA_COMMON_H_ -#include +#include #include #include - -#if TVM_CUDA_RUNTIME -#include #include "../workspace_pool.h" namespace tvm { @@ -49,5 +46,4 @@ class CUDAThreadEntry { }; } // namespace runtime } // namespace tvm -#endif // TVM_CUDA_RUNTIME #endif // TVM_RUNTIME_CUDA_CUDA_COMMON_H_ diff --git a/src/runtime/cuda/cuda_device_api.cc b/src/runtime/cuda/cuda_device_api.cc index 9aeca50584d5d..9f1ea15aeeae8 100644 --- a/src/runtime/cuda/cuda_device_api.cc +++ b/src/runtime/cuda/cuda_device_api.cc @@ -3,10 +3,8 @@ * \file cuda_device_api.cc * \brief GPU specific API */ -#include #include -#if TVM_CUDA_RUNTIME #include #include #include @@ -204,4 +202,3 @@ TVM_REGISTER_GLOBAL("device_api.gpu") } // namespace runtime } // namespace tvm -#endif // TVM_CUDA_RUNTIME diff --git a/src/runtime/cuda/cuda_module.cc b/src/runtime/cuda/cuda_module.cc index fb2de868640a6..a0e613107bae6 100644 --- a/src/runtime/cuda/cuda_module.cc +++ b/src/runtime/cuda/cuda_module.cc @@ -4,8 +4,6 @@ */ #include "./cuda_module.h" -#if TVM_CUDA_RUNTIME - #include #include #include @@ -305,4 +303,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_cuda") }); } // namespace runtime } // namespace tvm -#endif // TVM_CUDA_RUNTIME diff --git a/src/runtime/cuda/cuda_module.h b/src/runtime/cuda/cuda_module.h index 6c7095734aaa9..82427ca8fc22f 100644 --- a/src/runtime/cuda/cuda_module.h +++ b/src/runtime/cuda/cuda_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_CUDA_CUDA_MODULE_H_ #define TVM_RUNTIME_CUDA_CUDA_MODULE_H_ -#include #include #include #include diff --git a/src/runtime/metal/metal_common.h b/src/runtime/metal/metal_common.h index 2f75407f95ce0..205af9533f3b5 100644 --- a/src/runtime/metal/metal_common.h +++ b/src/runtime/metal/metal_common.h @@ -13,7 +13,6 @@ #import #import -#include #include #include #include diff --git a/src/runtime/metal/metal_device_api.mm b/src/runtime/metal/metal_device_api.mm index dcde6945a692c..fae1f0ded88f8 100644 --- a/src/runtime/metal/metal_device_api.mm +++ b/src/runtime/metal/metal_device_api.mm @@ -2,11 +2,9 @@ * Copyright (c) 2017 by Contributors * \file metal_device_api.mm */ -#include "./metal_common.h" - -#if TVM_METAL_RUNTIME #include #include +#include "./metal_common.h" namespace tvm { namespace runtime { @@ -289,5 +287,3 @@ int GetWarpSize(id dev) { } // namespace metal } // namespace runtime } // namespace tvm - -#endif // TVM_METAL_RUNTIME diff --git a/src/runtime/metal/metal_module.h b/src/runtime/metal/metal_module.h index bb2f9c86b7319..9a928e62bd1ba 100644 --- a/src/runtime/metal/metal_module.h +++ b/src/runtime/metal/metal_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_METAL_METAL_MODULE_H_ #define TVM_RUNTIME_METAL_METAL_MODULE_H_ -#include #include #include #include diff --git a/src/runtime/metal/metal_module.mm b/src/runtime/metal/metal_module.mm index 5baefd72ec629..c79e2cf11ac5d 100644 --- a/src/runtime/metal/metal_module.mm +++ b/src/runtime/metal/metal_module.mm @@ -2,16 +2,13 @@ * Copyright (c) 2017 by Contributors * \file metal_module.cc */ -#include "./metal_module.h" - -#if TVM_METAL_RUNTIME - #include #include #include #include #include #include +#include "./metal_module.h" #include "./metal_common.h" #include "../pack_args.h" #include "../thread_storage_scope.h" @@ -304,4 +301,3 @@ Module MetalModuleLoadBinary(void* strm) { }); } // namespace runtime } // namespace tvm -#endif // TVM_METAL_RUNTIME diff --git a/src/runtime/opencl/opencl_common.h b/src/runtime/opencl/opencl_common.h index a97efe408f33d..e2db24f857699 100644 --- a/src/runtime/opencl/opencl_common.h +++ b/src/runtime/opencl/opencl_common.h @@ -6,13 +6,11 @@ #ifndef TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ #define TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ -#include #include #include #include #include -#if TVM_OPENCL_RUNTIME #ifdef __APPLE__ #include #else @@ -192,5 +190,4 @@ class OpenCLThreadEntry { } // namespace cl } // namespace runtime } // namespace tvm -#endif // TVM_OPENCL_RUNTIME #endif // TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ diff --git a/src/runtime/opencl/opencl_device_api.cc b/src/runtime/opencl/opencl_device_api.cc index 07a82d34fd347..759f074b2fc10 100644 --- a/src/runtime/opencl/opencl_device_api.cc +++ b/src/runtime/opencl/opencl_device_api.cc @@ -2,12 +2,9 @@ * Copyright (c) 2017 by Contributors * \file opencl_device_api.cc */ -#include "./opencl_common.h" - -#if TVM_OPENCL_RUNTIME - #include #include +#include "./opencl_common.h" namespace tvm { namespace runtime { @@ -277,5 +274,3 @@ TVM_REGISTER_GLOBAL("device_api.opencl") } // namespace cl } // namespace runtime } // namespace tvm - -#endif // TVM_OPENCL_RUNTIME diff --git a/src/runtime/opencl/opencl_module.cc b/src/runtime/opencl/opencl_module.cc index d8831880fd8da..1d8904ed6f42e 100644 --- a/src/runtime/opencl/opencl_module.cc +++ b/src/runtime/opencl/opencl_module.cc @@ -2,16 +2,14 @@ * Copyright (c) 2017 by Contributors * \file opencl_module.cc */ -#include "./opencl_common.h" -#include "./opencl_module.h" - -#if TVM_OPENCL_RUNTIME - #include #include #include #include #include +#include "./opencl_common.h" +#include "./opencl_module.h" + #include "../pack_args.h" #include "../thread_storage_scope.h" #include "../meta_data.h" @@ -318,5 +316,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opencl") }); } // namespace runtime } // namespace tvm - -#endif // TVM_OPENCL_RUNTIME diff --git a/src/runtime/opencl/opencl_module.h b/src/runtime/opencl/opencl_module.h index 54da2d9b0443f..523a67f1a41ae 100644 --- a/src/runtime/opencl/opencl_module.h +++ b/src/runtime/opencl/opencl_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_ #define TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_ -#include #include #include #include diff --git a/src/runtime/opengl/opengl_common.h b/src/runtime/opengl/opengl_common.h index 252639f3af270..edc425dae9532 100644 --- a/src/runtime/opengl/opengl_common.h +++ b/src/runtime/opengl/opengl_common.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_ #define TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_ -#include #include #include #include diff --git a/src/runtime/opengl/opengl_device_api.cc b/src/runtime/opengl/opengl_device_api.cc index b45ee5079f19d..96ffb3192b7b7 100644 --- a/src/runtime/opengl/opengl_device_api.cc +++ b/src/runtime/opengl/opengl_device_api.cc @@ -2,13 +2,10 @@ * Copyright (c) 2017 by Contributors * \file opengl_device_api.cc */ -#include "./opengl_common.h" -#include "./opengl_module.h" - -#if TVM_OPENGL_RUNTIME - #include #include +#include "./opengl_common.h" +#include "./opengl_module.h" namespace tvm { namespace runtime { @@ -613,5 +610,3 @@ TVM_REGISTER_GLOBAL("device_api.opengl") } // namespace gl } // namespace runtime } // namespace tvm - -#endif // TVM_OPENGL_RUNTIME diff --git a/src/runtime/opengl/opengl_module.cc b/src/runtime/opengl/opengl_module.cc index 6793bd6d29b66..d800af95f053a 100644 --- a/src/runtime/opengl/opengl_module.cc +++ b/src/runtime/opengl/opengl_module.cc @@ -2,14 +2,10 @@ * Copyright (c) 2017 by Contributors * \file opengl_module.cc */ +#include #include - #include "./opengl_common.h" #include "./opengl_module.h" - -#if TVM_OPENGL_RUNTIME - -#include #include "../pack_args.h" #include "../thread_storage_scope.h" #include "../file_util.h" @@ -280,5 +276,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opengl") } // namespace runtime } // namespace tvm - -#endif // TVM_OPENGL_RUNTIME diff --git a/src/runtime/opengl/opengl_module.h b/src/runtime/opengl/opengl_module.h index a4cfa20bd734c..9e5f4044b3b6c 100644 --- a/src/runtime/opengl/opengl_module.h +++ b/src/runtime/opengl/opengl_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_ #define TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_ -#include #include #include #include diff --git a/src/runtime/rocm/rocm_common.h b/src/runtime/rocm/rocm_common.h index 63e4bff4582b6..a6898122e3894 100644 --- a/src/runtime/rocm/rocm_common.h +++ b/src/runtime/rocm/rocm_common.h @@ -6,12 +6,9 @@ #ifndef TVM_RUNTIME_ROCM_ROCM_COMMON_H_ #define TVM_RUNTIME_ROCM_ROCM_COMMON_H_ -#include #include -#include - -#if TVM_ROCM_RUNTIME #include +#include #include "../workspace_pool.h" namespace tvm { @@ -19,17 +16,17 @@ namespace runtime { #define ROCM_DRIVER_CALL(x) \ { \ - hipError_t result = x; \ - if (result != hipSuccess && result != hipErrorDeinitialized) { \ + hipError_t result = x; \ + if (result != hipSuccess && result != hipErrorDeinitialized) { \ LOG(FATAL) \ - << "ROCM HIP Error: " #x " failed with error: " << hipGetErrorString(result); \ + << "ROCM HIP Error: " #x " failed with error: " << hipGetErrorString(result); \ } \ } -#define ROCM_CALL(func) \ - { \ - hipError_t e = (func); \ - CHECK(e == hipSuccess) \ +#define ROCM_CALL(func) \ + { \ + hipError_t e = (func); \ + CHECK(e == hipSuccess) \ << "ROCM HIP: " << hipGetErrorString(e); \ } @@ -47,5 +44,4 @@ class ROCMThreadEntry { }; } // namespace runtime } // namespace tvm -#endif // TVM_ROCM_RUNTIME #endif // TVM_RUNTIME_ROCM_ROCM_COMMON_H_ diff --git a/src/runtime/rocm/rocm_device_api.cc b/src/runtime/rocm/rocm_device_api.cc index 47b9e8da7e2e3..3438e8edeaec2 100644 --- a/src/runtime/rocm/rocm_device_api.cc +++ b/src/runtime/rocm/rocm_device_api.cc @@ -3,10 +3,8 @@ * \file rocm_device_api.cc * \brief GPU specific API */ -#include #include -#if TVM_ROCM_RUNTIME #include #include #include @@ -162,4 +160,3 @@ TVM_REGISTER_GLOBAL("device_api.rocm") } // namespace runtime } // namespace tvm -#endif // TVM_ROCM_RUNTIME diff --git a/src/runtime/rocm/rocm_module.cc b/src/runtime/rocm/rocm_module.cc index d93862747bba0..503b04872c82d 100644 --- a/src/runtime/rocm/rocm_module.cc +++ b/src/runtime/rocm/rocm_module.cc @@ -2,16 +2,13 @@ * Copyright (c) 2017 by Contributors * \file rocm_module.cc */ -#include "./rocm_module.h" - -#if TVM_ROCM_RUNTIME - #include #include #include #include #include #include +#include "./rocm_module.h" #include "./rocm_common.h" #include "../pack_args.h" #include "../thread_storage_scope.h" @@ -237,4 +234,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_hip") }); } // namespace runtime } // namespace tvm -#endif // TVM_ROCM_RUNTIME diff --git a/src/runtime/rocm/rocm_module.h b/src/runtime/rocm/rocm_module.h index 039326ab1223a..4386157fc9864 100644 --- a/src/runtime/rocm/rocm_module.h +++ b/src/runtime/rocm/rocm_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_ROCM_ROCM_MODULE_H_ #define TVM_RUNTIME_ROCM_ROCM_MODULE_H_ -#include #include #include #include diff --git a/src/runtime/vulkan/vulkan_common.h b/src/runtime/vulkan/vulkan_common.h index 0d02c0aaadcf7..9dcd5f429b686 100644 --- a/src/runtime/vulkan/vulkan_common.h +++ b/src/runtime/vulkan/vulkan_common.h @@ -6,14 +6,11 @@ #ifndef TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_ #define TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_ -#include #include #include #include #include -#if TVM_VULKAN_RUNTIME - #include #include #include @@ -281,5 +278,4 @@ class VulkanThreadEntry { } // namespace vulkan } // namespace runtime } // namespace tvm -#endif // TVM_VULKAN_RUNTIME #endif // TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_ diff --git a/src/runtime/vulkan/vulkan_device_api.cc b/src/runtime/vulkan/vulkan_device_api.cc index 2abb0c277419a..891b39456558d 100644 --- a/src/runtime/vulkan/vulkan_device_api.cc +++ b/src/runtime/vulkan/vulkan_device_api.cc @@ -2,14 +2,10 @@ * Copyright (c) 2017 by Contributors * \file vulkan_device_api.cc */ -#include "./vulkan_common.h" - -#if TVM_VULKAN_RUNTIME - #include #include #include - +#include "./vulkan_common.h" namespace tvm { namespace runtime { @@ -693,5 +689,3 @@ TVM_REGISTER_GLOBAL("device_api.vulkan") } // namespace vulkan } // namespace runtime } // namespace tvm - -#endif // TVM_VULKAN_RUNTIME diff --git a/src/runtime/vulkan/vulkan_module.cc b/src/runtime/vulkan/vulkan_module.cc index 50ed744c512c8..56b4c79bcedfb 100644 --- a/src/runtime/vulkan/vulkan_module.cc +++ b/src/runtime/vulkan/vulkan_module.cc @@ -2,10 +2,6 @@ * Copyright (c) 2018 by Contributors * \file vulkan_module.cc */ -#include "./vulkan_module.h" - -#if TVM_VULKAN_RUNTIME - #include #include #include @@ -13,6 +9,7 @@ #include #include #include "./vulkan_common.h" +#include "./vulkan_module.h" #include "../pack_args.h" #include "../thread_storage_scope.h" #include "../meta_data.h" @@ -421,4 +418,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_vulkan") }); } // namespace runtime } // namespace tvm -#endif // TVM_VULKAN_RUNTIME diff --git a/src/runtime/vulkan/vulkan_module.h b/src/runtime/vulkan/vulkan_module.h index 65b6d24c8ad61..41dcfd310dcae 100644 --- a/src/runtime/vulkan/vulkan_module.h +++ b/src/runtime/vulkan/vulkan_module.h @@ -6,7 +6,6 @@ #ifndef TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_ #define TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_ -#include #include #include #include diff --git a/tests/scripts/task_build.sh b/tests/scripts/task_build.sh index dc524f1403d2c..2225d6eea5c3a 100755 --- a/tests/scripts/task_build.sh +++ b/tests/scripts/task_build.sh @@ -1,7 +1,2 @@ #!/bin/bash -echo "Build TVM..." -make "$@" -cd nnvm - -echo "Build NNVM..." -make "$@" +cd $1 && cmake .. && make $2 && cd .. diff --git a/tests/scripts/task_clean.sh b/tests/scripts/task_clean.sh index baecd292ff8f9..68c04c332a349 100755 --- a/tests/scripts/task_clean.sh +++ b/tests/scripts/task_clean.sh @@ -1,6 +1,3 @@ #!/bin/bash echo "Cleanup data..." -cd nnvm -make clean -cd .. -make clean +rm -rf $1 diff --git a/tests/scripts/task_cpp_unittest.sh b/tests/scripts/task_cpp_unittest.sh index 9a140b64e089c..2996fd6099a16 100755 --- a/tests/scripts/task_cpp_unittest.sh +++ b/tests/scripts/task_cpp_unittest.sh @@ -1,7 +1,7 @@ #!/bin/bash export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} -make test -j8 || exit -1 -for test in tests/cpp/*_test; do +make cpptest -j8 || exit -1 +for test in build/*_test; do ./$test || exit -1 done diff --git a/tests/scripts/task_java_unittest.sh b/tests/scripts/task_java_unittest.sh index 9017079237f10..8ae79b5c52b29 100755 --- a/tests/scripts/task_java_unittest.sh +++ b/tests/scripts/task_java_unittest.sh @@ -1,6 +1,5 @@ #!/bin/bash -export PYTHONPATH=python:apps/extension/python -export PYTHONPATH=${PYTHONPATH}:apps/graph_executor/python:apps/graph_executor/nnvm/python +export PYTHONPATH=python export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} CURR_DIR=$(cd `dirname $0`; pwd) diff --git a/tests/scripts/task_python_integration.sh b/tests/scripts/task_python_integration.sh index 7cdade714aa5d..ab56ca3e8f6f9 100755 --- a/tests/scripts/task_python_integration.sh +++ b/tests/scripts/task_python_integration.sh @@ -1,6 +1,6 @@ #!/bin/bash export PYTHONPATH=python:apps/extension/python -export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} +export LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH} rm -rf python/tvm/*.pyc python/tvm/*/*.pyc