Skip to content

Use of standard library math functions vs global namespace  #128253

@alugorey

Description

@alugorey

Issue description

Recently, it was discovered that some hip kernels prefer to use global namespace vs std namespace for various math functions. There was a recent issue being discussed where the use of global namespace math functions was causing minor accuracy issues on ROCm. Please reference said issue comment for more background: #96560 (comment)

After some internal investigation it was found that the global namespace was chosen in accordance CUDA documentation:
https://docs.nvidia.com/cuda/cuda-math-api/index.html

Note also that due to implementation constraints, certain math functions from std:: namespace may be callable in device code even via explicitly qualified std:: names. However, such use is discouraged, since this capability is unsupported, unverified, undocumented, not portable, and may change without notice.

There have also been other issues related to this where the std namespace seems to be generally prioritized when, according to the above documentation, it shouldn't
#127812

So I wanted to open a discussion as to why CUDA kernels are prioritizing the std namespace over the global namespace?

Should we standardize to global namespace for consistency?

cc @ptrblck @msaroufim @jeffdaily @sunway513 @jithunnair-amd @pruthvistony @ROCmSupport @dllehr-amd @jataylo @hongxiayang

Metadata

Metadata

Assignees

No one assigned

    Labels

    module: cudaRelated to torch.cuda, and CUDA support in generalmodule: rocmAMD GPU support for PytorchtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions