P4 to Git Change 1282811 by gandryey@gera-w8 on 2016/06/22 12:06:40

SWDEV-91794 - Memory leak when looping BuildProgram
	- Release binary raw inside runtime and compiler library

Affected files ...

... //depot/stg/opencl/drivers/opencl/compiler/lib/api/v0_8/acl.cpp#43 edit
... //depot/stg/opencl/drivers/opencl/compiler/lib/loaders/bif/bifbase.cpp#57 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpucompiler.cpp#155 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.cpp#227 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuprogram.hpp#68 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palcompiler.cpp#3 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.cpp#8 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palprogram.hpp#6 edit
This commit is contained in:
foreman
2016-06-22 12:40:45 -04:00
parent 047ef6b06e
commit af8e9cc3bb
6 changed files with 57 additions and 55 deletions
+23 -11
View File
@@ -68,7 +68,7 @@ HSAILProgram::~HSAILProgram()
delete it;
}
if (rawBinary_ != nullptr) {
free(rawBinary_);
aclFreeMem(binaryElf_, rawBinary_);
}
acl_error error;
// Free the elf binary
@@ -216,12 +216,8 @@ HSAILProgram::linkImpl(
aclBinaryFini(binaries_to_link[i]);
}
if (createLibrary) {
size_t size = 0;
void *mem = NULL;
aclWriteToMem(binaryElf_, &mem, &size);
setBinary(static_cast<char*>(mem), size);
saveBinaryAndSetType(TYPE_LIBRARY);
buildLog_ += aclGetCompilerLog(dev().compiler());
setType(TYPE_LIBRARY);
return true;
}
// Now call linkImpl with the new options
@@ -578,12 +574,8 @@ HSAILProgram::linkImpl(amd::option::Options* options)
}
}
// Save the binary in the interface class
size_t size = 0;
void *mem = nullptr;
aclWriteToMem(binaryElf_, &mem, &size);
setBinary(static_cast<char*>(mem), size);
saveBinaryAndSetType(TYPE_EXECUTABLE);
buildLog_ += aclGetCompilerLog(dev().compiler());
setType(TYPE_EXECUTABLE);
return true;
}
@@ -696,6 +688,26 @@ HSAILProgram::info(const char * str) {
return info_;
}
bool
HSAILProgram::saveBinaryAndSetType(type_t type)
{
//Write binary to memory
if (rawBinary_ != nullptr) {
//Free memory containing rawBinary
aclFreeMem(binaryElf_, rawBinary_);
rawBinary_ = nullptr;
}
size_t size = 0;
if (aclWriteToMem(binaryElf_, &rawBinary_, &size) != ACL_SUCCESS) {
buildLog_ += "Failed to write binary to memory \n";
return false;
}
setBinary(static_cast<char*>(rawBinary_), size);
//Set the type of binary
setType(type);
return true;
}
hsa_isa_t ORCAHSALoaderContext::IsaFromName(const char *name) {
hsa_isa_t isa = {0};
if (!strcmp(Gfx700, name)) { isa.handle = gfx700; return isa; }