[Bf-committers] Building CUDA in blenkernel

John Peter Yamauchi jpyamauchi at gmail.com
Sun May 3 19:16:54 CEST 2015


Hi,

I'm trying to build a CUDA file in the blenkernel directory.  So far when I
execute "make" it will print "No rule to make target
'blender-git/blender/source/blender/blenkernel/seqeffects.cu', needed by
'source/blender/blenkernel/kernel_sm_20.cubin'. Stop."

I copied the cmake code from blender/intern/cycles/kernel/CMakeFiles.txt,
stuck it at the end of the
blender/source/blender/blenkernel/CMakeFiles.txt, and made some adjustments:


find_package(CUDA)

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

# warn for other versions
if(CUDA_VERSION MATCHES "65")
else()
    message(WARNING
        "CUDA version ${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR} detected,
"
        "build may succeed but only CUDA 6.5 is officially supported")
endif()

# build for each arch
set(cuda_sources seqeffects.cu ${SRC_HEADERS})
set(cuda_cubins)


set(cuda_extra_flags "")
set(cuda_cubin kernel_${arch}.cubin)

set(cuda_debug_flags "")

set(cuda_version_flags "-D__KERNEL_CUDA_VERSION__=${CUDA_VERSION}")
set(cuda_math_flags "--use_fast_math")

add_custom_command(
    OUTPUT ${cuda_cubin}
    COMMAND ${CUDA_NVCC_EXECUTABLE}
        -arch=${arch}
        -m${CUDA_BITS}
        --cubin ${CMAKE_CURRENT_SOURCE_DIR}/seqeffects.cu
        -o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin}
        --ptxas-options="-v"
        ${cuda_arch_flags}
        ${cuda_version_flags}
        ${cuda_math_flags}
        ${cuda_extra_flags}
        ${cuda_debug_flags}
        -I${CMAKE_CURRENT_SOURCE_DIR}/../util
            -I${CMAKE_CURRENT_SOURCE_DIR}/svm
            -DCCL_NAMESPACE_BEGIN=
            -DCCL_NAMESPACE_END=
            -DNVCC

    DEPENDS ${cuda_sources})

list(APPEND cuda_cubins ${cuda_cubin})

add_custom_target(vse_acceleration ALL DEPENDS ${cuda_cubins})


## Warnings as errors, this is too strict!
#if(MSVC)
#    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
#endif()

blender_add_lib(bf_blenkernel "${SRC}" "${INC}" "${INC_SYS}")

add_dependencies(bf_blenkernel vse_acceleration)


What am I doing wrong?



Thanks!

jpyams


More information about the Bf-committers mailing list