From 68fd364e193019e522fbdbd806cec2fcade227b9 Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 29 Oct 2015 12:21:02 -0400
Subject: [PATCH] P4 to Git Change 1205457 by emankov@em-hsa-amd on 2015/10/29
12:03:44
SWDEV-77584 - ORCA RT: Preparations for enabling HSAIL on OpenCL 1.2 by default. Call aclLink always even for single library/binary.
[Reason]
If the binary is linked with an option -create-library & actually without any other modules to link, the binary is not changed except the ELF type, which should be ET_DYN according to OpenCL spec. Setting this ELF type did not perform previously, because aclLink was not called in case of single binary.
After switching to HSAIL by default program_binary_type from conformance/compiler test (at least, but may be some others) would fail.
aclLink correctly handles situations with no libs to link, and correctly sets the corresponding ELF type for the "linked" binary.
[Testing] pre check-in
[Reviewer] German Andryeyev
http://ocltc.amd.com/reviews/r/8845/
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#213 edit
---
rocclr/runtime/device/gpu/gpuprogram.cpp | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp
index 3815c79c1c..596c8d6ac1 100644
--- a/rocclr/runtime/device/gpu/gpuprogram.cpp
+++ b/rocclr/runtime/device/gpu/gpuprogram.cpp
@@ -1833,19 +1833,14 @@ HSAILProgram::linkImpl(
binaries_to_link.push_back(bin);
}
- // At this stage each HSAILProgram in the list has an aclBinary initialized
- // and contains LLVMIR
- // We can now go ahead and link them.
- if (binaries_to_link.size() > 1) {
- errorCode = aclLink(dev().hsaCompiler(),
- binaries_to_link[0], binaries_to_link.size() - 1,
- &binaries_to_link[1], ACL_TYPE_LLVMIR_BINARY, "-create-library", NULL);
- if (errorCode != ACL_SUCCESS) {
- buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
- buildLog_ +="Error while linking : \
- aclLink failed" ;
- return false;
- }
+ errorCode = aclLink(dev().hsaCompiler(),
+ binaries_to_link[0], binaries_to_link.size() - 1,
+ binaries_to_link.size() > 1 ? &binaries_to_link[1] : NULL,
+ ACL_TYPE_LLVMIR_BINARY, "-create-library", NULL);
+ if (errorCode != ACL_SUCCESS) {
+ buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
+ buildLog_ +="Error while linking : aclLink failed" ;
+ return false;
}
// Store the newly linked aclBinary for this program.
binaryElf_ = binaries_to_link[0];