[Openmp-commits] [openmp] 38af5b4 - [libomptarget][nfc] Refactor dlwrap.h for easier reuse in D115966 and upcoming patches
Jon Chesterfield via Openmp-commits
openmp-commits at lists.llvm.org
Fri Dec 17 14:28:39 PST 2021
Author: Jon Chesterfield
Date: 2021-12-17T22:28:31Z
New Revision: 38af5b4fd12117186ed9314c6997db169363f8c3
URL: https://github.com/llvm/llvm-project/commit/38af5b4fd12117186ed9314c6997db169363f8c3
DIFF: https://github.com/llvm/llvm-project/commit/38af5b4fd12117186ed9314c6997db169363f8c3.diff
LOG: [libomptarget][nfc] Refactor dlwrap.h for easier reuse in D115966 and upcoming patches
Added:
Modified:
openmp/libomptarget/include/dlwrap.h
openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp
Removed:
################################################################################
diff --git a/openmp/libomptarget/include/dlwrap.h b/openmp/libomptarget/include/dlwrap.h
index 4c9b9352d633d..cff747f1524bd 100644
--- a/openmp/libomptarget/include/dlwrap.h
+++ b/openmp/libomptarget/include/dlwrap.h
@@ -71,14 +71,18 @@
// DLWRAP_INTERNAL is similar, except the function it expands to is:
// static int dlwrap_foo(char x0, double x1) { ... }
// so that the function pointer call can be wrapped in library-specific code
+//
+// DLWRAP_INITIALIZE() declares static functions:
+#define DLWRAP_INITIALIZE() \
+ namespace dlwrap { \
+ static size_t size(); \
+ static const char *symbol(size_t); /* get symbol name in [0, size()) */ \
+ static void ** \
+ pointer(size_t); /* get pointer to function pointer in [0, size()) */ \
+ }
-// DLWRAP_FINALIZE() expands to definitions of:
+// DLWRAP_FINALIZE() implements the functions from DLWRAP_INITIALIZE
#define DLWRAP_FINALIZE() DLWRAP_FINALIZE_IMPL()
-namespace dlwrap {
-static size_t size();
-static const char *symbol(size_t); // get symbol name in [0, size())
-static void **pointer(size_t); // get pointer to function pointer in [0, size())
-} // namespace dlwrap
// Implementation details follow.
diff --git a/openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp b/openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
index cb3931eeba80e..ea1498c6b9c59 100644
--- a/openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/dynamic_hsa/hsa.cpp
@@ -17,6 +17,8 @@
#include <dlfcn.h>
+DLWRAP_INITIALIZE();
+
DLWRAP_INTERNAL(hsa_init, 0);
DLWRAP(hsa_status_string, 2);
diff --git a/openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp b/openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp
index 9e9cea0beb4f4..25388cf32d678 100644
--- a/openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp
+++ b/openmp/libomptarget/plugins/cuda/dynamic_cuda/cuda.cpp
@@ -20,6 +20,8 @@
#include <dlfcn.h>
+DLWRAP_INITIALIZE();
+
DLWRAP_INTERNAL(cuInit, 1);
DLWRAP(cuCtxGetDevice, 1);
More information about the Openmp-commits
mailing list