[Openmp-commits] [PATCH] D75788: [WIP][OpenMP] Reuse CUDA wrappers in `nvptx` target regions.

Jon Chesterfield via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Mar 6 18:46:31 PST 2020


JonChesterfield added a comment.

That's less invasive than I feared. Nicely done.

It may worth keeping the openmp header wrapper to do architecture dispatch. Something like:

  #ifndef __CLANG_OPENMP_MATH_DECLARES_H__
  #define __CLANG_OPENMP_MATH_DECLARES_H__
  
  #ifndef _OPENMP
  #error "This file is for OpenMP compilation only."
  #endif
  
  #if defined(__AMDGCN__)
  #pragma omp begin declare variant match(device = {arch(amdgcn)})
  #include "equivalent_header.h"
  #pragma omp end declare variant
  #endif // __AMDGCN__
  
  #if defined(__NVPTX__)
  #define __CUDA__
  #pragma omp begin declare variant match(device = {arch(nvptx)})
  
  #if defined(__cplusplus)
  #include <__clang_cuda_math_forward_declares.h>
  #endif
  
  /// Include declarations for libdevice functions.
  #include <__clang_cuda_libdevice_declares.h>
  /// Provide definitions for these functions.
  #include <__clang_cuda_device_functions.h>
  
  #pragma omp end declare variant
  #undef __CUDA__
  #endif // __NVPTX__
  
  
  #endif // __CLANG_OPENMP_MATH_DECLARES_H__



================
Comment at: clang/lib/Headers/cuda_wrappers/new:36
 
+#ifdef _OPENMP
+#define __DEVICE__
----------------
macros look off here - should it be `#define DEVICE`, or the following uses `__DEVICE__`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788





More information about the Openmp-commits mailing list