CUDA Shared Memory Swizzlingleimao.github.io 63 pointsjxmorris1230 days ago2 commentsSaveHideCopy link On HNComments−johndough24dI was wondering why the author was using braced initialization like size_t i{0}; instead of the more common size_t i = 0; Apparently, braced initialization does not allow narrowing conversion, so you'd get a compiler error for e.g. casting double to float size_t i{0.0}; and a warning for double d = 0.0; size_t i{d}; which might silently overflow size_t otherwise, so this is a bit safer.In C++, you can get the same effect without the unusual syntax by passing -Wfloat-conversion to gcc/clang, but not sure how to do that with CUDA:−KeplerBoy24dLei Mao's blog is such an amazing resource for GPU performance engineering. I am stunned by the sheer amount of insight he puts out on his blog.
Comments
I was wondering why the author was using braced initialization like
instead of the more common Apparently, braced initialization does not allow narrowing conversion, so you'd get a compiler error for e.g. casting double to float and a warning for which might silently overflow size_t otherwise, so this is a bit safer.In C++, you can get the same effect without the unusual syntax by passing -Wfloat-conversion to gcc/clang, but not sure how to do that with CUDA:
Lei Mao's blog is such an amazing resource for GPU performance engineering. I am stunned by the sheer amount of insight he puts out on his blog.