blt
blt copied to clipboard
create an example that tests both openmp and cuda
In blt_add_lib
, we can't use
DEPENDS_ON openmp cuda
b/c this will end up passing the openmp flags to nvcc.
But you can do the following:
DEPENDS_ON cuda
if(ENABLE_OPENMP)
if(CUDA_FOUND)
blt_add_target_compile_flags(TO my_target FLAGS "-Xcompiler ${OpenMP_CXX_FLAGS}")
else()
add_target_compile_flags(TO my_target FLAGS "${OpenMP_CXX_FLAGS}")
endif()
endif()
That seems like something that BLT should handle under the covers in the future.
The presence of the openmp
and cuda
dependencies could be detected and take proper action for the corresponding target. Although the provided solution is not that complicated and can be easily hidden in a macro in application code, it would be nice if BLT natively supports this.
@gzagaris yes, I think its pretty easy to do this cleanly in BLT
This works for C++ and there is a new blt_cuda_openmp_smoke test that exercises this capability. Fortran may not work yet though.