[Openmp-commits] [PATCH] D140077: [OpenMP] Add missing test for pinned memory API

Carlo Bertolli via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Dec 15 19:30:37 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGac52c8f58979: [OpenMP] Add missing test for pinned memory API (authored by carlo.bertolli).
Herald added a project: OpenMP.
Herald added a subscriber: openmp-commits.

Changed prior to commit:
  https://reviews.llvm.org/D140077?vs=483071&id=483415#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140077

Files:
  openmp/runtime/test/api/omp_pinned.c


Index: openmp/runtime/test/api/omp_pinned.c
===================================================================
--- /dev/null
+++ openmp/runtime/test/api/omp_pinned.c
@@ -0,0 +1,29 @@
+// RUN: %libomp-compile-and-run
+// RUN: env OMP_ALLOCATOR=omp_default_mem_space:pinned=true %libomp-run
+
+#include <omp.h>
+
+int main() {
+  omp_alloctrait_t pinned_trait[1] = {{omp_atk_pinned, omp_atv_true}};
+  omp_allocator_handle_t pinned_alloc =
+      omp_init_allocator(omp_default_mem_space, 1, pinned_trait);
+  omp_allocator_handle_t default_alloc = omp_get_default_allocator();
+  double *a = (double *)omp_alloc(10 * sizeof(double), pinned_alloc);
+  double *b = (double *)omp_alloc(10 * sizeof(double), default_alloc);
+
+  if (!a || !b) return 1;
+
+#pragma omp parallel for
+  for (int i = 0; i < 10; i++) {
+    a[i] = 0;
+    b[i] = 1;
+  }
+
+  for (int i = 0; i < 10; i++)
+    if (a[i] != 0 || b[i] != 1) return 1;
+
+  omp_free(a, pinned_alloc);
+  omp_free(b, default_alloc);
+
+  return 0;
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140077.483415.patch
Type: text/x-patch
Size: 1004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20221216/cf37baa0/attachment.bin>


More information about the Openmp-commits mailing list