Skip to content
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

Only write changing parts of kernel arguments to kernel CRA #324

Merged
merged 1 commit into from
Nov 17, 2023

Conversation

sophimao
Copy link
Contributor

No description provided.

@sophimao sophimao force-pushed the sim-low-ii branch 2 times, most recently from 54d4121 to 2a807f0 Compare November 15, 2023 16:44
@sophimao sophimao marked this pull request as ready for review November 15, 2023 19:40
@sophimao sophimao requested a review from zibaiwan November 15, 2023 19:55
@zibaiwan
Copy link
Contributor

zibaiwan commented Nov 15, 2023

Thanks Sophie. The overall PR looks good to me. Just one comment regarding using C code vs C++ code. I think since the Runtime have migrated to C++, we probably want to adopt C++ features in the case. Like using new&delete vs malloc&free, it's recommended to never use malloc in C++ due to a number of reasons.

For example

Instead of using
kern->kernel_arg_cache = (char **)acl_malloc(kern->num_accel * sizeof(char *));

Maybe use

kern->kernel_arg_cache = new char*[kern->num_accel](); Note: The () at the end should initialize each of the pointer to nullptr for you.

Don't forget to use delete [] for the array and delete each pointer.

While I am typing those, I feel I don't want to handle memory management myself already. I feel it's better to use the modern C++ feature unique_ptr and vector here as the underlying type of kernel_arg_cache.

I will let you decide.

zibaiwan
zibaiwan previously approved these changes Nov 15, 2023
@sophimao
Copy link
Contributor Author

Thanks Zibai for the suggestion! I think it's definitely valid, but I might submit that as a separate change in another PR as there are a lot of members of acl_kernel_if that currently still use malloc. In the separate change I might just update everything at once.

@sophimao sophimao merged commit 9ca3207 into intel:main Nov 17, 2023
@sophimao sophimao deleted the sim-low-ii branch November 17, 2023 14:55
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.

2 participants