[Openmp-commits] [openmp] [WIP] [OpenMP] Add unit tests for nextgen plugins (PR #74398)

Ethan Luis McDonough via Openmp-commits openmp-commits at lists.llvm.org
Fri Dec 15 00:56:10 PST 2023


================
@@ -0,0 +1,146 @@
+#include "Shared/PluginAPI.h"
+#include "omptarget.h"
+#include "gtest/gtest.h"
+
+const int DEVICE_ID = 0, DEVICE_TWO = 1;
+bool setup_map[DEVICE_TWO + 1];
+
+int init_test_device(int ID) {
+  if (setup_map[ID]) {
+    return OFFLOAD_SUCCESS;
+  }
+  if (__tgt_rtl_init_plugin() == OFFLOAD_FAIL ||
+      __tgt_rtl_init_device(ID) == OFFLOAD_FAIL) {
+    return OFFLOAD_FAIL;
+  }
+  setup_map[ID] = true;
+  return OFFLOAD_SUCCESS;
+}
+
+// Test plugin initialization
+TEST(NextgenPluginsTest, PluginInit) {
----------------
EthanLuisMcDonough wrote:

The global variables serve to keep track of which devices have been initialized. Devices can't be re-initialized, so I think the initialized devices would have to either be tracked through static class members or exist outside the test fixture to persist across tests. I don't *think* there's a way to check if a device has been initialized through the functions defined in PluginAPI.h, but I definitely could be overlooking something.

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


More information about the Openmp-commits mailing list