Commit 45cdaf3c authored by jerem's avatar jerem Committed by jeremad

fix openCL and CUDA from ubuntu

parent a3d5481f
...@@ -31,20 +31,19 @@ if (WINDOWS) ...@@ -31,20 +31,19 @@ if (WINDOWS)
find_library(NVML nvml PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" NO_DEFAULT_PATH) find_library(NVML nvml PATHS "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" NO_DEFAULT_PATH)
endif(WINDOWS) endif(WINDOWS)
if (LINUX) if(LINUX)
set(CUDA_PROPAGATE_HOST_FLAGS "FALSE") set(CUDA_PROPAGATE_HOST_FLAGS "FALSE")
if(TEGRA_DEMO) if(TEGRA_DEMO)
set(LINUX_CUDA_PATH ${CUDA_TOOLKIT_TARGET_DIR}/lib) set(LINUX_CUDA_PATH ${CUDA_TOOLKIT_TARGET_DIR}/lib)
find_library(GLEW_LIBRARIES GLEW NO_CMAKE_FIND_ROOT_PATH) find_library(GLEW_LIBRARIES GLEW NO_CMAKE_FIND_ROOT_PATH)
find_library(OPENGL_LIBRARIES GL NO_CMAKE_FIND_ROOT_PATH) find_library(OPENGL_LIBRARIES GL NO_CMAKE_FIND_ROOT_PATH)
else(TEGRA_DEMO) else()
find_package(GLEW) find_package(GLEW)
find_library(CUDA cuda PATHS "${LINUX_CUDA_PATH}/stubs") find_library(CUDA cuda PATHS "${LINUX_CUDA_PATH}/stubs")
find_library(CUDART cudart PATHS ${LINUX_CUDA_PATH}) find_library(CUDART cudart PATHS ${LINUX_CUDA_PATH})
find_library(NVML nvidia-ml PATHS "${LINUX_CUDA_PATH}/stubs") find_library(NVML nvidia-ml PATHS "${LINUX_CUDA_PATH}/stubs")
endif(TEGRA_DEMO) endif()
include_directories(${CMAKE_EXTERNAL_DEPS}/include) include_directories(${CMAKE_EXTERNAL_DEPS}/include)
link_directories(${LINUX_CUDA_PATH})
find_library(CUVID nvcuvid) find_library(CUVID nvcuvid)
endif(LINUX) endif(LINUX)
......
...@@ -50,19 +50,16 @@ include_discovery_vs_headers(${VS_DISCOVERY}) ...@@ -50,19 +50,16 @@ include_discovery_vs_headers(${VS_DISCOVERY})
if(NOT ANDROID) if(NOT ANDROID)
find_package(OpenCL) find_package(OpenCL)
endif (NOT ANDROID) endif()
if(OpenCL_FOUND) if(OpenCL_FOUND AND GPU_BACKEND_OPENCL)
target_include_directories(${VS_DISCOVERY} PRIVATE ${OpenCL_INCLUDE_DIRS}) target_include_directories(${VS_DISCOVERY} PRIVATE ${OpenCL_INCLUDE_DIRS})
target_link_libraries(${VS_DISCOVERY} PUBLIC ${OpenCL_LIBRARY}) target_link_libraries(${VS_DISCOVERY} PUBLIC ${OpenCL_LIBRARIES})
# different names on different implementations of find_package(OpenCL) if(WINDOWS)
set(PLATFORM_INDEPENDENT_OPENCL_LIBS ${OpenCL_LIBRARIES} ${OPENCL_LIBRARIES})
target_link_libraries(${VS_DISCOVERY} PRIVATE ${PLATFORM_INDEPENDENT_OPENCL_LIBS})
if(MSVC)
target_link_libraries(${VS_DISCOVERY} PRIVATE "DelayImp.lib") target_link_libraries(${VS_DISCOVERY} PRIVATE "DelayImp.lib")
set_target_properties(${VS_DISCOVERY} PROPERTIES LINK_FLAGS "/DELAYLOAD:OpenCL.dll") set_target_properties(${VS_DISCOVERY} PROPERTIES LINK_FLAGS "/DELAYLOAD:OpenCL.dll")
endif(MSVC) endif()
target_compile_definitions(${VS_DISCOVERY} PRIVATE OPENCL_FOUND) target_compile_definitions(${VS_DISCOVERY} PRIVATE OPENCL_FOUND)
endif(OpenCL_FOUND) endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# CUDA # CUDA
...@@ -71,7 +68,7 @@ endif(OpenCL_FOUND) ...@@ -71,7 +68,7 @@ endif(OpenCL_FOUND)
if(NOT CUDA_FOUND) if(NOT CUDA_FOUND)
include (${CMAKE_SOURCE_DIR}/cmake/getCuda.cmake) include (${CMAKE_SOURCE_DIR}/cmake/getCuda.cmake)
endif (NOT CUDA_FOUND) endif (NOT CUDA_FOUND)
if (CUDA_FOUND) if(CUDA_FOUND)
target_include_directories(${VS_DISCOVERY} PRIVATE ${CUDA_INCLUDE_DIRS}) target_include_directories(${VS_DISCOVERY} PRIVATE ${CUDA_INCLUDE_DIRS})
target_link_libraries(${VS_DISCOVERY} PRIVATE ${CUDA_LIBRARIES}) target_link_libraries(${VS_DISCOVERY} PRIVATE ${CUDA_LIBRARIES})
target_compile_definitions(${VS_DISCOVERY} PRIVATE CUDA_FOUND) target_compile_definitions(${VS_DISCOVERY} PRIVATE CUDA_FOUND)
...@@ -136,4 +133,3 @@ if(STAGING) ...@@ -136,4 +133,3 @@ if(STAGING)
else() else()
add_test(NAME ${DEVICE_NAME_TEST} COMMAND ${DEVICE_NAME_TEST}) add_test(NAME ${DEVICE_NAME_TEST} COMMAND ${DEVICE_NAME_TEST})
endif() endif()
...@@ -58,11 +58,15 @@ sudo apt install ...@@ -58,11 +58,15 @@ sudo apt install
libturbojpeg0-dev \ libturbojpeg0-dev \
libx264-dev \ libx264-dev \
ninja-build \ ninja-build \
ocl-icd-opencl-dev \
opencl-headers \
portaudio19-dev \ portaudio19-dev \
qt5-default \ qt5-default \
qtmultimedia5-dev \ qtmultimedia5-dev \
qttools5-dev \ qttools5-dev \
swig swig \
wget \
xxd
# Set up gcc-6 and g++-6 as your compiler # Set up gcc-6 and g++-6 as your compiler
sudo apt-get install gcc-6 g++-6 sudo apt-get install gcc-6 g++-6
......
...@@ -5,6 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive ...@@ -5,6 +5,7 @@ ENV DEBIAN_FRONTEND=noninteractive
RUN apt update && apt install -y \ RUN apt update && apt install -y \
bison \ bison \
ccache \ ccache \
clang \
doxygen \ doxygen \
flex \ flex \
git \ git \
...@@ -22,13 +23,16 @@ RUN apt update && apt install -y \ ...@@ -22,13 +23,16 @@ RUN apt update && apt install -y \
librtmp-dev \ librtmp-dev \
libx264-dev \ libx264-dev \
ninja-build \ ninja-build \
ocl-icd-opencl-dev \
opencl-headers \
portaudio19-dev \ portaudio19-dev \
python-pip \ python-pip \
qt5-default \ qt5-default \
qtmultimedia5-dev \ qtmultimedia5-dev \
qttools5-dev \ qttools5-dev \
swig \ swig \
wget wget \
xxd
RUN pip install cmake RUN pip install cmake
RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub RUN wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
RUN apt-key add 7fa2af80.pub RUN apt-key add 7fa2af80.pub
......
...@@ -5,5 +5,5 @@ ADD . stitchEm ...@@ -5,5 +5,5 @@ ADD . stitchEm
WORKDIR stitchEm WORKDIR stitchEm
RUN echo ${CUDA_SHORT} > cuda.version RUN echo ${CUDA_SHORT} > cuda.version
WORKDIR build WORKDIR build
RUN cmake -DCMAKE_BUILD_TYPE=Release -DRTMP_NVENC=OFF -DCUDA_TARGET_ARCH="50" -G Ninja .. RUN cmake -DCMAKE_BUILD_TYPE=Release -DRTMP_NVENC=OFF -DCUDA_TARGET_ARCH="50" -DGPU_BACKEND_CUDA=ON -DGPU_BACKEND_OPENCL=OFF -DDISABLE_OPENCL_SPIR=ON -G Ninja ..
CMD ninja CMD ninja
...@@ -148,9 +148,9 @@ if(ANDROID) ...@@ -148,9 +148,9 @@ if(ANDROID)
vs_lib_link_libraries("CUDA" ${GLEW} log) vs_lib_link_libraries("CUDA" ${GLEW} log)
message(STATUS "CUDA_LIBRARIES = ${CUDA_LIBRARIES}") message(STATUS "CUDA_LIBRARIES = ${CUDA_LIBRARIES}")
else() else()
vs_lib_link_libraries("PUBLIC_CUDA" ${CUDART} ${CUDA_LIBRARIES} ${NVTX}) vs_lib_link_libraries("CUDA" ${CUDART} ${NVTX})
vs_lib_link_libraries("CUDA" ${OpenGL} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLEW}) vs_lib_link_libraries("CUDA" ${OpenGL} ${OPENGL_LIBRARIES} ${GLEW_LIBRARIES} ${GLEW})
vs_lib_link_libraries("PUBLIC_CUDA" ${NVML}) vs_lib_link_libraries("PUBLIC_CUDA" ${NVML} ${CUDA_LIBRARIES})
if(CMAKE_CROSSCOMPILING) if(CMAKE_CROSSCOMPILING)
# needed by ceres # needed by ceres
vs_lib_link_libraries("CUDA" -fopenmp) vs_lib_link_libraries("CUDA" -fopenmp)
...@@ -161,5 +161,5 @@ else() ...@@ -161,5 +161,5 @@ else()
else() else()
vs_lib_link_libraries("PUBLIC_CUDA" ${CUDA}) vs_lib_link_libraries("PUBLIC_CUDA" ${CUDA})
endif() endif()
endif(ANDROID) endif()
option(DISABLE_OPENCL_SPIR "Skip OpenCL offline compilation and ship kernel sources") option(DISABLE_OPENCL_SPIR "Skip OpenCL offline compilation and ship kernel sources")
option(CL_ARGS_WORKAROUND "Redefining functions to support OpenCL limitation in parameters format") option(CL_ARGS_WORKAROUND "Redefining functions to support OpenCL limitation in parameters format")
if(DISABLE_OPENCL_SPIR) if(NOT DISABLE_OPENCL_SPIR)
message(WARNING "Careful: OpenCL offline compilation disabled. Binary will contain all OpenCL kernel sources as plain text!")
else(DISABLE_OPENCL_SPIR)
if (LINUX OR ANDROID) if (LINUX OR ANDROID)
message("No Alternative OpenCL SPIR compiler for Linux") message("No Alternative OpenCL SPIR compiler for Linux")
else(LINUX OR ANDROID) else()
option(ALTERNATIVE_OPENCL_SPIR "GENERATE an alternative SPIR that will be used if something goes wrong with the main SPIR" ON) option(ALTERNATIVE_OPENCL_SPIR "GENERATE an alternative SPIR that will be used if something goes wrong with the main SPIR" ON)
endif(LINUX OR ANDROID) endif()
endif(DISABLE_OPENCL_SPIR) endif()
set(CL_BACKEND_SOURCES set(CL_BACKEND_SOURCES
src/backend/cl/bilateral/bilateral.cpp src/backend/cl/bilateral/bilateral.cpp
...@@ -92,7 +90,6 @@ add_cppcheck(${VS_LIB_OBJECTS_OPENCL} VS) ...@@ -92,7 +90,6 @@ add_cppcheck(${VS_LIB_OBJECTS_OPENCL} VS)
# Add compile definitions # Add compile definitions
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
if(DISABLE_OPENCL_SPIR) if(DISABLE_OPENCL_SPIR)
message(WARNING "Careful: OpenCL offline compilation disabled. Binary will contain all OpenCL kernel sources as plain text!")
target_compile_definitions(${VS_LIB_OBJECTS_OPENCL} PRIVATE "DISABLE_OPENCL_SPIR") target_compile_definitions(${VS_LIB_OBJECTS_OPENCL} PRIVATE "DISABLE_OPENCL_SPIR")
endif() endif()
if(CL_ARGS_WORKAROUND) if(CL_ARGS_WORKAROUND)
......
...@@ -47,7 +47,7 @@ set(VS_LIB_ROOT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..) ...@@ -47,7 +47,7 @@ set(VS_LIB_ROOT_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../..)
if(APPLE) if(APPLE)
find_program(OPENCL_OFFLINE_COMPILER openclc find_program(OPENCL_OFFLINE_COMPILER openclc
PATHS ${OpenCL_LIBRARY}/Libraries/ PATHS ${OpenCL_LIBRARIES}/Libraries/
/System/Library/Frameworks/OpenCL.framework/Libraries /System/Library/Frameworks/OpenCL.framework/Libraries
DOC "OpenCL offline compiler to build spir files from kernel sources") DOC "OpenCL offline compiler to build spir files from kernel sources")
if (ALTERNATIVE_OPENCL_SPIR) if (ALTERNATIVE_OPENCL_SPIR)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment