Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Dinges <blender@dingto.org>2013-06-20 00:40:54 +0400
committerThomas Dinges <blender@dingto.org>2013-06-20 00:40:54 +0400
commite6fc17415223d97a5a8c8bca0af443fb3a655699 (patch)
tree8696c810b22464262db029f55e937782cd64cc7b /intern/cycles/kernel/CMakeLists.txt
parentac4058a2117a24901f2462ba34d49e6714532148 (diff)
parent93af050824170913d716e42e918ab58c224ed7f1 (diff)
Merged revision(s) 57499-57586 from trunk/blender into soc-2013-dingto
Diffstat (limited to 'intern/cycles/kernel/CMakeLists.txt')
-rw-r--r--intern/cycles/kernel/CMakeLists.txt54
1 files changed, 45 insertions, 9 deletions
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 1dcf63f9e47..753d32f5182 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -118,32 +118,68 @@ set(SRC_UTIL_HEADERS
# CUDA module
if(WITH_CYCLES_CUDA_BINARIES)
+ # 32 bit or 64 bit
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(CUDA_BITS 64)
else()
set(CUDA_BITS 32)
endif()
+ # CUDA version
+ execute_process (COMMAND ${CUDA_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
+ string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\1" CUDA_VERSION_MAJOR ${NVCC_OUT})
+ string(REGEX REPLACE ".*release ([0-9]+)\\.([0-9]+).*" "\\2" CUDA_VERSION_MINOR ${NVCC_OUT})
+ set(CUDA_VERSION "${CUDA_VERSION_MAJOR}${CUDA_VERSION_MINOR}")
+
+ # build for each arch
set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
set(cuda_cubins)
foreach(arch ${CYCLES_CUDA_BINARIES_ARCH})
set(cuda_cubin kernel_${arch}.cubin)
- if(${arch} MATCHES "sm_1[0-9]")
- # sm_1x
- set(cuda_arch_flags "--maxrregcount=24 --opencc-options -OPT:Olimit=0")
- elseif(${arch} MATCHES "sm_2[0-9]")
- # sm_2x
- set(cuda_arch_flags "--maxrregcount=24")
+ set(cuda_version_flags "-D__KERNEL_CUDA_VERSION__=${CUDA_VERSION}")
+
+ # warn for other versions
+ if(CUDA_VERSION MATCHES "50")
+ else()
+ message(STATUS "CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected, build may succeed but only CUDA 5.0 is officially supported")
+ endif()
+
+ # build flags depending on CUDA version and arch
+ if(CUDA_VERSION LESS 50)
+ # CUDA 4.x
+ if(${arch} MATCHES "sm_1[0-9]")
+ # sm_1x
+ set(cuda_arch_flags "--maxrregcount=24 --opencc-options -OPT:Olimit=0")
+ elseif(${arch} MATCHES "sm_2[0-9]")
+ # sm_2x
+ set(cuda_arch_flags "--maxrregcount=24")
+ else()
+ # sm_3x
+ set(cuda_arch_flags "--maxrregcount=32")
+ endif()
+
+ set(cuda_math_flags "")
else()
- # sm_3x
- set(cuda_arch_flags "--maxrregcount=32")
+ # CUDA 5.x
+ if(${arch} MATCHES "sm_1[0-9]")
+ # sm_1x
+ set(cuda_arch_flags "--maxrregcount=24 --opencc-options -OPT:Olimit=0")
+ elseif(${arch} MATCHES "sm_2[0-9]")
+ # sm_2x
+ set(cuda_arch_flags "--maxrregcount=32")
+ else()
+ # sm_3x
+ set(cuda_arch_flags "--maxrregcount=32")
+ endif()
+
+ set(cuda_math_flags "--use_fast_math")
endif()
add_custom_command(
OUTPUT ${cuda_cubin}
- COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
+ COMMAND ${CUDA_NVCC_EXECUTABLE} -arch=${arch} -m${CUDA_BITS} --cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin} --ptxas-options="-v" ${cuda_arch_flags} ${cuda_version_flags} ${cuda_math_flags} -I${CMAKE_CURRENT_SOURCE_DIR}/../util -I${CMAKE_CURRENT_SOURCE_DIR}/svm -DCCL_NAMESPACE_BEGIN= -DCCL_NAMESPACE_END= -DNVCC
DEPENDS ${cuda_sources})
delayed_install("${CMAKE_CURRENT_BINARY_DIR}" "${cuda_cubin}" ${CYCLES_INSTALL_PATH}/lib)