From 077970019bfbf290380bde2f5870993b251d3c0b Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 14 Mar 2019 17:09:48 -0400
Subject: [PATCH] P4 to Git Change 1756596 by slinder1@slinder1-fiji-ocllc on
2019/03/14 15:19:56
SWDEV-79445 - Extend buildlog handling in Comgr path
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#32 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#19 edit
---
rocclr/runtime/device/devprogram.cpp | 56 ++++++++++++++--------------
rocclr/runtime/device/devprogram.hpp | 3 ++
2 files changed, 32 insertions(+), 27 deletions(-)
diff --git a/rocclr/runtime/device/devprogram.cpp b/rocclr/runtime/device/devprogram.cpp
index 7060a0c0c0..51462c7cce 100644
--- a/rocclr/runtime/device/devprogram.cpp
+++ b/rocclr/runtime/device/devprogram.cpp
@@ -190,6 +190,24 @@ std::unique_ptr Program::newCompilerInstance() {
// ================================================================================================
#if defined(USE_COMGR_LIBRARY)
+// If buildLog is not null, and dataSet contains a log object, extract the
+// first log data object from dataSet and process it with
+// extractByteCodeBinary.
+amd_comgr_status_t Program::extractBuildLog(const char* buildLog,
+ amd_comgr_data_set_t dataSet) {
+ amd_comgr_status_t status = AMD_COMGR_STATUS_SUCCESS;
+ if (buildLog != nullptr) {
+ size_t count;
+ status = amd::Comgr::action_data_count(dataSet, AMD_COMGR_DATA_KIND_LOG, &count);
+
+ if (count > 0) {
+ const std::string logName(buildLog);
+ status = extractByteCodeBinary(dataSet, AMD_COMGR_DATA_KIND_LOG, logName);
+ }
+ }
+ return status;
+}
+
// Extract the byte code binary from the data set. The binary will be saved to an output
// file if the file name is provided. If buffer pointer, outBinary, is provided, the
// binary will be passed back to the caller.
@@ -405,6 +423,8 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
dataSetDevLibs);
}
+ status = extractBuildLog(buildLog, dataSetDevLibs);
+
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, dataSetDevLibs, *output);
}
@@ -419,15 +439,7 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
binarySize);
}
- if (buildLog != nullptr) {
- size_t count;
- status = amd::Comgr::action_data_count(*output, AMD_COMGR_DATA_KIND_LOG, &count);
-
- if (count > 0) {
- const std::string logName(buildLog);
- status = extractByteCodeBinary(*output, AMD_COMGR_DATA_KIND_LOG, logName);
- }
- }
+ status = extractBuildLog(buildLog, *output);
if (hasAction) {
amd::Comgr::destroy_action_info(action);
@@ -483,6 +495,8 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs,
action, inputs, dataSetPCH);
}
+ status = extractBuildLog(buildLog, dataSetPCH);
+
// Compiling the source codes with precompiled headers
if (status == AMD_COMGR_STATUS_SUCCESS) {
status = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC,
@@ -498,15 +512,7 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs,
binarySize);
}
- if (buildLog != nullptr) {
- size_t count;
- status = amd::Comgr::action_data_count(output, AMD_COMGR_DATA_KIND_LOG, &count);
-
- if (count > 0) {
- const std::string logName(buildLog);
- status = extractByteCodeBinary(output, AMD_COMGR_DATA_KIND_LOG, logName);
- }
- }
+ status = extractBuildLog(buildLog, output);
if (hasAction) {
amd::Comgr::destroy_action_info(action);
@@ -575,6 +581,8 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
status = extractByteCodeBinary(assemblyData, AMD_COMGR_DATA_KIND_SOURCE, dumpIsaName);
}
+ status = extractBuildLog(buildLog, assemblyData);
+
if (hsaAssemblyData) {
amd::Comgr::destroy_data_set(assemblyData);
}
@@ -592,6 +600,8 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
action, inputs, relocatableData);
}
+ status = extractBuildLog(buildLog, relocatableData);
+
// Create executable from the relocatable data set
amd::Comgr::action_info_set_options(action, "");
if (status == AMD_COMGR_STATUS_SUCCESS) {
@@ -609,15 +619,7 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
executableSize);
}
- if (buildLog != nullptr) {
- size_t count;
- status = amd::Comgr::action_data_count(output, AMD_COMGR_DATA_KIND_LOG, &count);
-
- if (count > 0) {
- const std::string logName(buildLog);
- status = extractByteCodeBinary(output, AMD_COMGR_DATA_KIND_LOG, logName);
- }
- }
+ status = extractBuildLog(buildLog, output);
if (hasAction) {
amd::Comgr::destroy_action_info(action);
diff --git a/rocclr/runtime/device/devprogram.hpp b/rocclr/runtime/device/devprogram.hpp
index 4f4bbf27c9..7730c92774 100644
--- a/rocclr/runtime/device/devprogram.hpp
+++ b/rocclr/runtime/device/devprogram.hpp
@@ -326,6 +326,9 @@ class Program : public amd::HeapObject {
bool linkImplHSAIL(amd::option::Options* options);
#if defined(USE_COMGR_LIBRARY)
+ //! Dump the log data object to the build log, if both are present
+ amd_comgr_status_t extractBuildLog(const char* buildLog,
+ amd_comgr_data_set_t dataSet);
//! Dump the code object data
amd_comgr_status_t extractByteCodeBinary(const amd_comgr_data_set_t inDataSet,
const amd_comgr_data_kind_t dataKind, const std::string& outFileName,