[Openmp-commits] [openmp] [Libomptarget] Remove global ctor and use reference counting (PR #80499)

Joseph Huber via Openmp-commits openmp-commits at lists.llvm.org
Tue Feb 6 08:44:15 PST 2024


================
@@ -0,0 +1,24 @@
+// RUN: %libomptarget-compile-run-and-check-generic
+
+#include <omp.h>
+#include <stdio.h>
+
+extern void __tgt_rtl_init(void);
+extern void __tgt_rtl_deinit(void);
+
+// Sanity checks to make sure that this works and is thread safe.
+int main() {
+  __tgt_rtl_init();
+#pragma omp parallel num_threads(8)
+  {
+    __tgt_rtl_init();
+    __tgt_rtl_deinit();
+  }
+  __tgt_rtl_deinit();
+
+  __tgt_rtl_init();
+  __tgt_rtl_deinit();
+
+  // CHECK: PASS
+  printf("PASS\n");
+}
----------------
jhuber6 wrote:

I could add a test that `dlopen`s a bunch of different libraries in parallel or something. Realistically this needs to be a unit test, but we're missing a bit of infrastructure right now. Figured that would come later.

https://github.com/llvm/llvm-project/pull/80499


More information about the Openmp-commits mailing list