[llvm] [OpenMP][offload] use per-type checks for multiple_reductions.cpp (PR #201045)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 2 00:34:37 PDT 2026
https://github.com/ro-i created https://github.com/llvm/llvm-project/pull/201045
None
>From 968a23502240aeeed8ed680d2ba5a2f7349955c6 Mon Sep 17 00:00:00 2001
From: Robert Imschweiler <robert.imschweiler at amd.com>
Date: Tue, 2 Jun 2026 02:32:31 -0500
Subject: [PATCH] [OpenMP][offload] use per-type checks for
multiple_reductions.cpp
---
.../test/offloading/multiple_reductions.cpp | 30 +++++++++++++++----
1 file changed, 24 insertions(+), 6 deletions(-)
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
More information about the llvm-commits
mailing list