From 7607667bd3c77625f5710c38ac205222be454cee Mon Sep 17 00:00:00 2001
From: foreman
Date: Mon, 3 Oct 2016 16:57:03 -0400
Subject: [PATCH] P4 to Git Change 1321923 by smekhano@stas-mwamba-rocm-hsa on
2016/10/03 16:45:37
SWDEV-104346 - ROCm/HSA: allow code object and isa dump under -save-temps
Reviewed by Laurent Morichetti
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/build/Makefile.oclrocm#9 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#38 edit
---
rocclr/runtime/device/rocm/rocprogram.cpp | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/rocclr/runtime/device/rocm/rocprogram.cpp b/rocclr/runtime/device/rocm/rocprogram.cpp
index 37f54cb353..f82c5be363 100644
--- a/rocclr/runtime/device/rocm/rocprogram.cpp
+++ b/rocclr/runtime/device/rocm/rocprogram.cpp
@@ -15,6 +15,7 @@
#include "libraries.amdgcn.inc"
#else // !defined(WITH_LIGHTNING_COMPILER)
#include "roccompilerlib.hpp"
+#include "amd_hsa_code.hpp"
#endif // !defined(WITH_LIGHTNING_COMPILER)
#include "utils/bif_section_labels.hpp"
@@ -1429,6 +1430,23 @@ HSAILProgram::linkImpl(amd::option::Options *options)
}
saveBinaryAndSetType(TYPE_EXECUTABLE);
buildLog_ += g_complibApi._aclGetCompilerLog(device().compiler());
+
+ if (options->isDumpFlagSet(amd::option::DUMP_O) || options->isDumpFlagSet(amd::option::DUMP_ISA)) {
+ amd::hsa::code::AmdHsaCode code;
+ if (!code.InitAsHandle(hsaProgramCodeObject_)) {
+ LogWarning("Error: Printing AMD HSA Code Object failed.");
+ } else {
+ if (options->isDumpFlagSet(amd::option::DUMP_O)) {
+ std::string dumpFileName = options->getDumpFileName(".co");
+ code.SaveToFile(dumpFileName);
+ }
+ if (options->isDumpFlagSet(amd::option::DUMP_ISA)) {
+ std::string dumpFileName = options->getDumpFileName(".isa");
+ code.PrintToFile(dumpFileName);
+ }
+ }
+ }
+
#endif // !defined(WITH_LIGHTNING_COMPILER)
return true;
}