Conversation
|
@ajkr updated the pull request - view changes |
|
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
| // find a power of two >= num_cpus and >= 8 | ||
| size_shift_ = 3; | ||
| while (1u << size_shift_ < num_cpus) { | ||
| while (1 << size_shift_ < num_cpus) { |
There was a problem hiding this comment.
I'm curious why we need to cast to size_t below but not int here. Does it mean any integer is by default int?
There was a problem hiding this comment.
yes, the result of 1 << size_shift_ is an int because its left operand is an int. I cast to size_t before returning from functions so user can consistently use size_t as array indexes.
There was a problem hiding this comment.
also, unbelievably, the array index on line 52 has to be a size_t to avoid the warning about bitshifting+implicit 32-to-64-bit conversion. maybe we should just disable that warning, it makes dealing with arrays + bitshifting way too annoying.
|
@ajkr updated the pull request - view changes - changes since last import |
|
@ajkr updated the pull request - view changes - changes since last import |
|
@ajkr has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
try to clean up the type conversions and hope it passes on windows.
one interesting thing I learned is that bitshift operations are special: in
x << y, the result type depends only on the type ofx, unlike most arithmetic operations where the result type depends on both operands' types.