Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda registration #822

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build
buildcuda
compile

# Dependency folders
depends/*/
Expand Down Expand Up @@ -123,6 +125,11 @@ ClientBin/
*.pfx
*.publishsettings

# Nsight Nvidia Eclipse
.cproject
.project
.settings/

# RIA/Silverlight projects
Generated_Code/

Expand Down
57 changes: 42 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#CMAKE_MINIMUM_REQUIRED(VERSION 3.28.3)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12.1)

SET(PROJECT_VER_MAJOR 0)
Expand Down Expand Up @@ -45,7 +46,6 @@ OPTION(ENABLE_PROFILING "Collect profiling stats (memory consuming)" OFF)
IF(ENABLE_PROFILING)
SET(LIBFREENECT2_WITH_PROFILING 1)
ENDIF()

IF(MSVC)
# suppress several "possible loss of data" warnings, and
# "zero-length array in struct" from libusb.h
Expand Down Expand Up @@ -266,6 +266,7 @@ ENDIF()
SET(HAVE_OpenGL disabled)
IF(ENABLE_OPENGL)
FIND_PACKAGE(GLFW3)
set(OpenGL_GL_PREFERENCE "GLVND")
FIND_PACKAGE(OpenGL)
SET(HAVE_OpenGL no)
IF(GLFW3_FOUND AND OPENGL_FOUND)
Expand All @@ -277,7 +278,8 @@ IF(ENABLE_OPENGL)
LIST(APPEND LIBFREENECT2_DLLS ${GLFW3_DLL})
LIST(APPEND LIBRARIES
${GLFW3_LIBRARIES}
${OPENGL_gl_LIBRARY}
${OPENGL_GL_LIBRARY}
${OPENGL_LIBRARIES}
)
LIST(APPEND SOURCES
src/flextGL.cpp
Expand Down Expand Up @@ -337,53 +339,78 @@ IF(ENABLE_OPENCL)
ENDIF(OpenCL_FOUND)
ENDIF(ENABLE_OPENCL)


SET(HAVE_CUDA disabled)
IF(ENABLE_CUDA)
FIND_PACKAGE(CUDA)
INCLUDE(CheckLanguage)
CHECK_LANGUAGE(CUDA)
# FIND_PACKAGE(CUDA)
SET(HAVE_CUDA no)
IF(CUDA_FOUND AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
#IF(CUDA_FOUND AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
IF(CMAKE_CUDA_COMPILER AND MSVC14 AND CUDA_VERSION VERSION_LESS 8.0)
SET(HAVE_CUDA "no (VS2015 not supported)")
ELSEIF(CUDA_FOUND)
#ELSEIF(CUDA_FOUND)
ELSEIF(CMAKE_CUDA_COMPILER)
SET(LIBFREENECT2_WITH_CUDA_SUPPORT 1)
SET(HAVE_CUDA yes)
ENABLE_LANGUAGE(CUDA)

#FIND_PACKAGE(CUDAToolkit)
STRING(REPLACE "\\" "/" NVCUDASAMPLES_ROOT "$ENV{NVCUDASAMPLES_ROOT}")
STRING(REPLACE "\\" "/" NVCUDASAMPLES8_0_ROOT "$ENV{NVCUDASAMPLES8_0_ROOT}")
CUDA_INCLUDE_DIRECTORIES(
#CUDA_INCLUDE_DIRECTORIES(
INCLUDE_DIRECTORIES(
"${MY_DIR}/include/"
"${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc"
"${NVCUDASAMPLES_ROOT}/common/inc"
"${NVCUDASAMPLES8_0_ROOT}/common/inc"
)
SET(CUDA_FLAGS -use_fast_math)
IF(NOT MSVC)
SET(CUDA_FLAGS "${CUDA_FLAGS} -Xcompiler -fPIC")
SET(CUDA_FLAGS "${CUDA_FLAGS} -Xcompiler -fPIC -D_FORCE_INLINES")
ENDIF()
IF(HAVE_CXX11 STREQUAL yes AND CUDA_VERSION VERSION_GREATER 7.0)
SET(CUDA_FLAGS "${CUDA_FLAGS} -std=c++11")
ENDIF()

SET(OLD_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
STRING(REGEX REPLACE "-std=c\\+\\+.." "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
CUDA_COMPILE(CUDA_OBJECTS
# Thrust requires exceptions. If OpenCL from NVidia is used we don't need this flag.
STRING(REGEX REPLACE "-fno-exceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "*************")
MESSAGE(STATUS ${CMAKE_CXX_FLAGS})
MESSAGE(STATUS ${CUDA_FLAGS})
MESSAGE(STATUS ${CUDA_INCLUDE_DIRS})
MESSAGE(STATUS ${CUDA_LIBRARIES})
MESSAGE(STATUS ${CUDA_OBJECTS})
MESSAGE(STATUS "*************")
#CUDA_COMPILE(CUDA_OBJECTS
LIST(APPEND SOURCES
#include/libfreenect2/cuda_registration.h
src/cuda_depth_packet_processor.cu
src/cuda_kde_depth_packet_processor.cu
OPTIONS ${CUDA_FLAGS}
src/cuda_registration.cu
#OPTIONS ${CUDA_FLAGS}
)
SET(CMAKE_CXX_FLAGS "${OLD_CMAKE_CXX_FLAGS}")

INCLUDE_DIRECTORIES(${CUDA_INCLUDE_DIRS})

LIST(APPEND SOURCES
${CUDA_OBJECTS}
)
#LIST(APPEND SOURCES
# ${CUDA_OBJECTS}
#)

LIST(APPEND LIBRARIES
${CUDA_LIBRARIES}
)
#LIST(APPEND LIBRARIES
# ${CUDA_LIBRARIES}
#)
#set_target_properties(freenect2 PROPERTIES CUDA_ARCHITECTURES "35;50;75")
#SET_PROPERTY(TARGET freenect2 PROPERTY CUDA_ARCHITECTURES OFF)
ENDIF()
#ENDIF(CMAKE_CUDA_COMPILER)
ENDIF(ENABLE_CUDA)



# RPATH handling for CUDA 8.0 libOpenCL.so conflict. See #804.
IF(HAVE_OpenCL STREQUAL yes AND UNIX AND NOT APPLE)
FILE(GLOB CUDA_ld_so_conf /etc/ld.so.conf.d/cuda*.conf)
Expand Down
Loading