Skip to content

Commit

Permalink
Turn CUDA support off by default
Browse files Browse the repository at this point in the history
1. Stop depending on the deprecated FindCUDA module,
2. Add a new FindOmrCuda module, which locates a minimum set of headers
   needed by OMR,
3. Stop automatically enabling OMR_OPT_CUDA when the dependencies are
   present.

Signed-off-by: Robert Young <rwy0717@gmail.com>
  • Loading branch information
rwy7 committed Oct 28, 2019
1 parent c1ba8e2 commit 31f4f6c
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 23 deletions.
17 changes: 0 additions & 17 deletions CMakeLists.txt
Expand Up @@ -63,23 +63,6 @@ set(OMR_INSTALL_ARCHIVE_DIR ${CMAKE_INSTALL_LIBDIR} CACHE PATH "Installation dir
set(OMR_INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR} CACHE PATH "Installation directory for headers")
set(OMR_INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME} CACHE PATH "Installation directory for data files")

###
### CUDA Support
###

if (OMR_ENV_DATA64)
find_package(Threads)
if(Threads_FOUND)
# Threads mush be found before we can look for CUDA.
# FindCuda will error out if Threads is missing, even though CUDA itself is optional.
find_package(CUDA)
else()
set(CUDA_FOUND OFF CACHE BOOL "CUDA is disabled (threads not found)")
endif()
else()
set(CUDA_FOUND OFF CACHE BOOL "CUDA is disabled")
endif()

###
### Versions and stuff
###
Expand Down
2 changes: 1 addition & 1 deletion buildenv/jenkins/jobs/builds/Build-linux_x86-64
Expand Up @@ -34,7 +34,7 @@ pipeline {

dir('build') {
echo 'Configure...'
sh '''cmake -Wdev -C../cmake/caches/Travis.cmake ..'''
sh '''cmake -Wdev -C../cmake/caches/Travis.cmake -DOMR_OPT_CUDA=ON ..'''

echo 'Compile...'
sh '''make -j4'''
Expand Down
Expand Up @@ -20,7 +20,7 @@ pipeline {

dir('build') {
echo 'Configure...'
sh '''cmake -Wdev -C../cmake/caches/Travis.cmake ..'''
sh '''cmake -Wdev -C../cmake/caches/Travis.cmake -DOMR_OPT_CUDA=ON ..'''

echo 'Compile...'
sh '''make -j4'''
Expand Down
2 changes: 1 addition & 1 deletion cmake/config.cmake
Expand Up @@ -201,6 +201,6 @@ set(OMR_NOTIFY_POLICY_CONTROL OFF CACHE BOOL "TODO: Document")

set(OMR_ENV_GCC OFF CACHE BOOL "TODO: Document")

set(OMR_OPT_CUDA ${CUDA_FOUND} CACHE BOOL "Enable CUDA support in OMR")
set(OMR_OPT_CUDA OFF CACHE BOOL "Enable CUDA support in OMR")

set(OMR_SANITIZE OFF CACHE STRING "Sanitizer selection. Only has an effect on GNU or Clang")
72 changes: 72 additions & 0 deletions cmake/modules/FindOmrCuda.cmake
@@ -0,0 +1,72 @@
###############################################################################
# Copyright (c) 2019, 2019 IBM Corp. and others
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at http://eclipse.org/legal/epl-2.0
# or the Apache License, Version 2.0 which accompanies this distribution
# and is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following Secondary
# Licenses when the conditions for such availability set forth in the
# Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
# version 2 with the GNU Classpath Exception [1] and GNU General Public
# License, version 2 with the OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] http://openjdk.java.net/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
#############################################################################

#
# This package locates a minimum set of cuda resources, required by the OMR_OPT_CUDA flag.
#

include(FindPackageHandleStandardArgs)

set(OMR_CUDA_HOME "NOTFOUND" CACHE STRING "Path to the CUDA SDK. Takes precedence over CUDA_HOME in OMR.")

set(OmrCuda_INCLUDE_DIRS "OmrCuda_INCLUDE_DIRS-NOTFOUND")

set(OmrCuda_SEARCH_PATH
"${OMR_CUDA_HOME}"
"$ENV{CUDA_HOME}"
"$ENV{CUDA_PATH}"
"$ENV{CUDA_INC_PATH}"
"$ENV{NVSDKCOMPUTE_ROOT}/C"
"$ENV{NVSDKCUDA_ROOT}"
"/opt/cuda"
"/Developer/CUDA"
)

find_path(OmrCuda_CUDA_H_DIR
NAMES cuda.h
PATHS
${OmrCuda_SEARCH_PATH}
PATH_SUFFIXES
include
DOC "The cuda.h include directory"
)

find_path(OmrCuda_CUDA_RUNTIME_H_DIR
NAMES cuda_runime.h
PATHS
${OmrCuda_SEARCH_PATH}
PATH_SUFFIXES
include
DOC "The cuda_runtime.h include directory"
)

find_package_handle_standard_args(OmrCuda
DEFAULT_MSG
OmrCuda_CUDA_H_DIR
OmrCuda_CUDA_RUNTIME_H_DIR
)

if(OmrCuda_FOUND)
set(OmrCuda_INCLUDE_DIRS
"${OmrCuda_CUDA_H_DIR}"
"${OmrCuda_CUDA_RUNTIME_H_DIR}"
)
endif()
10 changes: 7 additions & 3 deletions port/CMakeLists.txt
Expand Up @@ -22,7 +22,11 @@

include(OmrFindFiles)

if (OMR_HOST_OS STREQUAL "zos")
if(OMR_OPT_CUDA)
find_package(OmrCuda REQUIRED)
endif()

if(OMR_HOST_OS STREQUAL "zos")
include(OmrMetalC)
endif()

Expand All @@ -44,10 +48,10 @@ target_include_directories(omrport_obj
$<TARGET_PROPERTY:omr_base,INTERFACE_INCLUDE_DIRECTORIES>
)

if (OMR_OPT_CUDA)
if(OMR_OPT_CUDA)
target_include_directories(omrport_obj
PRIVATE
${CUDA_INCLUDE_DIRS}
${OmrCuda_INCLUDE_DIRS}
)
endif()

Expand Down

0 comments on commit 31f4f6c

Please sign in to comment.