Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Large strings gtest fixture and utilities #15513
Large strings gtest fixture and utilities #15513
Changes from 10 commits
469ef0b
eab7a2f
c70e274
2d904e4
0356ed5
a00fd9e
13cb128
9ce12c2
95b3172
fc07a39
7906dcb
ed742e5
746ad6b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Moved from
copying/concatenate_tests.cpp
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.
Oh no, manually assigning static variable like this is not a good practice. Can we initialize it automatically?
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 issue is that the variable (or its pointer at least) needs to be accessible globally but the lifetime scope must be within
main()
. Solsd
must be created and destroyed within themain()
scope but needs to be singleton for the entire process at the same time.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.
How about create-on-first-access?
get_ls_data()
then should be called withinmain()
scope.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.
This won't work because it will return a pointer to main which will not automatically destroy it.
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.
Is there value in making this a function static? Its construction is guaranteed to be thread safe, and will be destroyed in reverse order of construction.
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.
We could use a smart pointer here. This seems to work.
When the smart pointer goes out of scope, it will delete the object.
This is more inline with what RMM does with resource memory manager objects.
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.
Sorry, I don't fully understand the concern. The function static object is guaranteed to be alive until
main()
exits. Does that not suit?Do we have a dependency somewhere in the global static destruction sequence, or something?
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.
@ttnghia: With a function static, the object is guaranteed to be initialized once, on the first call.
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.
Initializing part is not too challenging. Global static destruction is not good since the object holds device memory.
Here is a godbolt which I hope will explain some of this: https://godbolt.org/z/rTa9ceEKf
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.
Hmm. Thank you, I'll try bear this in mind.