diff --git a/CMakeLists.txt b/CMakeLists.txt index 45116732..6125281c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,35 @@ endif() if (USE_BANG) add_compile_definitions(USE_BANG) + include_directories(src/kernels/mlu/include) + + # Neuware Evironment + if ((NOT DEFINED NEUWARE_HOME) AND (NOT DEFINED ENV{NEUWARE_HOME})) + message(FATAL_ERROR "NEUWARE_HOME is not defined from cmake or env") + elseif (DEFINED NEUWARE_HOME) + set(NEUWARE_HOME ${NEUWARE_HOME} CACHE STRING "NEUWARE_HOME directory for Cambricon Neuware development") + else() + set(NEUWARE_HOME $ENV{NEUWARE_HOME} CACHE STRING "NEUWARE_HOME directory for Cambricon Neuware development") + endif() + message(STATUS "NEUWARE_HOME: ${NEUWARE_HOME}") + + # cnrt cndrv cnnl + include_directories("${NEUWARE_HOME}/include") + find_library(CAMBRICON_CNNL libcnnl.so "${NEUWARE_HOME}/lib64") + find_library(CAMBRICON_CNRT libcnrt.so "${NEUWARE_HOME}/lib64") + find_library(CAMBRICON_CNDRV libcndrv.so "${NEUWARE_HOME}/lib64") + find_library(CAMBRICON_CNCL libcncl.so "${NEUWARE_HOME}/lib64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lstdc++ -Wall -Werror") + + if ((NOT DEFINED TARGET_CPU_ARCH) AND (NOT DEFINED ENV{TARGET_CPU_ARCH})) + execute_process(COMMAND uname -m OUTPUT_VARIABLE _uname_m OUTPUT_STRIP_TRAILING_WHITESPACE) + set(TARGET_CPU_ARCH "${_uname_m}" CACHE STRING "Target CPU ARCH") + elseif(DEFINED TARGET_CPU_ARCH) + set(TARGET_CPU_ARCH ${TARGET_CPU_ARCH} CACHE STRING "Target CPU ARCH") + else() + set(TARGET_CPU_ARCH $ENV{TARGET_CPU_ARCH} CACHE STRING "Target CPU ARCH") + endif() + message(STATUS "TARGET_CPU_ARCH: ${TARGET_CPU_ARCH}") endif() add_compile_options(-march=native) # this will cause error in some machine diff --git a/Makefile b/Makefile index 571515f5..48208765 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ CMAKE_EXTRA = build: mkdir -p build - cmake -Bbuild -DCMAKE_BUILD_TYPE=$(TYPE) -DUSE_CUDA=$(CUDA) -DUSE_KUNLUN=$(KUNLUN) $(CMAKE_EXTRA) + cmake -Bbuild -DCMAKE_BUILD_TYPE=$(TYPE) -DUSE_CUDA=$(CUDA) -DUSE_KUNLUN=$(KUNLUN) -DUSE_BANG=$(BANG) $(CMAKE_EXTRA) make -j -C build install-python: build diff --git a/src/04kernel/CMakeLists.txt b/src/04kernel/CMakeLists.txt index f09a9fed..e8564af4 100644 --- a/src/04kernel/CMakeLists.txt +++ b/src/04kernel/CMakeLists.txt @@ -35,6 +35,9 @@ if(USE_KUNLUN) find_library(KUNLUN_DNN libxpuapi.so ${KUNLUN_HOME}/XTDK/shlib) target_link_libraries(kernel PUBLIC ${KUNLUN_RT} ${KUNLUN_DNN}) endif() +if(USE_BANG) + target_link_libraries(kernel ${CAMBRICON_CNCL} ${CAMBRICON_CNNL} ${CAMBRICON_CNRT} ${CAMBRICON_CNDRV} stdc++) +endif() file(GLOB_RECURSE KERNEL_TEST test/*.cpp) if(KERNEL_TEST)