From 4df676dc363d7fd1c6b7f0e73026c6eb4db9b3a1 Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 15 Dec 2015 13:07:52 -0500 Subject: [PATCH] P4 to Git Change 1221023 by yaxunl@yaxunl_stg_win50 on 2015/12/15 12:50:27 SWDEV-83705 - [SPIRV] Refactor aclUpdateRawFile as a static function called by SPIRVToModule. Affected files ... ... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#39 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/backends/common/v0_8/if_acl.cpp#88 edit ... //depot/stg/opencl/drivers/opencl/compiler/lib/include/v0_8/acl.h#12 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#216 edit --- .../compiler/lib/backends/common/v0_8/if_acl.cpp | 16 ++++++++++++++++ rocclr/compiler/lib/include/v0_8/acl.h | 3 --- rocclr/runtime/device/gpu/gpuprogram.cpp | 3 --- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp index 7cad8119ef..ea525c8289 100644 --- a/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp +++ b/rocclr/compiler/lib/backends/common/v0_8/if_acl.cpp @@ -386,6 +386,18 @@ OCLFEToModule( return module; } +/// Update elf e_rawfile buffer. +static acl_error +updateElfRawFile(aclBinary *bin) +{ + if (bin == NULL + || bin->bin == NULL) { + return ACL_INVALID_ARG; + } + bifbase *elfBin = reinterpret_cast(bin->bin); + return elfBin->updateRawFile() ? ACL_SUCCESS : ACL_ELF_ERROR; +} + aclModule* ACL_API_ENTRY SPIRVToModule( aclLoaderData *ald, @@ -449,7 +461,11 @@ SPIRVToModule( outstream.flush(); auto errCode = cl->clAPI.insSec(cl, bin, &array[0], array.size(), aclLLVMIR); if (error != nullptr) (*error) = errCode; + if (errCode != ACL_SUCCESS) + return reinterpret_cast(llMod); + errCode = updateElfRawFile(bin); + if (error != nullptr) (*error) = errCode; return reinterpret_cast(llMod); #endif // LEGACY_COMPLIB } diff --git a/rocclr/compiler/lib/include/v0_8/acl.h b/rocclr/compiler/lib/include/v0_8/acl.h index b70bd14fb7..ba2669196c 100644 --- a/rocclr/compiler/lib/include/v0_8/acl.h +++ b/rocclr/compiler/lib/include/v0_8/acl.h @@ -98,9 +98,6 @@ acl_error ACL_API_ENTRY aclWriteToMem(aclBinary *bin, void **mem, size_t *size) ACL_API_0_8; -acl_error ACL_API_ENTRY - aclUpdateRawFile(aclBinary *bin); - aclBinary* ACL_API_ENTRY aclCreateFromBinary(const aclBinary *binary, aclBIFVersion version) ACL_API_0_8; diff --git a/rocclr/runtime/device/gpu/gpuprogram.cpp b/rocclr/runtime/device/gpu/gpuprogram.cpp index cc6fcb1178..3b915235b4 100644 --- a/rocclr/runtime/device/gpu/gpuprogram.cpp +++ b/rocclr/runtime/device/gpu/gpuprogram.cpp @@ -1821,9 +1821,6 @@ HSAILProgram::linkImpl( buildLog_ += "Error while linking: Could not load SPIR-V" ; return false; } - // Need to update elf raw file since it will be used by - // aclCreateFromBinary. - aclUpdateRawFile(binaryElf_); } else { buildLog_ +="Error while linking : \ Invalid binary (Missing LLVMIR section)" ;