-
Notifications
You must be signed in to change notification settings - Fork 208
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
base: main
Are you sure you want to change the base?
Conversation
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); |
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.
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:
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' |
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.
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()) |
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.
Minor: I don't think we need .c_str()
here, do we?
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.
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.
Corrected
Fixes #2163 according to issue description