[Parallel_libs-commits] [PATCH] D24580: [SE] Let users specify CUDA path

Jason Henline via Parallel_libs-commits parallel_libs-commits at lists.llvm.org
Wed Sep 14 13:28:58 PDT 2016


jhen created this revision.
jhen added a reviewer: jlebar.
jhen added subscribers: parallel_libs-commits, jprice.
Herald added subscribers: jlebar, mgorny, beanz.

Add logic to allow users to specify the CUDA path at configuration time.

https://reviews.llvm.org/D24580

Files:
  streamexecutor/CMakeLists.txt
  streamexecutor/lib/CMakeLists.txt
  streamexecutor/lib/platforms/cuda/cmake/modules/FindLIBCUDA.cmake
  streamexecutor/lib/platforms/cuda/cmake/modules/FindLibcuda.cmake

Index: streamexecutor/lib/platforms/cuda/cmake/modules/FindLIBCUDA.cmake
===================================================================
--- streamexecutor/lib/platforms/cuda/cmake/modules/FindLIBCUDA.cmake
+++ streamexecutor/lib/platforms/cuda/cmake/modules/FindLIBCUDA.cmake
@@ -3,10 +3,35 @@
 #  LIBCUDA_FOUND - System has libcuda
 #  LIBCUDA_INCLUDE_DIRS - The libcuda include directories
 #  LIBCUDA_LIBRARIES - The libraries needed to use libcuda
+#
+# Use the CUDA_ROOT environment variable or the CUDA_ROOT CMake variable to
+# specify the first directory to search for cuda.h.
+
+# First search based on the CUDA_ROOT cmake variable.
+find_path(
+    LIBCUDA_INCLUDE_DIR
+    cuda.h
+    PATHS
+    ${CUDA_ROOT}/include
+    NO_DEFAULT_PATH)
+
+# Then search based on the CUDA_ROOT environment variable.
+find_path(
+    LIBCUDA_INCLUDE_DIR
+    cuda.h
+    PATHS
+    ENV CUDA_ROOT
+    PATH_SUFFIXES include
+    NO_DEFAULT_PATH)
+
+# Finally, search based on a well-known location.
+find_path(
+    LIBCUDA_INCLUDE_DIR
+    cuda.h
+    PATHS
+    /usr/local/cuda/include
+    NO_DEFAULT_PATH)
 
-# TODO(jhen): Allow users to specify a search path.
-find_path(LIBCUDA_INCLUDE_DIR cuda.h /usr/local/cuda/include)
-# TODO(jhen): Use the library that goes with the headers.
 find_library(LIBCUDA_LIBRARY cuda)
 
 include(FindPackageHandleStandardArgs)
Index: streamexecutor/lib/CMakeLists.txt
===================================================================
--- streamexecutor/lib/CMakeLists.txt
+++ streamexecutor/lib/CMakeLists.txt
@@ -9,7 +9,7 @@
         ${CMAKE_MODULE_PATH}
         "${CMAKE_CURRENT_SOURCE_DIR}/platforms/cuda/cmake/modules/")
 
-    find_package(Libcuda REQUIRED)
+    find_package(LIBCUDA REQUIRED)
     include_directories(${LIBCUDA_INCLUDE_DIRS})
 
     set(
Index: streamexecutor/CMakeLists.txt
===================================================================
--- streamexecutor/CMakeLists.txt
+++ streamexecutor/CMakeLists.txt
@@ -2,10 +2,18 @@
 
 option(STREAM_EXECUTOR_UNIT_TESTS "enable unit tests" ON)
 option(STREAM_EXECUTOR_ENABLE_DOXYGEN "enable StreamExecutor doxygen" ON)
-option(STREAM_EXECUTOR_ENABLE_CONFIG_TOOL "enable building streamexecutor-config tool" ON)
-option(STREAM_EXECUTOR_ENABLE_CUDA_PLATFORM "enable building the CUDA StreamExecutor platform" OFF)
-
-configure_file("include/streamexecutor/PlatformOptions.h.in" "include/streamexecutor/PlatformOptions.h")
+option(
+    STREAM_EXECUTOR_ENABLE_CONFIG_TOOL
+    "enable building streamexecutor-config tool"
+    ON)
+option(STREAM_EXECUTOR_ENABLE_CUDA_PLATFORM
+    "enable building the CUDA StreamExecutor platform \
+(use CUDA_ROOT to specify the CUDA path such as /usr/local/cuda)"
+    OFF)
+
+configure_file(
+    "include/streamexecutor/PlatformOptions.h.in"
+    "include/streamexecutor/PlatformOptions.h")
 
 # First find includes relative to the streamexecutor top-level source path.
 include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24580.71420.patch
Type: text/x-patch
Size: 2979 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/parallel_libs-commits/attachments/20160914/72f728a7/attachment.bin>


More information about the Parallel_libs-commits mailing list