[llvm] [OpenMP][offload] use per-type checks for multiple_reductions.cpp (PR #201045)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 2 00:35:22 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-offload
Author: Robert Imschweiler (ro-i)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/201045.diff
1 Files Affected:
- (modified) offload/test/offloading/multiple_reductions.cpp (+24-6)
``````````diff
diff --git a/offload/test/offloading/multiple_reductions.cpp b/offload/test/offloading/multiple_reductions.cpp
index 3187076d06f6c..7c28898ca67e8 100644
--- a/offload/test/offloading/multiple_reductions.cpp
+++ b/offload/test/offloading/multiple_reductions.cpp
@@ -5,6 +5,8 @@
#include <cassert>
#include <cstdio>
#include <cstdlib>
+#include <iomanip>
+#include <ios>
#include <iostream>
#include "omp.h"
@@ -33,7 +35,6 @@ template <typename T> void run_type(void) {
#pragma omp target teams distribute parallel for reduction(+ : s1)
for (int i = 0; i < N; ++i)
s1 += in1[i];
- // CHECK: 49995000
std::cout << s1 << '\n';
s1 = T(0);
@@ -42,7 +43,6 @@ template <typename T> void run_type(void) {
#pragma omp target teams distribute parallel for reduction(+ : s1)
for (int i = 0; i < N; i++)
s1 = accumulate(s1, in1[i]);
- // CHECK: 49995000
std::cout << s1 << '\n';
// Dot reduction
@@ -50,7 +50,6 @@ template <typename T> void run_type(void) {
#pragma omp target teams distribute parallel for reduction(+ : s1)
for (int i = 0; i < N; ++i)
s1 += in1[i] * in2[i];
- // CHECK: 2570853208
std::cout << s1 << '\n';
// Combined reduction (sum and max) - in the same loop ...
@@ -61,7 +60,6 @@ template <typename T> void run_type(void) {
s1 += in1[i];
s2 = in1[i] > s2 ? in1[i] : s2;
}
- // CHECK: 49995000 : 9999
std::cout << s1 << " : " << s2 << '\n';
// ... and in separate loops
@@ -77,7 +75,6 @@ template <typename T> void run_type(void) {
for (int i = 0; i < N; i++)
s2 = in1[i] > s2 ? in1[i] : s2;
}
- // CHECK: 49995000 : 9999
std::cout << s1 << " : " << s2 << '\n';
// Reduction in a kernel that is also doing something completely
@@ -100,7 +97,6 @@ template <typename T> void run_type(void) {
s1 += x;
}
}
- // CHECK: 49995000
std::cout << s1 << '\n';
#pragma omp target exit data map(delete : in1[0 : N], in2[0 : N])
@@ -110,8 +106,30 @@ template <typename T> void run_type(void) {
}
int main(int argc, char **argv) {
+ std::cout << std::fixed << std::setprecision(0);
+
+ // CHECK: 49995000
+ // CHECK: 49995000
+ // CHECK: 333283335000
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000
run_type<double>();
+
+ // CHECK: 49995000
+ // CHECK: 49995000
+ // CHECK: 2570853208
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000
run_type<unsigned>();
+
+ // CHECK: 49995000
+ // CHECK: 49995000
+ // CHECK: 333283335000
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000 : 9999
+ // CHECK: 49995000
run_type<unsigned long>();
// Reduction calculating pi
``````````
</details>
https://github.com/llvm/llvm-project/pull/201045
More information about the llvm-commits
mailing list