blt icon indicating copy to clipboard operation
blt copied to clipboard

create an example that tests both openmp and cuda

Open cyrush opened this issue 6 years ago • 3 comments

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()

cyrush avatar Jun 19 '18 00:06 cyrush

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 avatar Jun 27 '18 03:06 gzagaris

@gzagaris yes, I think its pretty easy to do this cleanly in BLT

cyrush avatar Jun 27 '18 04:06 cyrush

This works for C++ and there is a new blt_cuda_openmp_smoke test that exercises this capability. Fortran may not work yet though.

white238 avatar Apr 18 '19 01:04 white238