[llvm] 73bfb4f - [OpenMPOpt] initial tests for ICV tracking. Only nthreads is used.

via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 16 02:30:12 PDT 2020


Author: sstefan1
Date: 2020-06-16T11:29:42+02:00
New Revision: 73bfb4fd52dc748022172021129956ce0071e679

URL: https://github.com/llvm/llvm-project/commit/73bfb4fd52dc748022172021129956ce0071e679
DIFF: https://github.com/llvm/llvm-project/commit/73bfb4fd52dc748022172021129956ce0071e679.diff

LOG: [OpenMPOpt] initial tests for ICV tracking. Only nthreads is used.

Summary: Couple of tests to showcase what will be done and what to expect with ICV tracking.

Reviewers: jdoerfert, JonChesterfield

Subscribers: yaxunl, guansong, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81114

Added: 
    llvm/test/Transforms/OpenMP/icv_tracking.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/OpenMP/icv_tracking.ll b/llvm/test/Transforms/OpenMP/icv_tracking.ll
new file mode 100644
index 000000000000..e3704338a7a9
--- /dev/null
+++ b/llvm/test/Transforms/OpenMP/icv_tracking.ll
@@ -0,0 +1,117 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature
+; RUN: opt -S -openmpopt < %s | FileCheck %s
+; RUN: opt -S -passes=openmpopt < %s | FileCheck %s
+
+%struct.ident_t = type { i32, i32, i32, i32, i8* }
+
+ at .str = private unnamed_addr constant [23 x i8] c";unknown;unknown;0;0;;\00", align 1
+ at 0 = private unnamed_addr global %struct.ident_t { i32 0, i32 2, i32 0, i32 0, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0) }, align 8
+
+define dso_local i32 @foo(i32 %0, i32 %1) {
+; CHECK-LABEL: define {{[^@]+}}@foo
+; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]])
+; CHECK-NEXT:    tail call void @omp_set_num_threads(i32 [[TMP0]])
+; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @omp_set_num_threads(i32 [[TMP1]])
+; CHECK-NEXT:    [[TMP4:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    [[TMP5:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    [[TMP6:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP4]])
+; CHECK-NEXT:    tail call void @use(i32 [[TMP5]])
+; CHECK-NEXT:    tail call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*))
+; CHECK-NEXT:    [[TMP7:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP7]])
+; CHECK-NEXT:    ret i32 0
+;
+  tail call void @omp_set_num_threads(i32 %0)
+  %3 = tail call i32 @omp_get_max_threads()
+; FIXME: this value should be tracked and the rest of the getters deduplicated and replaced with it.
+  tail call void @omp_set_num_threads(i32 %1)
+  %4 = tail call i32 @omp_get_max_threads()
+  %5 = tail call i32 @omp_get_max_threads()
+  %6 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %4)
+  tail call void @use(i32 %5)
+  tail call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined. to void (i32*, i32*, ...)*))
+  %7 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %7)
+  ret i32 0
+}
+
+declare dso_local void @omp_set_num_threads(i32)
+
+declare dso_local i32 @omp_get_max_threads()
+
+declare dso_local void @use(i32)
+
+define internal void @.omp_outlined.(i32* %0, i32* %1) {
+; CHECK-LABEL: define {{[^@]+}}@.omp_outlined.
+; CHECK-SAME: (i32* [[TMP0:%.*]], i32* [[TMP1:%.*]])
+; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    [[TMP4:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP4]])
+; CHECK-NEXT:    tail call void @omp_set_num_threads(i32 10)
+; CHECK-NEXT:    [[TMP5:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP5]])
+; CHECK-NEXT:    ret void
+;
+; FIXME: this value should be tracked and the rest of the getters deduplicated and replaced with it.
+  %3 = tail call i32 @omp_get_max_threads()
+  %4 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %4)
+; FIXME: this value ( min(%3, 10) ) should be tracked and the rest of the getters deduplicated and replaced with it.
+  tail call void @omp_set_num_threads(i32 10)
+  %5 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %5)
+  ret void
+}
+
+declare !callback !0 void @__kmpc_fork_call(%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...)
+
+define dso_local i32 @bar(i32 %0, i32 %1) {
+; CHECK-LABEL: define {{[^@]+}}@bar
+; CHECK-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]])
+; CHECK-NEXT:    [[TMP3:%.*]] = icmp sgt i32 [[TMP0]], [[TMP1]]
+; CHECK-NEXT:    [[TMP4:%.*]] = select i1 [[TMP3]], i32 [[TMP0]], i32 [[TMP1]]
+; CHECK-NEXT:    tail call void @omp_set_num_threads(i32 [[TMP4]])
+; CHECK-NEXT:    [[TMP5:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined..1 to void (i32*, i32*, ...)*))
+; CHECK-NEXT:    [[TMP6:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP6]])
+; CHECK-NEXT:    ret i32 0
+;
+  %3 = icmp sgt i32 %0, %1
+  %4 = select i1 %3, i32 %0, i32 %1
+; FIXME: getters can be replaced with %4
+  tail call void @omp_set_num_threads(i32 %4)
+  %5 = tail call i32 @omp_get_max_threads()
+  tail call void (%struct.ident_t*, i32, void (i32*, i32*, ...)*, ...) @__kmpc_fork_call(%struct.ident_t* nonnull @0, i32 0, void (i32*, i32*, ...)* bitcast (void (i32*, i32*)* @.omp_outlined..1 to void (i32*, i32*, ...)*))
+  %6 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %6)
+  ret i32 0
+}
+
+define internal void @.omp_outlined..1(i32* %0, i32*  %1) {
+; CHECK-LABEL: define {{[^@]+}}@.omp_outlined..1
+; CHECK-SAME: (i32* [[TMP0:%.*]], i32* [[TMP1:%.*]])
+; CHECK-NEXT:    [[TMP3:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP3]])
+; CHECK-NEXT:    tail call void @omp_set_num_threads(i32 10)
+; CHECK-NEXT:    [[TMP4:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP4]])
+; CHECK-NEXT:    [[TMP5:%.*]] = tail call i32 @omp_get_max_threads()
+; CHECK-NEXT:    tail call void @use(i32 [[TMP5]])
+; CHECK-NEXT:    ret void
+;
+  %3 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %3)
+  tail call void @omp_set_num_threads(i32 10)
+  %4 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %4)
+  %5 = tail call i32 @omp_get_max_threads()
+  tail call void @use(i32 %5)
+  ret void
+}
+
+!0 = !{!1}
+!1 = !{i64 2, i64 -1, i64 -1, i1 true}


        


More information about the llvm-commits mailing list