[Openmp-commits] [openmp] 0d5b7dd - [OpenMP] Add a test for D158802 (#70678)
via Openmp-commits
openmp-commits at lists.llvm.org
Mon Oct 30 12:59:09 PDT 2023
Author: Shilei Tian
Date: 2023-10-30T15:59:05-04:00
New Revision: 0d5b7dd25cc47123d6920207c089c8a9b98571b4
URL: https://github.com/llvm/llvm-project/commit/0d5b7dd25cc47123d6920207c089c8a9b98571b4
DIFF: https://github.com/llvm/llvm-project/commit/0d5b7dd25cc47123d6920207c089c8a9b98571b4.diff
LOG: [OpenMP] Add a test for D158802 (#70678)
In D158802 we honored user's `thread_limit` value even with the
optimization
introduced in D152014. This patch adds a simple test.
Added:
openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
Modified:
Removed:
################################################################################
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..9796c2dc11663bc
--- /dev/null
+++ b/openmp/libomptarget/test/offloading/small_trip_count_thread_limit.cpp
@@ -0,0 +1,31 @@
+// clang-format off
+// RUN: %libomptarget-compilexx-generic
+// RUN: env LIBOMPTARGET_INFO=16 \
+// RUN: %libomptarget-run-generic 2>&1 | %fcheck-generic
+
+// UNSUPPORTED: aarch64-unknown-linux-gnu
+// UNSUPPORTED: aarch64-unknown-linux-gnu-LTO
+// UNSUPPORTED: x86_64-pc-linux-gnu
+// UNSUPPORTED: x86_64-pc-linux-gnu-LTO
+
+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