Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor <cuda/std/cstdlib> #3339

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

davebayer
Copy link
Contributor

This PR implements refactor of <cuda/std/cstdlib>.

Changes:

  • removed imports of functions that are __host__ only, such as exit or atof
  • moved malloc-related functions to <cuda/std/__cstdlib/malloc.h> module
  • added implementation of calloc and aligned_alloc for __device__

@davebayer davebayer requested review from a team as code owners January 10, 2025 19:44
Copy link

copy-pr-bot bot commented Jan 10, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

Comment on lines +53 to +67
#if _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC)
# define _LIBCUDACXX_HAS_ALIGNED_ALLOC_HOST 1
# define _LIBCUDACXX_ALIGNED_ALLOC_HOST _CCCL_HOST
#else
# define _LIBCUDACXX_ALIGNED_ALLOC_HOST
#endif // _CCCL_STD_VER >= 2017 && !_CCCL_COMPILER(MSVC)

#if _CCCL_HAS_CUDA_COMPILER && !_CCCL_CUDA_COMPILER(CLANG)
# define _LIBCUDACXX_HAS_ALIGNED_ALLOC_DEVICE 1
# define _LIBCUDACXX_ALIGNED_ALLOC_DEVICE _CCCL_DEVICE
#else
# define _LIBCUDACXX_ALIGNED_ALLOC_DEVICE
#endif // _CCCL_HAS_CUDA_COMPILER && !_CCCL_CUDA_COMPILER(CLANG)

#define _LIBCUDACXX_ALIGNED_ALLOC_EXSPACE _LIBCUDACXX_ALIGNED_ALLOC_HOST _LIBCUDACXX_ALIGNED_ALLOC_DEVICE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate what the issue is here?

Shouldnt this rather be a _CCCL_EXECK_CHECK_DISABLE?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is quite simple, to use aligned_alloc

  • on host, we need C++17, but MSVC does not implement that at all
  • on device, we need support for __nv_aligned_device_malloc, which I did not a way to make it work with clang-cuda

Using _CCCL_EXECK_CHECK_DISABLE would probably solve the issue, too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Review
Development

Successfully merging this pull request may close these issues.

2 participants