================
@@ -0,0 +1,2029 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
UTC_ARGS: --check-globals all --filter-out-after "getelem.*kernel" --filter-out
"= alloca.*" --include-generated-funcs --replace-value-regex
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]"
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _ --global-value-regex
"\.offload_.*" --global-hex-value-regex ".offload_maptypes.*" --version 6
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -std=c++20 -triple
x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++20 -triple
x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=51 -std=c++20 -triple
x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+struct Point { int x, y; };
+struct Point3D { int x, y, z; };
+
+void test_target_explicit_map() {
+ Point p{1, 2};
+ auto [a, b] = p;
+
+#pragma omp target map(tofrom: p)
+ {
+ a = a + 1;
+ b = b + 1;
+ }
+}
+
+void test_target_implicit_map() {
+ Point p{1, 2};
+ auto [a, b] = p;
+
+#pragma omp target
+ {
+ int sum = a + b;
+ }
+}
+
+void test_target_parallel() {
+ Point p{3, 4};
+ auto [a, b] = p;
+
+#pragma omp target parallel
+ {
+ int sum = a + b;
+ }
+}
+
+void test_target_parallel_for() {
+ Point p{5, 6};
+ auto [a, b] = p;
+
+#pragma omp target parallel for
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
+void test_firstprivate_dsa() {
+ Point p{7, 8};
+ auto [a, b] = p;
+
+#pragma omp parallel firstprivate(p)
+ {
+ int sum = a + b;
+ }
+}
+
+void test_shared_dsa() {
+ Point p{9, 10};
+ auto [a, b] = p;
+
+#pragma omp parallel shared(p)
+ {
+ int sum = a + b;
+ }
+}
+
+void test_reduction_dsa() {
+ Point p{1, 2};
+ auto [a, b] = p;
+ int sum = 0;
+
+#pragma omp parallel for reduction(+:sum)
+ for (int i = 0; i < 10; i++) {
+ sum += a + b;
+ }
+}
+
+void test_parallel_for_() {
+ Point p{11, 12};
+ auto [a, b] = p;
+
+#pragma omp parallel for
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
+void test_parallel_for_simd_() {
+ Point p{13, 14};
+ auto [a, b] = p;
+
+#pragma omp parallel for simd
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
+void test_target_teams_distribute() {
+ Point p{15, 16};
+ auto [a, b] = p;
+
+#pragma omp target teams distribute
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
+void test_task() {
+ Point p{17, 18};
+ auto [a, b] = p;
+
+#pragma omp task
+ {
+ int sum = a + b;
+ }
+}
+
+void test_task_depend() {
+ Point p{19, 20};
+ auto [a, b] = p;
+
+#pragma omp task depend(in: a, b)
+ {
+ int sum = a + b;
+ }
+}
+
+void test_taskloop_() {
+ Point p{21, 22};
+ auto [a, b] = p;
+
+#pragma omp taskloop
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
+template<typename T>
+int test_template_bas(T p) {
+ auto [a, b] = p;
+ int result = 0;
+
+#pragma omp parallel reduction(+:result)
+ {
+ result = a + b;
+ }
+ return result;
+}
+
+template<typename T>
+int test_template_target(T p) {
+ auto [a, b] = p;
+ int result = 0;
+
+#pragma omp target map(tofrom: result)
+ {
+ result = a + b;
+ }
+ return result;
+}
+
+template<typename T>
+int test_template_task(T p) {
+ auto [a, b] = p;
+ int result = 0;
+
+#pragma omp task shared(result)
+ {
+ result = a + b;
+ }
+#pragma omp taskwait
+ return result;
+}
+
+template<typename T>
+int test_template_3_bindings(T p) {
+ auto [x, y, z] = p;
+ int result = 0;
+
+#pragma omp parallel reduction(+:result)
+ {
+ result = x + y + z;
+ }
+ return result;
+}
+
+void instantiate_templates() {
+ Point p2{1, 2};
+ Point3D p3{1, 2, 3};
+
+ test_template_bas(p2);
+ test_template_bas(Point{3, 4});
+ test_template_target(p2);
+ test_template_task(p2);
+ test_template_3_bindings(p3);
+}
+
+void test_static_binding() {
+ static Point p{23, 24};
+ static auto [a, b] = p;
+
+#pragma omp parallel
+ {
+ int sum = a + b;
+ }
+}
+
+void test_static_binding_shared() {
+ static Point p{25, 26};
+ static auto [a, b] = p;
+
+#pragma omp parallel shared(p)
+ {
+ a = a + 1;
+ b = b + 1;
+ }
+}
+
+void test_array_target() {
+ int arr[2] = {27, 28};
+ auto [a, b] = arr;
+
+#pragma omp target
+ {
+ int sum = a + b;
+ }
+}
+
+void test_array_task() {
+ int arr[2] = {29, 30};
+ auto [a, b] = arr;
+
+#pragma omp task
+ {
+ int sum = a + b;
+ }
+}
+
+void test_nested() {
+ Point p{31, 32};
+ auto [a, b] = p;
+
+#pragma omp parallel
+ {
+#pragma omp critical
+ {
+ int sum = a + b;
+ }
+
+#pragma omp task
+ {
+ int product = a * b;
+ }
+ }
+}
+
+void test_reference_binding() {
+ Point p{31, 32};
+ auto& [a, b] = p;
+
+#pragma omp parallel
+ {
+ int sum = a + b;
+ }
+}
+
+void test_const_binding() {
+ const Point p{33, 34};
+ const auto [a, b] = p;
+
+#pragma omp parallel
+ {
+ int sum = a + b;
+ }
+}
+
+void test_multiple_bindings() {
+ Point p1{33, 34};
+ Point p2{35, 36};
+ auto [a, b] = p1;
+ auto [c, d] = p2;
+
+#pragma omp parallel
+ {
+ int sum = a + b + c + d;
+ }
+}
+
+void test_multiple_bindings_mixed_dsa() {
+ Point p1{37, 38};
+ Point p2{39, 40};
+ auto [a, b] = p1;
+ auto [c, d] = p2;
+
+#pragma omp parallel firstprivate(p1) shared(p2)
+ {
+ int result = a + b + c + d;
+ }
+}
+
+void test_array_3_elements() {
+ int arr[3] = {35, 36, 37};
+ auto [a, b, c] = arr;
+
+#pragma omp parallel
+ {
+ int sum = a + b + c;
+ }
+}
+
+void test_single() {
+ Point p{38, 39};
+ auto [a, b] = p;
+
+#pragma omp parallel
+#pragma omp single
+ {
+ int sum = a + b;
+ }
+}
+
+void test_sections() {
+ Point p{40, 41};
+ auto [a, b] = p;
+
+#pragma omp parallel sections
+ {
+#pragma omp section
+ { int sum = a + b; }
+#pragma omp section
+ { int diff = a - b; }
+ }
+}
+
+void test_nested_parallel() {
+ Point p{42, 43};
+ auto [a, b] = p;
+
+#pragma omp parallel
+ {
+#pragma omp parallel
+ {
+ int sum = a + b;
+ }
+ }
+}
+
+void test_simd_() {
+ Point p{44, 45};
+ auto [a, b] = p;
+
+#pragma omp simd
+ for (int i = 0; i < 10; i++) {
+ int result = a + b + i;
+ }
+}
+
----------------
alexey-bataev wrote:
Template instantiated test-case?
https://github.com/llvm/llvm-project/pull/190832
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits