Description
I prefer the return, it's more functional, looks more clear, and I think it's a better general c++/CUDA practice, and the compiler is nominally better at optimizing it (in general - here I think everything will be inlined anyway). So I always default to returning.
Originally posted by @ProExpertProg in #19233 (comment)
The vLLM codebase currently employs two different patterns for handling function outputs within our CUDA C++ code:
- Return Values: Functions return the result directly (e.g.,
OutType func(InType)
). - Output Parameters: Functions take a non-const pointer or reference to fill with the result (e.g.,
void func(InType, OutType*)
).
While both are valid, the lack of a formal standard can lead to inconsistencies. Adopting a clear coding standard would improve readability, maintainability, and make it easier for new contributors to understand and write idiomatic code.
I would like to open this topic for discussion with the community. What are your thoughts on this? If we can reach a consensus, we can create a small guide in our contribution documentation and identify existing code that could be refactored in follow-up issues.