[Openmp-commits] [openmp] [OpenMP] Add a test for D158802 (PR #70678)

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Mon Oct 30 09:06:46 PDT 2023


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/70678

In D158802 we honored user's `thread_limit` value even with the optimization
introduced in D152014. This patch adds a simple test.


>From 21a129f0f7e94ea4da2a5ed91860876f2c5e4265 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Mon, 30 Oct 2023 12:04:46 -0400
Subject: [PATCH] [OpenMP] Add a test for D158802

In D158802 we honored user's `thread_limit` value even with the optimization
introduced in D152014. This patch adds a simple test.
---
 .../small_trip_count_thread_limit.cpp         | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp

diff --git a/openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp b/openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
new file mode 100644
index 000000000000000..3aec477e1864aa0
--- /dev/null
+++ b/openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
@@ -0,0 +1,26 @@
+// clang-format off
+// RUN: %libomptarget-compilexx-generic
+// RUN: env LIBOMPTARGET_INFO=16 \
+// RUN:   %libomptarget-run-generic 2>&1 | %fcheck-generic
+
+int main(int argc, char *argv[]) {
+  constexpr const int block_size = 256;
+  constexpr const int grid_size = 4;
+  constexpr const int count = block_size * grid_size;
+
+  int *data = new int[count];
+
+#pragma omp target teams distribute parallel for thread_limit(block_size) map(from: data[0:count])
+  for (int i = 0; i < count; ++i)
+    data[i] = i;
+
+  for (int i = 0; i < count; ++i)
+    if (data[i] != i)
+      return 1;
+
+  delete[] data;
+
+  return 0;
+}
+
+// CHECK: Launching kernel {{.*}} with 4 blocks and 256 threads in SPMD mode



More information about the Openmp-commits mailing list