blt icon indicating copy to clipboard operation
blt copied to clipboard

CUDA compilation flags

Open mclarsen opened this issue 7 years ago • 6 comments

Is there a special way to propagate defines? I am adding a library that depends on cuda, and nvcc is being invoked., but -D PARALLEL is not being passed to nvcc. Am I doing something incorrectly?

blt_add_library( NAME vtkh_par SOURCES ${vtkh_sources} ${vtkh_par_sources} HEADERS ${vtkh_par_headers} ${vtkh_headers} DEPENDS_ON ${vtkh_thirdparty_libs} mpi icet)

blt_add_target_compile_flags(TO vtkh_par FLAGS "-D PARALLEL")

mclarsen avatar Aug 28 '17 15:08 mclarsen

blt_register_library has additional arguments to add flags and defines to a library target.

I am not entirely sure how blt_register_library works when the library is generated with blt_add_library through. @white238, can you please clarify?

kennyweiss avatar Aug 28 '17 16:08 kennyweiss

To be clear, this works correctly without cuda.

mclarsen avatar Aug 28 '17 16:08 mclarsen

the issue is for CMake cuda targets (created via macros in FindCUDA), you can't add any additional flags after the targets are created.

The work around is to add the defines to global flags CMAKE_CXX_FLAGS before blt_add_library and then restore the old flags after

This is actually a compelling case for adding an optional DEFINES arg to blt_add_library

We can't use blt_register_library to solve this b/c these flags are needed to compile the lib. (And in this case the aren't needed by client code)

cyrush avatar Aug 28 '17 17:08 cyrush

Update: setting CMAKE_CXX_FLAGS doesn't work w/ BLT's current cuda support. The only path I found was to add the defs to global CUDA_NVCC_FLAGS (along with keeping old and restoring them after adding the lib)

@mclarsen and I were able to modify CMAKE_CXX_FLAGS before, however we were using cuda_wrap_srcs, not cuda_add_library, which BLT is currently using

cyrush avatar Aug 29 '17 06:08 cyrush

Bit by this again in another project.

mclarsen avatar May 08 '18 16:05 mclarsen

FYI: @mclarsen There is work to pivot to CMake's native cuda support: #154

cyrush avatar May 15 '18 22:05 cyrush