P4 to Git Change 1349031 by lmoriche@lmoriche_opencl_dev on 2016/12/02 18:33:20
SWDEV-107568 - [ROCm CQE][OCL][CZ] Basic 2.0 conformance test giving Segmentation fault (core dumped) at "progvar_prog_scope_uninit" - Detect if writable program scope variables are present in the program, and if so, insert barrier each dispatch of a kernel from this program. Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rockernel.hpp#11 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#48 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.hpp#16 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocvirtual.cpp#21 edit
Bu işleme şunda yer alıyor:
@@ -128,7 +128,7 @@ public:
|
||||
bool init_LC();
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
|
||||
const HSAILProgram* program() {
|
||||
const HSAILProgram* program() const {
|
||||
return static_cast<const HSAILProgram*>(program_);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,8 @@ HSAILProgram::HSAILProgram(roc::NullDevice& device)
|
||||
hsaProgramHandle_.handle = 0;
|
||||
hsaExecutable_.handle = 0;
|
||||
|
||||
hasGlobalStores_ = false;
|
||||
|
||||
#if defined(WITH_LIGHTNING_COMPILER)
|
||||
metadata_ = NULL;
|
||||
#endif // defined(WITH_LIGHTNING_COMPILER)
|
||||
@@ -886,6 +888,8 @@ HSAILProgram::setKernels_LC(amd::option::Options *options, void* binary, size_t
|
||||
}
|
||||
|
||||
size_t progvarsTotalSize = 0;
|
||||
size_t dynamicSize = 0;
|
||||
size_t progvarsWriteSize = 0;
|
||||
|
||||
// Begin the Elf image from memory
|
||||
Elf* e = elf_memory((char*) binary, binSize, NULL);
|
||||
@@ -936,9 +940,16 @@ HSAILProgram::setKernels_LC(amd::option::Options *options, void* binary, size_t
|
||||
}
|
||||
}
|
||||
// Accumulate the size of R & !X loadable segments
|
||||
else if (pHdr.p_type == PT_LOAD
|
||||
&& (pHdr.p_flags & PF_R) && !(pHdr.p_flags & PF_X)) {
|
||||
progvarsTotalSize += pHdr.p_memsz;
|
||||
else if (pHdr.p_type == PT_LOAD && !(pHdr.p_flags & PF_X)) {
|
||||
if (pHdr.p_flags & PF_R) {
|
||||
progvarsTotalSize += pHdr.p_memsz;
|
||||
}
|
||||
if (pHdr.p_flags & PF_W) {
|
||||
progvarsWriteSize += pHdr.p_memsz;
|
||||
}
|
||||
}
|
||||
else if (pHdr.p_type == PT_DYNAMIC) {
|
||||
dynamicSize += pHdr.p_memsz;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -950,6 +961,10 @@ HSAILProgram::setKernels_LC(amd::option::Options *options, void* binary, size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
if (progvarsWriteSize != dynamicSize) {
|
||||
hasGlobalStores_ = true;
|
||||
}
|
||||
progvarsTotalSize -= dynamicSize;
|
||||
setGlobalVariableTotalSize(progvarsTotalSize);
|
||||
|
||||
saveBinaryAndSetType(TYPE_EXECUTABLE, binary, binSize);
|
||||
@@ -1037,6 +1052,11 @@ HSAILProgram::setKernels_LC(amd::option::Options *options, void* binary, size_t
|
||||
return false;
|
||||
}
|
||||
|
||||
// FIME_lmoriche: the compiler should set the kernarg alignment based
|
||||
// on the alignment requirement of the parameters. For now, bump it to
|
||||
// the worse case: 128byte aligned.
|
||||
kernargSegmentAlignment = std::max(kernargSegmentAlignment, 128u);
|
||||
|
||||
Kernel *aKernel = new roc::Kernel(
|
||||
kernelName,
|
||||
this,
|
||||
|
||||
@@ -58,6 +58,8 @@ public:
|
||||
return dev().getBackendDevice();
|
||||
}
|
||||
|
||||
bool hasGlobalStores() const { return hasGlobalStores_; }
|
||||
|
||||
protected:
|
||||
//! pre-compile setup for GPU
|
||||
virtual bool initBuild(amd::option::Options* options);
|
||||
@@ -160,6 +162,7 @@ private:
|
||||
// aclBinary and aclCompiler - for the compiler library
|
||||
aclBinary* binaryElf_; //!< Binary for the new compiler library
|
||||
aclBinaryOptions binOpts_; //!< Binary options to create aclBinary
|
||||
bool hasGlobalStores_; //!< program has writable program scope variables
|
||||
|
||||
/* HSA executable */
|
||||
hsa_ext_program_t hsaProgramHandle_; //!< Handle to HSA runtime program
|
||||
|
||||
@@ -315,6 +315,14 @@ VirtualGPU::processMemObjects(
|
||||
}
|
||||
}
|
||||
|
||||
if (hsaKernel.program()->hasGlobalStores()) {
|
||||
// Sync AQL packets
|
||||
setAqlHeader(kDispatchPacketHeader);
|
||||
// Clear memory dependency state
|
||||
const static bool All = true;
|
||||
memoryDependency().clear(!All);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Yeni konuda referans
Bir kullanıcı engelle