P4 to Git Change 1605680 by gandryey@gera-ocl-lc on 2018/09/13 19:07:27
SWDEV-79445 - OCL generic changes and code clean-up - Fix test_basic progvar_prog_scope_uninit with LC. Detect global variables usage in the program and add the code object allocation to the memory dependency tracking Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#70 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#27 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palvirtual.cpp#123 edit
此提交包含在:
@@ -999,7 +999,36 @@ static hsa_status_t GetKernelNamesCallback(hsa_executable_t hExec, hsa_executabl
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
char* name = (char*)alloca(length + 1);
|
||||
char* name = reinterpret_cast<char*>(alloca(length + 1));
|
||||
if (!symbol->GetInfo(HSA_EXECUTABLE_SYMBOL_INFO_NAME, name)) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
name[length] = '\0';
|
||||
|
||||
symbolNameList->push_back(std::string(name));
|
||||
}
|
||||
return HSA_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static hsa_status_t GetGlobalVarNamesCallback(
|
||||
hsa_executable_t hExec, hsa_executable_symbol_t hSymbol,
|
||||
void* data) {
|
||||
auto symbol = Symbol::Object(hSymbol);
|
||||
auto symbolNameList = reinterpret_cast<std::vector<std::string>*>(data);
|
||||
|
||||
hsa_symbol_kind_t type;
|
||||
if (!symbol->GetInfo(HSA_CODE_SYMBOL_INFO_TYPE, &type)) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
if (type == HSA_SYMBOL_KIND_VARIABLE) {
|
||||
// VariableSymbol* vsym = symbol; // Casting to the variable structure
|
||||
uint32_t length;
|
||||
if (!symbol->GetInfo(HSA_EXECUTABLE_SYMBOL_INFO_NAME_LENGTH, &length)) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
|
||||
char* name = reinterpret_cast<char*>(alloca(length + 1));
|
||||
if (!symbol->GetInfo(HSA_EXECUTABLE_SYMBOL_INFO_NAME, name)) {
|
||||
return HSA_STATUS_ERROR;
|
||||
}
|
||||
@@ -1530,7 +1559,7 @@ bool LightningProgram::setKernels(amd::option::Options* options, void* binary, s
|
||||
|
||||
// Get the list of kernels
|
||||
std::vector<std::string> kernelNameList;
|
||||
status = executable_->IterateSymbols(GetKernelNamesCallback, (void*)&kernelNameList);
|
||||
status = executable_->IterateSymbols(GetKernelNamesCallback, &kernelNameList);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog_ += "Error: Failed to get kernel names\n";
|
||||
return false;
|
||||
@@ -1568,6 +1597,15 @@ bool LightningProgram::setKernels(amd::option::Options* options, void* binary, s
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the list of global variables
|
||||
std::vector<std::string> glbVarNames;
|
||||
status = executable_->IterateSymbols(GetGlobalVarNamesCallback, &glbVarNames);
|
||||
if (status != HSA_STATUS_SUCCESS) {
|
||||
buildLog_ += "Error: Failed to get kernel names\n";
|
||||
return false;
|
||||
}
|
||||
globalVars_ = (glbVarNames.size() != 0) ? true : false;
|
||||
|
||||
DestroySegmentCpuAccess();
|
||||
|
||||
// Save the binary and type
|
||||
|
||||
@@ -178,6 +178,9 @@ class HSAILProgram : public device::Program {
|
||||
return loader_->FindHostAddress(devAddr);
|
||||
}
|
||||
|
||||
//! Global variables are a part of the code segment
|
||||
bool GlobalVariables() const { return globalVars_; }
|
||||
|
||||
protected:
|
||||
//! pre-compile setup for GPU
|
||||
virtual bool initBuild(amd::option::Options* options);
|
||||
@@ -252,8 +255,9 @@ class HSAILProgram : public device::Program {
|
||||
std::list<Sampler*> staticSamplers_; //!< List od internal static samplers
|
||||
union {
|
||||
struct {
|
||||
uint32_t isNull_ : 1; //!< Null program no memory allocations
|
||||
uint32_t internal_ : 1; //!< Internal blit program
|
||||
uint32_t isNull_ : 1; //!< Null program no memory allocations
|
||||
uint32_t internal_ : 1; //!< Internal blit program
|
||||
uint32_t globalVars_ : 1; //!< Code object contains global variables
|
||||
};
|
||||
uint32_t flags_; //!< Program flags
|
||||
};
|
||||
|
||||
@@ -3227,14 +3227,17 @@ bool VirtualGPU::processMemObjectsHSA(const amd::Kernel& kernel, const_address p
|
||||
dev().srds().fillResourceList(*this);
|
||||
}
|
||||
|
||||
addVmMemory(&hsaKernel.prog().codeSegGpu());
|
||||
|
||||
const static bool IsReadOnly = false;
|
||||
for (const pal::Memory* mem : hsaKernel.prog().globalStores()) {
|
||||
const static bool IsReadOnly = false;
|
||||
// Validate global store for a dependency in the queue
|
||||
memoryDependency().validate(*this, mem, IsReadOnly);
|
||||
addVmMemory(mem);
|
||||
}
|
||||
if (hsaKernel.prog().GlobalVariables()) {
|
||||
// Validate code object for a dependency in the queue
|
||||
memoryDependency().validate(*this, &hsaKernel.prog().codeSegGpu(), IsReadOnly);
|
||||
}
|
||||
addVmMemory(&hsaKernel.prog().codeSegGpu());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
新增問題並參考
封鎖使用者