[Openmp-commits] [PATCH] D111987: [libomptarget][nfc]Generalise DeviceRTL cmake to allow building for amdgpu

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Oct 26 12:43:54 PDT 2021


JonChesterfield added inline comments.


================
Comment at: openmp/libomptarget/DeviceRTL/CMakeLists.txt:145
 
-# Generate a Bitcode library for all the compute capabilities the user requested
-foreach(sm ${nvptx_sm_list})
-  # TODO: replace this with declare variant and isa selector.
-  set(cuda_flags -Xclang -target-cpu -Xclang sm_${sm} "-D__CUDA_ARCH__=${sm}0")
+macro(instantiate_DeviceRTL)
+  # parameters target_cpu, target_name, target_bc_flags
----------------
Meinersbur wrote:
> JonChesterfield wrote:
> > Meinersbur wrote:
> > > Consider
> > > ```
> > > function(instantiate_DeviceRTL target_cpu target_name)
> > >   set(target_bc_flags ${ARGN})
> > > ```
> > > or maybe even `cmake_parse_arguments` of more options might be added in the future.
> > I spent quite a while permuting function and macro trying to get names on parameters and none of it ran correctly, ending up with parameter names in a comment. 
> > 
> > Perhaps cmake thinks a function takes a list and peels off the named arguments, implicit &rest style?
> > 
> > How would one call such a function? 
> > Perhaps cmake thinks a function takes a list and peels off the named arguments, implicit &rest style?
> 
> Yes. Like `*args` in Python. See https://cmake.org/cmake/help/latest/command/function.html#arguments
> 
> > How would one call such a function?
> ```
> instantiate_DeviceRTL(sm_${SM} nvptx -target nvptx64 -Xclang -target-feature -Xclang +ptx61 "-D__CUDA_ARCH__=${sm}0")
> ```
> 
> With cmake_parse_arguments it could be something like
> ```
> instantiate_DeviceRTL(
>   TARGET nvptx
>   ARCH sm_${SM} 
>   TARGET_FLAGS -target nvptx64 -Xclang -target-feature -Xclang +ptx61 -D__CUDA_ARCH__=${sm}0
>   )
> ```
> 
Worked exactly as written in the comment, thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D111987/new/

https://reviews.llvm.org/D111987



More information about the Openmp-commits mailing list