-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fix memory leak in online compiler #4963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SYCL] Fix memory leak in online compiler #4963
Conversation
The experimental online compiler may leak memory in compileToSPIRV. These changes address this leak by storing the SPIR-V binary information directly in the vector that will later be returned. Signed-off-by: Steffen Larsen <[email protected]>
SpirVSize = OutputLengths[I]; | ||
SpirV = new byte[SpirVSize]; | ||
std::memcpy(SpirV, Outputs[I], SpirVSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v-klochkov - Can there only be at most one .spv in OutputNames
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@v-klochkov, ping, can you answer the question above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me.
Regarding the number of output spirv files. It is assumed to be 1 at most, but I did not find any strict wordings about that in ocloc API https://github.com/intel/compute-runtime/blob/master/shared/offline_compiler/source/ocloc_api.h
It may be a good idea to add an assert here checking that there is only 1 spv output.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! I have added such an assertion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch
SpirVSize = OutputLengths[I]; | ||
SpirV = new byte[SpirVSize]; | ||
std::memcpy(SpirV, Outputs[I], SpirVSize); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me.
Regarding the number of output spirv files. It is assumed to be 1 at most, but I did not find any strict wordings about that in ocloc API https://github.com/intel/compute-runtime/blob/master/shared/offline_compiler/source/ocloc_api.h
It may be a good idea to add an assert here checking that there is only 1 spv output.
Signed-off-by: Steffen Larsen <[email protected]>
43e98f7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
The experimental online compiler may leak memory in compileToSPIRV. These changes address this leak by storing the SPIR-V binary information directly in the vector that will later be returned.