Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OpenMP] Limit reduction support for pragma 'distribute' when combine…
…d with pragma 'simd' Differential Revision: https://reviews.llvm.org/D43513 This is a bug fix that removes the emission of reduction support for pragma 'distribute' when found alone or in combinations without simd. Pragma 'distribute' does not have a reduction clause, but when combined with pragma 'simd' we need to emit the support for simd's reduction clause as part of code generation for distribute. This guard is similar to the one used for reduction support earlier in the same code gen function. llvm-svn: 325822
- Loading branch information
Carlo Bertolli
committed
Feb 22, 2018
1 parent
401b2a4
commit beda214
Showing
2 changed files
with
107 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// Test host code gen | ||
|
||
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 | ||
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s | ||
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 | ||
// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 | ||
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s | ||
// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-32 | ||
|
||
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s | ||
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s | ||
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s | ||
// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY1 %s | ||
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s | ||
// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=45 -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY1 %s | ||
// SIMD-ONLY1-NOT: {{__kmpc|__tgt}} | ||
// expected-no-diagnostics | ||
#ifndef HEADER | ||
#define HEADER | ||
|
||
|
||
template <typename T> | ||
T tmain(T &r) { | ||
int n = 1000; | ||
// schedule: dynamic chunk | ||
#pragma omp target map(tofrom:r) | ||
#pragma omp teams | ||
#pragma omp distribute parallel for reduction(+:r) | ||
for (int i = 0; i < n; ++i) | ||
r += (T)i; | ||
|
||
return r; | ||
} | ||
|
||
int main() { | ||
int n = 1000; | ||
int r = 0; | ||
#pragma omp target map(tofrom:r) | ||
#pragma omp teams | ||
#pragma omp distribute parallel for reduction(+:r) | ||
for (int i = 0; i < n; ++i) | ||
r += i; | ||
|
||
return tmain<int>(r); | ||
} | ||
|
||
// CHECK-LABEL: main | ||
// CHECK: call{{.+}} @__tgt_target_teams( | ||
// CHECK: call void [[OFFL:@.+]]( | ||
// CHECK: call{{.+}} [[TMAIN:@.+]](i{{32|64}} | ||
// CHECK: ret | ||
|
||
// CHECK: define{{.+}} [[OFFL]]( | ||
// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEOUTL:@.+]] to{{.+}} | ||
// CHECK: ret void | ||
|
||
// CHECK: define{{.+}} [[TEOUTL]]( | ||
// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[PAROUTL:@.+]] to{{.+}} | ||
// CHECK: ret void | ||
|
||
// CHECK: define{{.+}} [[PAROUTL]]( | ||
// CHECK: call{{.+}} @__kmpc_reduce_nowait( | ||
// CHECK: call{{.+}} @__kmpc_end_reduce_nowait( | ||
// CHECK: ret void | ||
|
||
// CHECK: define{{.+}} [[TMAIN]](i{{32|64}} | ||
// CHECK: call{{.+}} @__tgt_target_teams( | ||
// CHECK: call void [[TOFFL:@.+]]( | ||
// CHECK: ret | ||
|
||
// CHECK: define{{.+}} [[TOFFL]]( | ||
// CHECK: call{{.+}} @__kmpc_fork_teams({{.+}}, {{.+}}, {{.+}} [[TEMPLTEOUTL:@.+]] to{{.+}} | ||
// CHECK: ret void | ||
|
||
// CHECK: define{{.+}} [[TEMPLTEOUTL]]( | ||
// CHECK: call{{.+}} @__kmpc_fork_call({{.+}}, {{.+}}, {{.+}} [[TPAROUTL:@.+]] to{{.+}} | ||
// CHECK: ret void | ||
|
||
// CHECK: define{{.+}} [[TPAROUTL]]( | ||
// CHECK: call{{.+}} @__kmpc_reduce_nowait( | ||
// CHECK: call{{.+}} @__kmpc_end_reduce_nowait( | ||
// CHECK: ret void | ||
|
||
#endif // HEADER |