From 04398ca89051f6cc75c5456e6626e61dc20067ea Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 29 Oct 2014 22:56:55 -0400
Subject: [PATCH] P4 to Git Change 1092096 by yaxunl@yaxunl_stg_win50 on
2014/10/29 22:49:51
EPR #408439 - Add heuristics for setting SC register allocation strategy.
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/amdil_be.cpp#40 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/SI/scCompileSI.cpp#47 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/SI/scCompileSI.h#18 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/SI/scStateSI.cpp#26 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/scwrapper/scState.cpp#33 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/OPTIONS.def#120 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/amdilUtils.cpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/amdilUtils.hpp#2 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/InitializePasses.h#73 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/Transforms/IPO.h#29 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/include/llvm/Transforms/IPO/AMDKernelPerfHint.h#1 add
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Target/AMDIL/AMDILKernelManager.cpp#453 edit
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Transforms/IPO/AMDKernelPerfHint.cpp#1 add
... //depot/stg/opencl/drivers/opencl/compiler/llvm/lib/Transforms/IPO/AMDPassManagerBuilder.cpp#46 edit
[ROCm/clr commit: a5d50f6926e9c181c95942423acbd555eec84358]
---
projects/clr/rocclr/compiler/lib/utils/OPTIONS.def | 10 +++++-----
.../clr/rocclr/compiler/lib/utils/amdilUtils.cpp | 12 ++++++++++++
.../clr/rocclr/compiler/lib/utils/amdilUtils.hpp | 2 ++
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
index eff4cd7625..1fc6b55947 100644
--- a/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
+++ b/projects/clr/rocclr/compiler/lib/utils/OPTIONS.def
@@ -748,16 +748,16 @@ OPTION(OT_BOOL, \
false, 0, 0, NULL, \
"HSA: use buffer instructions instead of flat for global memory")
-// -scras=int or --sc-si-opt-reg-alloc-strategy (default 0)
-// 0 let shader compiler choose reg alloc strategy
+// -scras=int or --sc-si-opt-reg-alloc-strategy (default 4)
+// 4 let OCL compiler choose SC reg alloc strategy by heuristic
// keep this updated with SCShaderSi.h
OPTION(OT_UINT32, \
OA_RUNTIME|OVIS_SUPPORT|OVA_REQUIRED|OA_SEPARATOR_EQUAL, \
"scras", "sc-si-opt-reg-alloc-strategy", \
SCSIOptRegAllocStrategy, \
- 0, 0, 3, NULL, \
- "Set SI+ shader compiler register allocation strategy 0-default, "
- "1-balanced, 2-minimize GPRs, 3-minimize moves (default 0).")
+ 4, 0, 4, NULL, \
+ "Set SI+ shader compiler register allocation strategy 0-SC default, "
+ "1-balanced, 2-minimize GPRs, 3-minimize moves, 4-heuristic(default 4).")
// -fuser-no-inline -fno-user-no-inline
OPTION(OT_BOOL, \
diff --git a/projects/clr/rocclr/compiler/lib/utils/amdilUtils.cpp b/projects/clr/rocclr/compiler/lib/utils/amdilUtils.cpp
index babdd4a5ec..c691bbbb2c 100644
--- a/projects/clr/rocclr/compiler/lib/utils/amdilUtils.cpp
+++ b/projects/clr/rocclr/compiler/lib/utils/amdilUtils.cpp
@@ -12,3 +12,15 @@ void amdilUtils::changePrivateUAVLength(std::string& kernel, unsigned length) {
")_access(private)";
kernel = std::regex_replace(kernel, pattern, ss.str());
}
+
+bool amdilUtils::isKernelMemoryBound(const std::string& kernel) {
+ std::istringstream is(kernel);
+ std::regex pattern("\\s*;\\s*membound\\s*:\\s*1\\s*");
+ while (is) {
+ std::string line;
+ is >> line;
+ if (std::regex_match(line, pattern))
+ return true;
+ }
+ return false;
+}
diff --git a/projects/clr/rocclr/compiler/lib/utils/amdilUtils.hpp b/projects/clr/rocclr/compiler/lib/utils/amdilUtils.hpp
index f28bcc3ee7..9b49fa1bd7 100644
--- a/projects/clr/rocclr/compiler/lib/utils/amdilUtils.hpp
+++ b/projects/clr/rocclr/compiler/lib/utils/amdilUtils.hpp
@@ -7,5 +7,7 @@ namespace amdilUtils {
// Change all private uav length in a kernel
void changePrivateUAVLength(std::string& kernel, unsigned length);
+bool isKernelMemoryBound(const std::string& kernel);
+
}
#endif /* AMDILUTILS_H_ */