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
Tento commit je obsažen v:
foreman
2016-06-22 12:40:45 -04:00
rodič 047ef6b06e
revize af8e9cc3bb
6 změnil soubory, kde provedl 57 přidání a 55 odebrání
+23 -11
Zobrazit soubor
@@ -1715,7 +1715,7 @@ HSAILProgram::~HSAILProgram()
delete it;
}
if (rawBinary_ != NULL) {
free(rawBinary_);
aclFreeMem(binaryElf_, rawBinary_);
}
acl_error error;
// Free the elf binary
@@ -1863,12 +1863,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().hsaCompiler());
setType(TYPE_LIBRARY);
return true;
}
// Now call linkImpl with the new options
@@ -2227,12 +2223,8 @@ HSAILProgram::linkImpl(amd::option::Options* options)
}
}
// Save the binary in the interface class
size_t size = 0;
void *mem = NULL;
aclWriteToMem(binaryElf_, &mem, &size);
setBinary(static_cast<char*>(mem), size);
saveBinaryAndSetType(TYPE_EXECUTABLE);
buildLog_ += aclGetCompilerLog(dev().hsaCompiler());
setType(TYPE_EXECUTABLE);
return true;
}
@@ -2345,6 +2337,26 @@ HSAILProgram::info(const char * str) {
return info_;
}
bool
HSAILProgram::saveBinaryAndSetType(type_t type)
{
//Write binary to memory
if (rawBinary_ != NULL) {
//Free memory containing rawBinary
aclFreeMem(binaryElf_, rawBinary_);
rawBinary_ = NULL;
}
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; }