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

Added test to verify program queries after recompiling and relinking #2272

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shajder
Copy link
Contributor

@shajder shajder commented Feb 11, 2025

Fixes #2163 according to issue description

@CLAassistant
Copy link

CLAassistant commented Feb 11, 2025

CLA assistant check
All committers have signed the CLA.

Comment on lines +502 to +506
const size_t len = kernel_names_len + 1;
std::vector<char> kernel_names(len, '\0');
error =
clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len,
kernel_names.data(), &kernel_names_len);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're interested, it's possible to read into a std::string directly (for C++11 and newer, which we are), vs. reading into a std::vector and then creating a std::string from it.

Something like:

Suggested change
const size_t len = kernel_names_len + 1;
std::vector<char> kernel_names(len, '\0');
error =
clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len,
kernel_names.data(), &kernel_names_len);
std::string kernel_names(kernel_names_len, '\0');
error =
clGetProgramInfo(program, CL_PROGRAM_KERNEL_NAMES, kernel_names_len,
&kernel_names[0], nullptr);
kernel_names.pop_back(); // remove the final '\0'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Obviously I can apply your suggestion but some time ago I was asked by one of reviewers here in CTS project to use std::vector<char> in such cases due to the concerns around spec requirement for std::string to have internally continuous chunk of memory. As far as I learnt later it was cleared up at some point in C++11 or 14 spec, still it seems like std::vector<char> delivers full control over underlying buffer. Just let me know to do the change.

"sample_test_C" };
for (const auto &name : expected_names)
{
test_assert_error(program_names.find(name.c_str())
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor: I don't think we need .c_str() here, do we?

Suggested change
test_assert_error(program_names.find(name.c_str())
test_assert_error(program_names.find(name)

Same pattern exists a few other places in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing coverage for CL_PROGRAM_* queries whose value can change after a rebuild
3 participants