Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Etienne Schmitt
CGoGN
Commits
d8eb0172
Commit
d8eb0172
authored
Feb 11, 2013
by
Pierre Kraemer
Browse files
add new version of OpenNL (with CHOLMOD support)
parent
601d62f3
Changes
74
Expand all
Hide whitespace changes
Inline
Side-by-side
ThirdParty/OpenNL/CMake/CMakeLists.txt
0 → 100644
View file @
d8eb0172
PROJECT
(
CUDA_DISCOVER_DEVICE_FLAGS
)
if
(
COMMAND cmake_minimum_required
)
cmake_minimum_required
(
VERSION 2.4
)
endif
(
COMMAND cmake_minimum_required
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/../CMakeModules/FindCUDA.cmake
)
SET
(
CMAKE_CXX_FLAGS
${
CMAKE_CXX_FLAGS
}
${
CMAKE_ANSI_CXXFLAGS
}
)
SET
(
CMAKE_C_FLAGS
${
CMAKE_C_FLAGS
}
${
CMAKE_ANSI_CFLAGS
}
)
INCLUDE_DIRECTORIES
(
${
CMAKE_ROOT
}
/include
${
CMAKE_ROOT
}
/Source
)
CUDA_ADD_LIBRARY
(
cmCUDA_DISCOVER_DEVICE_FLAGS MODULE cmCUDA_DISCOVER_DEVICE_FLAGS.cpp
)
ThirdParty/OpenNL/CMake/cmCUDA_DISCOVER_DEVICE_FLAGS.cpp
0 → 100644
View file @
d8eb0172
#include
<fstream>
#include
<sstream>
#include
<string>
#if WIN32
#include
<windows.h>
#else
//#include <iostream>
#include
<dirent.h>
#include
<sys/stat.h>
#endif
/*WIN32*/
#include
"cmCPluginAPI.h"
#include
<cuda.h>
#include
<cuda_runtime_api.h>
class
FlagBuilder
{
public:
void
add_flag
(
const
std
::
string
&
flag
){
oss
<<
"-D"
<<
flag
<<
";"
;
}
template
<
typename
T
>
void
add_def
(
const
std
::
string
&
def
,
const
T
value
){
oss
<<
"-D"
<<
def
<<
"="
<<
value
<<
";"
;
}
std
::
string
str
(){
return
oss
.
str
();
}
private:
std
::
ostringstream
oss
;
};
FlagBuilder
fb
;
// Check if there is a device supporting CUDA
void
GetCUDADeviceFlags
()
{
int
deviceCount
;
bool
archi_13
=
false
;
cudaGetDeviceCount
(
&
deviceCount
);
// This function call returns 0 if there are no CUDA capable devices.
if
(
deviceCount
==
0
)
printf
(
"There is no device supporting CUDA
\n
"
);
int
dev
=
0
;
for
(
dev
=
0
;
dev
<
1
/*deviceCount/*HACK : we want the first one only for now*/
;
++
dev
)
{
printf
(
"
\n
First device is selected by default.
\n\n
"
);
cudaDeviceProp
deviceProp
;
cudaGetDeviceProperties
(
&
deviceProp
,
dev
);
if
(
dev
==
0
)
{
// This function call returns 9999 for both major & minor fields, if no CUDA capable devices are present
if
(
deviceProp
.
major
==
9999
&&
deviceProp
.
minor
==
9999
)
printf
(
"There is no device supporting CUDA.
\n
"
);
else
if
(
deviceCount
==
1
)
printf
(
"There is 1 device supporting CUDA
\n
"
);
else
printf
(
"There are %d devices supporting CUDA
\n
"
,
deviceCount
);
if
((
deviceProp
.
major
*
10
+
deviceProp
.
minor
)
>=
13
)
{
// OK on peut faire du double et rajouter des optimizations
archi_13
=
true
;
}
#if CUDART_VERSION >= 2000
if
(
archi_13
){
fb
.
add_def
(
"MAX_THREADS"
,
deviceProp
.
multiProcessorCount
*
1024
);
}
else
{
fb
.
add_def
(
"MAX_THREADS"
,
deviceProp
.
multiProcessorCount
*
768
);
}
#endif
fb
.
add_def
(
"WARP_SIZE"
,
deviceProp
.
warpSize
);
fb
.
add_flag
(
"USE_CRS_SHARED"
);
fb
.
add_flag
(
"USE_TEXTURE"
);
}
printf
(
"
\n
Device %d:
\"
%s
\"\n
"
,
dev
,
deviceProp
.
name
);
#if CUDART_VERSION >= 2020
int
driverVersion
=
0
,
runtimeVersion
=
0
;
cudaDriverGetVersion
(
&
driverVersion
);
printf
(
" CUDA Driver Version: %d.%d
\n
"
,
driverVersion
/
1000
,
driverVersion
%
100
);
cudaRuntimeGetVersion
(
&
runtimeVersion
);
printf
(
" CUDA Runtime Version: %d.%d
\n
"
,
runtimeVersion
/
1000
,
runtimeVersion
%
100
);
#endif
printf
(
" CUDA Capability Major revision number: %d
\n
"
,
deviceProp
.
major
);
printf
(
" CUDA Capability Minor revision number: %d
\n
"
,
deviceProp
.
minor
);
printf
(
" Total amount of global memory: %u bytes
\n
"
,
deviceProp
.
totalGlobalMem
);
#if CUDART_VERSION >= 2000
printf
(
" Number of multiprocessors: %d
\n
"
,
deviceProp
.
multiProcessorCount
);
printf
(
" Number of cores: %d
\n
"
,
8
*
deviceProp
.
multiProcessorCount
);
#endif
printf
(
" Total amount of constant memory: %u bytes
\n
"
,
deviceProp
.
totalConstMem
);
printf
(
" Total amount of shared memory per block: %u bytes
\n
"
,
deviceProp
.
sharedMemPerBlock
);
printf
(
" Total number of registers available per block: %d
\n
"
,
deviceProp
.
regsPerBlock
);
printf
(
" Warp size: %d
\n
"
,
deviceProp
.
warpSize
);
printf
(
" Warp size: %d
\n
"
,
deviceProp
.
warpSize
);
printf
(
" Maximum number of threads per block: %d
\n
"
,
deviceProp
.
maxThreadsPerBlock
);
printf
(
" Maximum sizes of each dimension of a block: %d x %d x %d
\n
"
,
deviceProp
.
maxThreadsDim
[
0
],
deviceProp
.
maxThreadsDim
[
1
],
deviceProp
.
maxThreadsDim
[
2
]);
printf
(
" Maximum sizes of each dimension of a grid: %d x %d x %d
\n
"
,
deviceProp
.
maxGridSize
[
0
],
deviceProp
.
maxGridSize
[
1
],
deviceProp
.
maxGridSize
[
2
]);
printf
(
" Maximum memory pitch: %u bytes
\n
"
,
deviceProp
.
memPitch
);
printf
(
" Texture alignment: %u bytes
\n
"
,
deviceProp
.
textureAlignment
);
printf
(
" Clock rate: %.2f GHz
\n
"
,
deviceProp
.
clockRate
*
1e-6
f
);
#if CUDART_VERSION >= 2000
printf
(
" Concurrent copy and execution: %s
\n
"
,
deviceProp
.
deviceOverlap
?
"Yes"
:
"No"
);
#endif
#if CUDART_VERSION >= 2020
printf
(
" Run time limit on kernels: %s
\n
"
,
deviceProp
.
kernelExecTimeoutEnabled
?
"Yes"
:
"No"
);
printf
(
" Integrated: %s
\n
"
,
deviceProp
.
integrated
?
"Yes"
:
"No"
);
printf
(
" Support host page-locked memory mapping: %s
\n
"
,
deviceProp
.
canMapHostMemory
?
"Yes"
:
"No"
);
printf
(
" Compute mode: %s
\n
"
,
deviceProp
.
computeMode
==
cudaComputeModeDefault
?
"Default (multiple host threads can use this device simultaneously)"
:
deviceProp
.
computeMode
==
cudaComputeModeExclusive
?
"Exclusive (only one host thread at a time can use this device)"
:
deviceProp
.
computeMode
==
cudaComputeModeProhibited
?
"Prohibited (no host thread can use this device)"
:
"Unknown"
);
#endif
}
}
#ifdef __cplusplus
extern
"C"
{
#endif
static
int
InitialPass
(
void
*
inf
,
void
*
mf
,
int
argc
,
char
*
argv
[])
{
cmLoadedCommandInfo
*
info
=
(
cmLoadedCommandInfo
*
)(
inf
);
const
char
*
pwd
=
info
->
CAPI
->
GetCurrentDirectory
(
mf
);
info
->
CAPI
->
DisplaySatus
(
mf
,
pwd
);
GetCUDADeviceFlags
();
info
->
CAPI
->
DisplaySatus
(
mf
,
fb
.
str
().
c_str
());
info
->
CAPI
->
AddDefinition
(
mf
,
"CUDA_DEVICE_FLAGS"
,
fb
.
str
().
c_str
());
return
1
;
}
void
CM_PLUGIN_EXPORT
CUDA_DISCOVER_DEVICE_FLAGSInit
(
cmLoadedCommandInfo
*
info
)
{
info
->
InitialPass
=
InitialPass
;
info
->
m_Inherited
=
0
;
info
->
Name
=
"CUDA_DISCOVER_DEVICE_FLAGS"
;
}
#ifdef __cplusplus
}
#endif
ThirdParty/OpenNL/CMakeLists.txt
0 → 100644
View file @
d8eb0172
######################################
# CMake version checks
######################################
if
(
COMMAND cmake_minimum_required
)
cmake_minimum_required
(
VERSION 2.4
)
endif
(
COMMAND cmake_minimum_required
)
if
(
COMMAND cmake_policy
)
if
(
POLICY CMP0003
)
cmake_policy
(
SET CMP0003 OLD
)
endif
(
POLICY CMP0003
)
if
(
POLICY CMP0005
)
cmake_policy
(
SET CMP0005 OLD
)
endif
(
POLICY CMP0005
)
if
(
POLICY CMP0011
)
cmake_policy
(
SET CMP0011 OLD
)
# or NEW
endif
(
POLICY CMP0011
)
endif
(
COMMAND cmake_policy
)
######################################
# Project
######################################
PROJECT
(
OpenNL3
)
SET
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
-Wall -fPIC"
)
#SET(GEEX_BUILD_PATH ${PROJECT_BINARY_DIR})
#SET(BINARIES_RELATIVE_PATH /binaries/bin/)
#IF (WIN32)
# SET(LIBRARIES_RELATIVE_PATH /binaries/bin/)
#ELSE(WIN32)
# SET(LIBRARIES_RELATIVE_PATH /binaries/lib/)
#ENDIF(WIN32)
#IF(WIN32)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
#ELSE(WIN32)
# SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}${LIBRARIES_RELATIVE_PATH})
#ENDIF(WIN32)
#SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}${BINARIES_RELATIVE_PATH})
IF
(
EXISTS
${
CMAKE_SOURCE_DIR
}
/OpenNL/CMakeOptions.txt
)
MESSAGE
(
INFO:
"Using local options file: "
${
CMAKE_SOURCE_DIR
}
/OpenNL/CMakeOptions.txt
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/OpenNL/CMakeOptions.txt
)
ENDIF
(
EXISTS
${
CMAKE_SOURCE_DIR
}
/OpenNL/CMakeOptions.txt
)
IF
(
USE_CNC
)
ADD_DEFINITIONS
(
-DNL_USE_CNC
)
IF
(
CUDA_BUILD_EMULATION
)
ADD_DEFINITIONS
(
-D__DEVICE_EMULATION__
)
ENDIF
(
CUDA_BUILD_EMULATION
)
IF
(
WIN32
)
ADD_DEFINITIONS
(
-DOS_WIN
)
ELSE
(
WIN32
)
ADD_DEFINITIONS
(
-DOS_LINUX
)
ENDIF
(
WIN32
)
INCLUDE
(
${
CMAKE_SOURCE_DIR
}
/OpenNL/CMakeModules/FindCUDA.cmake
)
IF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
SET
(
CUDA_COMPILE_TIME_EXTRA_FLAGS -G
)
ENDIF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
IF
(
CNC_OPTIMIZE_FOR_THIS_MACHINE
)
IF
(
COMMAND CUDA_DISCOVER_DEVICE_FLAGS
)
ELSE
(
COMMAND CUDA_DISCOVER_DEVICE_FLAGS
)
TRY_COMPILE
(
COMPILE_OK
${
PROJECT_BINARY_DIR
}
/CMake
${
PROJECT_SOURCE_DIR
}
/CMake CUDA_DISCOVER_DEVICE_FLAGS
)
IF
(
NOT COMPILE_OK
)
IF
(
WIN32
)
MESSAGE
(
"error compiling CUDA_DISCOVER_DEVICE_FLAGS extention"
)
ELSE
(
WIN32
)
MESSAGE
(
FATAL_ERROR
"error compiling CUDA_DISCOVER_DEVICE_FLAGS extention"
)
ENDIF
(
WIN32
)
ENDIF
(
NOT COMPILE_OK
)
LOAD_COMMAND
(
CUDA_DISCOVER_DEVICE_FLAGS
${
PROJECT_BINARY_DIR
}
/CMake
${
PROJECT_BINARY_DIR
}
/CMake/Debug
)
ENDIF
(
COMMAND CUDA_DISCOVER_DEVICE_FLAGS
)
CUDA_DISCOVER_DEVICE_FLAGS
()
SET
(
CUDA_NVCC_FLAGS
${
CUDA_NVCC_FLAGS
}
${
CUDA_DEVICE_FLAGS
}
)
ADD_DEFINITIONS
(
${
CUDA_DEVICE_FLAGS
}
)
ELSE
(
CNC_OPTIMIZE_FOR_THIS_MACHINE
)
SET
(
CUDA_NVCC_FLAGS
${
CNC_NVCC_FLAGS
}
)
ENDIF
(
CNC_OPTIMIZE_FOR_THIS_MACHINE
)
ENDIF
(
USE_CNC
)
IF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
ADD_DEFINITIONS
(
-DNL_DEBUG
)
IF
(
PARANOID_DEBUG
)
ADD_DEFINITIONS
(
-DNL_PARANOID
)
ENDIF
(
PARANOID_DEBUG
)
ENDIF
(
CMAKE_BUILD_TYPE MATCHES Debug
)
#########################################
# ADD HERE ADDITIONAL INCLUDE DIRECTORIES
#########################################
INCLUDE_DIRECTORIES
(
${
CMAKE_SOURCE_DIR
}
)
INCLUDE_DIRECTORIES
(
src
)
#########################################
# ADD HERE SUBDIRECTORIES
#########################################
ADD_SUBDIRECTORY
(
src
)
IF
(
BUILD_EXAMPLES
)
ADD_SUBDIRECTORY
(
examples
)
ENDIF
(
BUILD_EXAMPLES
)
IF
(
WIN32
)
MESSAGE
(
"Configure done. You may need to click on configure again if the OK button is disabled"
)
ENDIF
(
WIN32
)
ThirdParty/OpenNL/CMakeModules/FindCUDA.cmake
0 → 100644
View file @
d8eb0172
This diff is collapsed.
Click to expand it.
ThirdParty/OpenNL/CMakeModules/FindCUDA/make2cmake.cmake
0 → 100644
View file @
d8eb0172
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# Copyright (c) 2007-2009
# Scientific Computing and Imaging Institute, University of Utah
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#######################################################################
# This converts a file written in makefile syntax into one that can be included
# by CMake.
file
(
READ
${
input_file
}
depend_text
)
if
(
${
depend_text
}
MATCHES
".+"
)
# message("FOUND DEPENDS")
# Remember, four backslashes is escaped to one backslash in the string.
string
(
REGEX REPLACE
"
\\\\
"
" "
depend_text
${
depend_text
}
)
# This works for the nvcc -M generated dependency files.
string
(
REGEX REPLACE
"^.* : "
""
depend_text
${
depend_text
}
)
string
(
REGEX REPLACE
"[
\\\\
]*
\n
"
";"
depend_text
${
depend_text
}
)
set
(
dependency_list
""
)
foreach
(
file
${
depend_text
}
)
string
(
REGEX REPLACE
"^ +"
""
file
${
file
}
)
if
(
NOT IS_DIRECTORY
${
file
}
)
# If softlinks start to matter, we should change this to REALPATH. For now we need
# to flatten paths, because nvcc can generate stuff like /bin/../include instead of
# just /include.
get_filename_component
(
file_absolute
"
${
file
}
"
ABSOLUTE
)
list
(
APPEND dependency_list
"
${
file_absolute
}
"
)
endif
(
NOT IS_DIRECTORY
${
file
}
)
endforeach
(
file
)
else
()
# message("FOUND NO DEPENDS")
endif
()
# Remove the duplicate entries and sort them.
list
(
REMOVE_DUPLICATES dependency_list
)
list
(
SORT dependency_list
)
foreach
(
file
${
dependency_list
}
)
set
(
cuda_nvcc_depend
"
${
cuda_nvcc_depend
}
\"
${
file
}
\"\n
"
)
endforeach
()
file
(
WRITE
${
output_file
}
"# Generated by: make2cmake.cmake
\n
SET(CUDA_NVCC_DEPEND
\n
${
cuda_nvcc_depend
}
)
\n\n
"
)
ThirdParty/OpenNL/CMakeModules/FindCUDA/parse_cubin.cmake
0 → 100644
View file @
d8eb0172
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# Copyright (c) 2007-2009
# Scientific Computing and Imaging Institute, University of Utah
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
#
#######################################################################
# Parses a .cubin file produced by nvcc and reports statistics about the file.
file
(
READ
${
input_file
}
file_text
)
if
(
${
file_text
}
MATCHES
".+"
)
# Remember, four backslashes is escaped to one backslash in the string.
string
(
REGEX REPLACE
";"
"
\\\\
;"
file_text
${
file_text
}
)
string
(
REGEX REPLACE
"
\n
code"
";code"
file_text
${
file_text
}
)
list
(
LENGTH file_text len
)
foreach
(
line
${
file_text
}
)
# Only look at "code { }" blocks.
if
(
line MATCHES
"^code"
)
# Break into individual lines.
string
(
REGEX REPLACE
"
\n
"
";"
line
${
line
}
)
foreach
(
entry
${
line
}
)
# Extract kernel names.
if
(
${
entry
}
MATCHES
"[^g]name = ([^ ]+)"
)
string
(
REGEX REPLACE
".* = ([^ ]+)"
"
\\
1"
entry
${
entry
}
)
# Check to see if the kernel name starts with "_"
set
(
skip FALSE
)
# if (${entry} MATCHES "^_")
# Skip the rest of this block.
# message("Skipping ${entry}")
# set(skip TRUE)
# else (${entry} MATCHES "^_")
message
(
"Kernel:
${
entry
}
"
)
# endif (${entry} MATCHES "^_")
endif
(
${
entry
}
MATCHES
"[^g]name = ([^ ]+)"
)
# Skip the rest of the block if necessary
if
(
NOT skip
)
# Registers
if
(
${
entry
}
MATCHES
"reg([ ]+)=([ ]+)([^ ]+)"
)
string
(
REGEX REPLACE
".*([ ]+)=([ ]+)([^ ]+)"
"
\\
3"
entry
${
entry
}
)
message
(
"Registers:
${
entry
}
"
)
endif
()
# Local memory
if
(
${
entry
}
MATCHES
"lmem([ ]+)=([ ]+)([^ ]+)"
)
string
(
REGEX REPLACE
".*([ ]+)=([ ]+)([^ ]+)"
"
\\
3"
entry
${
entry
}
)
message
(
"Local:
${
entry
}
"
)
endif
()
# Shared memory
if
(
${
entry
}
MATCHES
"smem([ ]+)=([ ]+)([^ ]+)"
)
string
(
REGEX REPLACE
".*([ ]+)=([ ]+)([^ ]+)"
"
\\
3"
entry
${
entry
}
)
message
(
"Shared:
${
entry
}
"
)
endif
()
if
(
${
entry
}
MATCHES
"^}"
)
message
(
""
)
endif
()
endif
(
NOT skip
)
endforeach
(
entry
)
endif
(
line MATCHES
"^code"
)
endforeach
(
line
)
else
()
# message("FOUND NO DEPENDS")
endif
()
ThirdParty/OpenNL/CMakeModules/FindCUDA/run_nvcc.cmake
0 → 100644
View file @
d8eb0172
# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
#
# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
#
# This code is licensed under the MIT License. See the FindCUDA.cmake script
# for the text of the license.
# The MIT License
#
# License for the specific language governing rights and limitations under
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
##########################################################################
# This file runs the nvcc commands to produce the desired output file along with
# the dependency file needed by CMake to compute dependencies. In addition the
# file checks the output of each command and if the command fails it deletes the
# output files.
# Input variables
#
# verbose:BOOL=<> OFF: Be as quiet as possible (default)
# ON : Describe each step
#
# build_configuration:STRING=<> Typically one of Debug, MinSizeRel, Release, or
# RelWithDebInfo, but it should match one of the
# entries in CUDA_HOST_FLAGS. This is the build
# configuration used when compiling the code. If
# blank or unspecified Debug is assumed as this is
# what CMake does.
#
# generated_file:STRING=<> File to generate. This argument must be passed in.
#
# generated_cubin_file:STRING=<> File to generate. This argument must be passed
# in if build_cubin is true.
if
(
NOT generated_file
)
message
(
FATAL_ERROR
"You must specify generated_file on the command line"
)
endif
()
# Set these up as variables to make reading the generated file easier
set
(
CMAKE_COMMAND
"@CMAKE_COMMAND@"
)
set
(
source_file
"@source_file@"
)
set
(
NVCC_generated_dependency_file
"@NVCC_generated_dependency_file@"
)
set
(
cmake_dependency_file
"@cmake_dependency_file@"
)
set
(
CUDA_make2cmake
"@CUDA_make2cmake@"
)
set
(
CUDA_parse_cubin
"@CUDA_parse_cubin@"
)
set
(
build_cubin @build_cubin@
)
# We won't actually use these variables for now, but we need to set this, in
# order to force this file to be run again if it changes.
set
(
generated_file_path
"@generated_file_path@"
)
set
(
generated_file_internal
"@generated_file@"
)
set
(
generated_cubin_file_internal
"@generated_cubin_file@"
)
set
(
CUDA_NVCC_EXECUTABLE
"@CUDA_NVCC_EXECUTABLE@"
)
set
(
CUDA_NVCC_FLAGS
"@CUDA_NVCC_FLAGS@;;@CUDA_WRAP_OPTION_NVCC_FLAGS@"
)
@CUDA_NVCC_FLAGS_CONFIG@
set
(
nvcc_flags
"@nvcc_flags@"
)
set
(
CUDA_NVCC_INCLUDE_ARGS
"@CUDA_NVCC_INCLUDE_ARGS@"
)
set
(
format_flag
"@format_flag@"
)
if
(
build_cubin AND NOT generated_cubin_file
)
message
(
FATAL_ERROR
"You must specify generated_cubin_file on the command line"
)
endif
()
# This is the list of host compilation flags. It C or CXX should already have
# been chosen by FindCUDA.cmake.
@CUDA_HOST_FLAGS@
# Take the compiler flags and package them up to be sent to the compiler via -Xcompiler
set
(
nvcc_host_compiler_flags
""
)
# If we weren't given a build_configuration, use Debug.
if
(
NOT build_configuration
)
set
(
build_configuration Debug
)
endif
()
string
(
TOUPPER
"
${
build_configuration
}
"
build_configuration
)
#message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}")
foreach
(
flag
${
CMAKE_HOST_FLAGS
}
${
CMAKE_HOST_FLAGS_
${
build_configuration
}}
)
# Extra quotes are added around each flag to help nvcc parse out flags with spaces.
set
(
nvcc_host_compiler_flags
"
${
nvcc_host_compiler_flags
}
,
\"
${
flag
}
\"
"
)
endforeach
()
if
(
nvcc_host_compiler_flags
)
set
(
nvcc_host_compiler_flags
"-Xcompiler"
${
nvcc_host_compiler_flags
}
)
endif
()
#message("nvcc_host_compiler_flags = \"${nvcc_host_compiler_flags}\"")
# Add the build specific configuration flags
list
(
APPEND CUDA_NVCC_FLAGS
${
CUDA_NVCC_FLAGS_
${
build_configuration
}}
)
if
(
DEFINED CCBIN
)