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 Jan 22, 2020
1 parent c1ba8e2 commit f129bc9
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 24 deletions.
19 changes: 1 addition & 18 deletions CMakeLists.txt
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, 2018 IBM Corp. and others
# Copyright (c) 2017, 2020 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
Expand Down 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 -DOMR_CUDA_HOME=/usr/local/cuda ..'''

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 -DOMR_CUDA_HOME=/usr/local/cuda ..'''

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")
66 changes: 66 additions & 0 deletions cmake/modules/FindOmrCuda.cmake
@@ -0,0 +1,66 @@
###############################################################################
# Copyright (c) 2019, 2020 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 module locates a minimal set of cuda headers, required by the OMR_OPT_CUDA flag.
# This module will search for CUDA resources in only one directory. The variables tested, in order of preference, are:
#
# 1. The cmake variable OMR_CUDA_HOME, if set.
# 2. The cmake variable CUDA_HOME, if set.
# 3. The environment variable CUDA_HOME, if set.
#

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")

# Establish which directory we are searching in

set(OmrCuda_SEARCH_DIR "")

if(OMR_CUDA_HOME)
set(OmrCuda_SEARCH_DIR "${OMR_CUDA_HOME}")
elseif(CUDA_HOME)
set(OmrCuda_SEARCH_DIR "${CUDA_HOME}")
elseif($ENV{CUDA_HOME})
set("$ENV{CUDA_HOME}")
else()
message(WARNING "CUDA support requested, but OMR_CUDA_HOME/CUDA_HOME are not set.")
endif()

# Try to locate the main CUDA include directory by finding cuda.h

find_path(OmrCuda_INCLUDE_DIR
NAMES cuda.h
PATHS ${OmrCuda_SEARCH_DIR}
PATH_SUFFIXES include Headers
DOC "The CUDA include directory"
NO_DEFAULT_PATH
)

find_package_handle_standard_args(OmrCuda
DEFAULT_MSG
OmrCuda_INCLUDE_DIR
)

if(OmrCuda_FOUND)
set(OmrCuda_INCLUDE_DIRS "${OmrCuda_INCLUDE_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 f129bc9

Please sign in to comment.