From 63f4e9165145e9838023aefd799cf4ed5dab88c1 Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 18 Jun 2019 17:37:24 -0400 Subject: [PATCH] P4 to Git Change 1861649 by slinder1@slinder1-fiji-ocllc on 2019/06/18 17:25:38 SWDEV-161424 - Back out changelist 1853517 Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.cpp#48 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/devprogram.hpp#28 edit [ROCm/clr commit: 0d465d1193b471ede7a27acd7b7074d0768b2407] --- .../clr/rocclr/runtime/device/devprogram.cpp | 55 ++++++++++++------- .../clr/rocclr/runtime/device/devprogram.hpp | 4 +- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/devprogram.cpp b/projects/clr/rocclr/runtime/device/devprogram.cpp index bb91aa3892..b4d43d6406 100644 --- a/projects/clr/rocclr/runtime/device/devprogram.cpp +++ b/projects/clr/rocclr/runtime/device/devprogram.cpp @@ -200,17 +200,19 @@ std::unique_ptr Program::newCompilerInstance() { // If buildLog is not null, and dataSet contains a log object, extract the // first log data object from dataSet and process it with // extractByteCodeBinary. -void Program::extractBuildLog(amd_comgr_data_set_t dataSet) { +void Program::extractBuildLog(const char* buildLog, amd_comgr_data_set_t dataSet) { amd_comgr_status_t status = AMD_COMGR_STATUS_SUCCESS; - size_t count; - status = amd::Comgr::action_data_count(dataSet, AMD_COMGR_DATA_KIND_LOG, &count); + if (buildLog != nullptr) { + size_t count; + status = amd::Comgr::action_data_count(dataSet, AMD_COMGR_DATA_KIND_LOG, &count); - if (status == AMD_COMGR_STATUS_SUCCESS && count > 0) { - char* logData = nullptr; - size_t logSize; - status = extractByteCodeBinary(dataSet, AMD_COMGR_DATA_KIND_LOG, "", &logData, &logSize); - buildLog_ += logData; - free(logData); + if (status == AMD_COMGR_STATUS_SUCCESS && count > 0) { + char* logData = nullptr; + size_t logSize; + status = extractByteCodeBinary(dataSet, AMD_COMGR_DATA_KIND_LOG, "", &logData, &logSize); + buildLog_ += logData; + free(logData); + } } if (status != AMD_COMGR_STATUS_SUCCESS) { buildLog_ += "Warning: extracting build log failed.\n"; @@ -375,10 +377,6 @@ amd_comgr_status_t Program::createAction(const amd_comgr_language_t oclver, status = amd::Comgr::action_info_set_option_list(*action, optionsArgv.data(), optionsArgv.size()); } - if (status == AMD_COMGR_STATUS_SUCCESS) { - status = amd::Comgr::action_info_set_logging(*action, true); - } - return status; } @@ -403,6 +401,11 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs, amd_comgr_status_t status = createAction(oclver, targetIdent, options, &action, &hasAction); + const char* buildLog = amdOptions->oVariables->BuildLog; + if (status == AMD_COMGR_STATUS_SUCCESS && buildLog != nullptr) { + status = amd::Comgr::action_info_set_logging(action, true); + } + if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::create_data_set(&dataSetDevLibs); } @@ -411,12 +414,12 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs, hasDataSetDevLibs = true; status = amd::Comgr::do_action(AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES, action, inputs, dataSetDevLibs); - extractBuildLog(dataSetDevLibs); + extractBuildLog(buildLog, dataSetDevLibs); } if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, dataSetDevLibs, *output); - extractBuildLog(*output); + extractBuildLog(buildLog, *output); } if (status == AMD_COMGR_STATUS_SUCCESS) { @@ -462,6 +465,11 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs, amd_comgr_status_t status = createAction(oclver, targetIdent, options, &action, &hasAction); + const char* buildLog = amdOptions->oVariables->BuildLog; + if (status == AMD_COMGR_STATUS_SUCCESS && buildLog != nullptr) { + status = amd::Comgr::action_info_set_logging(action, true); + } + if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::create_data_set(&output); } @@ -489,7 +497,7 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs, hasDataSetPreprocessor = true; status = amd::Comgr::do_action(AMD_COMGR_ACTION_SOURCE_TO_PREPROCESSOR, action, inputs, dataSetPreprocessor); - extractBuildLog(dataSetPreprocessor); + extractBuildLog(buildLog, dataSetPreprocessor); } if (status == AMD_COMGR_STATUS_SUCCESS) { @@ -507,14 +515,14 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t inputs, if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::do_action(AMD_COMGR_ACTION_ADD_PRECOMPILED_HEADERS, action, inputs, dataSetPCH); - extractBuildLog(dataSetPCH); + 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, action, dataSetPCH, output); - extractBuildLog(output); + extractBuildLog(buildLog, output); } if (status == AMD_COMGR_STATUS_SUCCESS) { @@ -563,6 +571,11 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs, amd_comgr_status_t status = createAction(AMD_COMGR_LANGUAGE_NONE, targetIdent, options, &action, &hasAction); + const char* buildLog = amdOptions->oVariables->BuildLog; + if (status == AMD_COMGR_STATUS_SUCCESS && buildLog != nullptr) { + status = amd::Comgr::action_info_set_logging(action, true); + } + if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::create_data_set(&output); } @@ -580,7 +593,7 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs, hasAssemblyData = true; status = amd::Comgr::do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_ASSEMBLY, action, inputs, assemblyData); - extractBuildLog(assemblyData); + extractBuildLog(buildLog, assemblyData); } // dump the ISA @@ -604,7 +617,7 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs, hasRelocatableData = true; status = amd::Comgr::do_action(AMD_COMGR_ACTION_CODEGEN_BC_TO_RELOCATABLE, action, inputs, relocatableData); - extractBuildLog(relocatableData); + extractBuildLog(buildLog, relocatableData); } // Create executable from the relocatable data set @@ -612,7 +625,7 @@ bool Program::compileAndLinkExecutable(const amd_comgr_data_set_t inputs, if (status == AMD_COMGR_STATUS_SUCCESS) { status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE, action, relocatableData, output); - extractBuildLog(output); + extractBuildLog(buildLog, output); } if (status == AMD_COMGR_STATUS_SUCCESS) { diff --git a/projects/clr/rocclr/runtime/device/devprogram.hpp b/projects/clr/rocclr/runtime/device/devprogram.hpp index 68de7babb1..f5479136a7 100644 --- a/projects/clr/rocclr/runtime/device/devprogram.hpp +++ b/projects/clr/rocclr/runtime/device/devprogram.hpp @@ -340,8 +340,8 @@ 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 a log data object is present - void extractBuildLog(amd_comgr_data_set_t dataSet); + //! Dump the log data object to the build log, if both are present + void 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,