Use size_t for the number of shared memory bytes. #1046
Merged
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.
Description
Use
size_t
for the number of shared memory bytes for most (all?) kernels.I did a find/replace for
unsigned int shared_bytes
so it's possible that I missed some kernels where the variable names are different. I also addedconst
to some instances ofshared_bytes
, where appropriate.Motivation and context
I was seeing compiler warnings when building HOOMD. These arose from the implicit casts of
unsigned int
tolong unsigned int
(the same assize_t
on my system) for amounts of shared memory passed to CUDA kernels. Several places in the source code use explicit C-style casts(unsigned int)(value)
orstatic_cast<unsigned int>(value)
to avoid this kind of warning, but the actual data is probably best represented assize_t
. Most of the places where this is used callsizeof(T)
, which returnssize_t
, and the HIP programming guide also says this value should besize_t
when passed to the kernel run function.This code path last changed in #809, which added the explicit casts in several places. It is likely that the new warnings I saw were from other PRs that were merged since then.
Sample warnings:
How has this been tested?
HOOMD builds without warnings now.
Compiler versions tested
Checklist:
sphinx-doc/credits.rst
) in the pull request source branch.