From 96c74ba5fd80be258f233d8173bd6b82a7d321fa Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 20 Aug 2014 08:05:49 -0400
Subject: [PATCH] P4 to Git Change 1068366 by emankov@em-hsa-amd on 2014/08/20
07:59:20
ECR #333753 - Compiler Lib & RT: Fix for Compiler's build log printing on RT.
+ RT now asks correctly Compiler's build log by aclGetCompilerLog().
+ BuildLog is added for HSAILKernel by moving it from NullKernel class to Kernel class.
+ Compiler's Lib appendLogToCL() is fixed.
+ Usage of API's aclExtractSection/aclExtractSymbol/aclInsertSection/aclInsertSymbol in Compiler Lib itself replaced by it's inner realizations extSec/extSym/insSec/insSym due to unneded build log clearing in first case.
+ Phase info is added to build log even if CallBack function is not presented for aclCompiler.
How to verify:
set AMD_OCL_BUILD_OPTIONS_APPEND="-print-compile-phases -buildlog=stdout"
test_integer_ops integer_ctz
test_integer_ops integer_ctz cpu
Testing: make smoke_clang, selective OCL conf. tests, pre check-in
Reviewer: Brian Sumner, German Andryeyev
Review board: http://ocltc.amd.com/reviews/r/5582/
Affected files ...
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#46 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/brig_loader.cpp#13 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/gpu/hsail_be.cpp#31 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/utils/v0_8/libUtils.cpp#4 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#228 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.cpp#262 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpukernel.hpp#100 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#174 edit
---
rocclr/compiler/lib/utils/v0_8/libUtils.cpp | 15 +++++++++------
rocclr/runtime/device/device.hpp | 5 ++++-
rocclr/runtime/device/gpu/gpukernel.cpp | 1 +
rocclr/runtime/device/gpu/gpukernel.hpp | 4 ----
rocclr/runtime/device/gpu/gpuprogram.cpp | 2 ++
5 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
index 1f89e38013..136ab1b329 100644
--- a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
+++ b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp
@@ -459,20 +459,23 @@ appendLogToCL(aclCompiler *cl, const std::string &logStr)
if (logStr.empty()) {
return;
}
- unsigned size = logStr.size() + cl->logSize;
+ std::string log = logStr;
+ if ('\n' != log[log.size()-1]) {
+ log.append("\n");
+ }
+ unsigned size = cl->logSize + log.size();
if (!size) {
return;
}
char *tmpBuildLog = reinterpret_cast(aclutAlloc(cl)(size + 2));
memset(tmpBuildLog, 0, size + 2);
if (cl->logSize) {
- std::copy(cl->buildLog,cl->buildLog + cl->logSize, tmpBuildLog);
- std::copy(logStr.begin(), logStr.end(), tmpBuildLog + cl->logSize + 1);
- tmpBuildLog[cl->logSize] = '\n';
+ std::copy(cl->buildLog, cl->buildLog + cl->logSize, tmpBuildLog);
+ std::copy(log.begin(), log.end(), tmpBuildLog + cl->logSize);
} else {
- std::copy(logStr.begin(), logStr.end(), tmpBuildLog);
+ std::copy(log.begin(), log.end(), tmpBuildLog);
}
- cl->logSize += (unsigned int)logStr.size();
+ cl->logSize += (unsigned int)log.size();
if (cl->buildLog) {
aclutFree(cl)(cl->buildLog);
}
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index 8d3ed27d1f..66930f93f6 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -918,12 +918,15 @@ public:
workGroupInfo_.preferredSizeMultiple_ = size;
}
+ //! Return the build log
+ const std::string& buildLog() const { return buildLog_; }
+
protected:
std::string name_; //!< kernel name
WorkGroupInfo workGroupInfo_; //!< device kernel info structure
amd::KernelSignature* signature_; //!< kernel signature
bool hsa_; //!< True if HSA kernel on GPU
-
+ std::string buildLog_; //!< build log
private:
//! Disable default copy constructor
Kernel(const Kernel&);
diff --git a/rocclr/runtime/device/gpu/gpukernel.cpp b/rocclr/runtime/device/gpu/gpukernel.cpp
index cdf91b789a..39661c7bf5 100644
--- a/rocclr/runtime/device/gpu/gpukernel.cpp
+++ b/rocclr/runtime/device/gpu/gpukernel.cpp
@@ -3524,6 +3524,7 @@ HSAILKernel::init()
void* shader_isa = NULL;
error = aclCompile(dev().hsaCompiler(), prog().binaryElf(),
options.c_str(), ACL_TYPE_CG, ACL_TYPE_ISA, NULL);
+ buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
if (error != ACL_SUCCESS) {
LogError("Failed to finalize");
return false;
diff --git a/rocclr/runtime/device/gpu/gpukernel.hpp b/rocclr/runtime/device/gpu/gpukernel.hpp
index 10b3ec0e10..b2558bc3c7 100644
--- a/rocclr/runtime/device/gpu/gpukernel.hpp
+++ b/rocclr/runtime/device/gpu/gpukernel.hpp
@@ -424,9 +424,6 @@ public:
//! Returns GPU device object, associated with this kernel
const NullProgram& nullProg() const { return prog_; }
- //! Returns the kernel's build log
- const std::string& buildLog() const { return buildLog_; }
-
//! Returns the kernel's build error
const cl_int buildError() const { return buildError_; }
@@ -477,7 +474,6 @@ protected:
//! Returns UAV arena index for this kernel
uint uavArena() const { return uavArena_; }
- std::string buildLog_; //!< Kernel's build log
cl_int buildError_; //!< Kernel's build error
std::string ilSource_; //!< IL source code of this kernel
diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp
index 26ea61b683..896e307d8c 100644
--- a/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -2049,6 +2049,7 @@ HSAILProgram::linkImpl(amd::option::Options* options)
std::string curOptions = options->origOptionStr + hsailOptions();
errorCode = aclCompile(dev().hsaCompiler(), binaryElf_,
curOptions.c_str(), continueCompileFrom, ACL_TYPE_CG, NULL);
+ buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
break;
}
}
@@ -2108,6 +2109,7 @@ HSAILProgram::linkImpl(amd::option::Options* options)
if (!aKernel->init() ) {
return false;
}
+ buildLog_ += aKernel->buildLog();
aKernel->setUniformWorkGroupSize(options
->oVariables->UniformWorkGroupSize);
kernels()[kernelName] = aKernel;