[Openmp-commits] [PATCH] D144893: [OpenMP][WIP] `spir64` device runtime library template

Shilei Tian via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Mar 9 17:45:30 PST 2023


tianshilei1992 added inline comments.


================
Comment at: openmp/libomptarget/DeviceRTL/src/LibC.cpp:37
+/// Intel implementation
+#pragma omp begin declare variant match(device = {arch(spir64)})
+namespace impl {
----------------
spoutn1k wrote:
> tianshilei1992 wrote:
> > I'm thinking potentially we can have a generic implementation of `omp_vprintf` that just returns -1 and having the NVPTX version calls `vprintf`. In this way we don't need to do it for every target.
> How do I go about doing this ? Declare `omp_vprintf` as weak ?
just something like:
```
int32_t omp_vprintf(const char *Format, void *Arguments, uint32_t) {
  return -1;
}
#pragma omp begin declare variant match(device = {arch(nvptx64)})
int32_t omp_vprintf(const char *Format, void *Arguments, uint32_t) {
  return vprintf(...);
}
#pragma omp end declare variant
```
In this way, when the arch is NVPTX64, that variant will replace the default one.


================
Comment at: openmp/libomptarget/DeviceRTL/src/Mapping.cpp:162
+uint32_t getNumHardwareThreadsInBlock() {
+  return __spirv_BuiltInWorkgroupSize(0);
+}
----------------
Do we have these builtins in LLVM right now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144893



More information about the Openmp-commits mailing list