From e9d11c526fa4b974cafe35af0f5a15bf35a7e43b Mon Sep 17 00:00:00 2001 From: foreman Date: Wed, 25 Jan 2017 18:12:20 -0500 Subject: [PATCH] P4 to Git Change 1366205 by kzhuravl@kzhuravl-fiji-cl-on-lc on 2017/01/25 18:04:35 SWDEV-94644 - Make sure we are processing metadata note entry with supported n_type. Update build log and fail for not supported metadata n_type. Use constants defined in AMDGPUPTNote.h This change is needed for https://reviews.llvm.org/D29115 This change is required for CL 1366203 ReviewBoardURL: http://ocltc.amd.com/reviews/r/12223/ Testing: lightning conformance tests locally Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#31 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#54 edit [ROCm/clr commit: 4ad12d089ce0d8abe32eef32440e3642678944f9] --- .../clr/rocclr/runtime/device/pal/palprogram.cpp | 12 +++++++++--- .../clr/rocclr/runtime/device/rocm/rocprogram.cpp | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp index 73b11c2da0..c5b5ac9a1a 100644 --- a/projects/clr/rocclr/runtime/device/pal/palprogram.cpp +++ b/projects/clr/rocclr/runtime/device/pal/palprogram.cpp @@ -20,6 +20,7 @@ #include "hsa_ext_image.h" #include "amd_hsa_loader.hpp" #if defined(WITH_LIGHTNING_COMPILER) +#include "AMDGPUPTNote.h" #include "AMDGPURuntimeMetadata.h" #include "driver/AmdCompiler.h" #include "libraries.amdgcn.inc" @@ -1603,9 +1604,14 @@ LightningProgram::setKernels( address name = (address) ¬e[1]; address desc = name + amd::alignUp(note->n_namesz, sizeof(int)); - if (note->n_type == 7 /*NT_AMDGPU_HSA_RUNTIME_METADATA_1_0*/ - && note->n_namesz == sizeof "AMD" - && !memcmp(name, "AMD", note->n_namesz)) { + if (note->n_type == AMDGPU::PT_NOTE::NT_AMDGPU_HSA_RUNTIME_METADATA_V_1) { + buildLog_ += "Error: object code with metadata v1 is not " \ + "supported\n"; + return false; + } + else if (note->n_type == AMDGPU::PT_NOTE::NT_AMDGPU_HSA_RUNTIME_METADATA + && note->n_namesz == sizeof AMDGPU::PT_NOTE::NoteName + && !memcmp(name, AMDGPU::PT_NOTE::NoteName, note->n_namesz)) { std::string metadataStr((const char *) desc, (size_t) note->n_descsz); metadata_ = new AMDGPU::RuntimeMD::Program::Metadata(metadataStr); // We've found and loaded the runtime metadata, exit the diff --git a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp index 78b9f901ec..9dcbba16c1 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rocprogram.cpp @@ -10,6 +10,7 @@ #include "compiler/lib/utils/options.hpp" #include "rockernel.hpp" #if defined(WITH_LIGHTNING_COMPILER) +#include "AMDGPUPTNote.h" #include "libelf/gelf.h" #include "driver/AmdCompiler.h" #include "libraries.amdgcn.inc" @@ -927,9 +928,14 @@ HSAILProgram::setKernels_LC(amd::option::Options *options, void* binary, size_t address name = (address) ¬e[1]; address desc = name + amd::alignUp(note->n_namesz, sizeof(int)); - if (note->n_type == 7 /*AMDGPU::PT_NOTE::NT_AMDGPU_HSA_RUNTIME_METADATA*/ - && note->n_namesz == sizeof "AMD" - && !memcmp(name, "AMD", note->n_namesz)) { + if (note->n_type == AMDGPU::PT_NOTE::NT_AMDGPU_HSA_RUNTIME_METADATA_V_1) { + buildLog_ += "Error: object code with metadata v1 is not " \ + "supported\n"; + return false; + } + else if (note->n_type == AMDGPU::PT_NOTE::NT_AMDGPU_HSA_RUNTIME_METADATA + && note->n_namesz == sizeof AMDGPU::PT_NOTE::NoteName + && !memcmp(name, AMDGPU::PT_NOTE::NoteName, note->n_namesz)) { std::string metadataStr((const char *) desc, (size_t) note->n_descsz); metadata_ = new AMDGPU::RuntimeMD::Program::Metadata(metadataStr); // We've found and loaded the runtime metadata, exit the