Skip to content

[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

Merged
merged 2 commits into from
Nov 20, 2021

Conversation

steffenlarsen
Copy link
Contributor

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.

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]>
@steffenlarsen steffenlarsen requested a review from a team as a code owner November 16, 2021 09:16
Comment on lines -170 to -172
SpirVSize = OutputLengths[I];
SpirV = new byte[SpirVSize];
std::memcpy(SpirV, Outputs[I], SpirVSize);
Copy link
Contributor Author

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?

Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

alexbatashev
alexbatashev previously approved these changes Nov 16, 2021
Copy link
Contributor

@alexbatashev alexbatashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice catch

v-klochkov
v-klochkov previously approved these changes Nov 18, 2021
Comment on lines -170 to -172
SpirVSize = OutputLengths[I];
SpirV = new byte[SpirVSize];
std::memcpy(SpirV, Outputs[I], SpirVSize);
Copy link
Contributor

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.

Copy link
Contributor

@v-klochkov v-klochkov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bader bader merged commit 2af6ccd into intel:sycl Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants