Repository navigation
Refactor cuda::arch_traits - #6150
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
670f570 to
d65db26
Compare
| //! | ||
| //! @note If the current architecture is unknown (too new/old), the compilation will fail. | ||
| template <class _Dummy = void> | ||
| [[nodiscard]] _CCCL_DEVICE_API inline ::cuda::arch_traits_t current_arch_traits() noexcept |
There was a problem hiding this comment.
I've made the function non-constexpr. As was described in the test file, it doesn't fully serve it's purpose due to missing function signatures. The advantage is that now we can be compatible with nvhpc in CUDA mode.
My idea is that we should try to go without constexpr and if users complain, we should add constexpr if possible (non nvhpc compilers).
If you don't agree with this, we can make it constexpr now, but then we will allow users to write code that is not portable among all of the CUDA compilers. And as I said, we can always add it later.
There was a problem hiding this comment.
Technically nvhpc CUDA compilation is not officially supported, I am not sure we should make the nvcc case worst because of something we don't support.
But at the same time it is true that the constexpr traits are not as useful as I hoped, so maybe we don't lose much.
The question I would ask is: Later we can add a second API that serves one of those cases, would it be better to special case the constexpr traits getter or to special case traits getter for nvhpc. I thought it made more sense to special case for nvhpc, but I am fine either way. Maybe we could provide both cases already?
There was a problem hiding this comment.
I know it's not officially supported now, but the thing is that it might change in the future. And users will have already their code written in a way that is not compatible with nvhpc.
I'm not against adding another API that would be constexpr, but I would like to make this the default.
And I believe that if you use the cuda::arch_trait().property in an if (...), I believe it will get optimized away, so we would be only paying the additional compilation cost.
There was a problem hiding this comment.
Ok, I am fine with that, we just need to figure out the name for the constexpr version then
There was a problem hiding this comment.
What about current_arch_traits_static or current_static_arch_traits (similar to static_extents)?
| // Confirm trait value is defined device code and usable as a reference | ||
| foo(cuda::arch::traits<Arch>().compute_capability); | ||
| foo(cuda::arch::current_traits().compute_capability);)) | ||
| assert(Arch == cuda::device::current_arch_id()); |
There was a problem hiding this comment.
todo: make it static_assert if we decide to go with constexpr
| [[maybe_unused]] __shared__ int array[cuda::arch_traits<Arch>().max_shared_memory_per_block / sizeof(int)]; | ||
|
|
||
| // constexpr is useless and I can't use intrinsics here :( | ||
| if (cuda::device::current_arch_traits().cluster_supported) |
There was a problem hiding this comment.
todo: make it if constexpr if we decide to go with constexpr
|
/ok to test d65db26 |
| case arch_id::sm_120a: | ||
| return ::cuda::arch_traits<arch_id::sm_120a>(); | ||
| default: | ||
| ::cuda::__throw_cuda_error(::cudaErrorInvalidValue, "Traits requested for an unknown architecture"); |
There was a problem hiding this comment.
Do we want to throw cuda_error here? Don't we want to use cuda::std::invalid_argument instead?
|
/ok to test 7aece08 |
|
/ok to test 59f560b |
This comment has been minimized.
This comment has been minimized.
| [[nodiscard]] _CCCL_API inline constexpr traits_t traits_for_id(id __id) | ||
| [[nodiscard]] _CCCL_API inline constexpr bool __is_known_compute_capability(int __cc) | ||
| { | ||
| return __cc >= __lowest_known_arch && __cc <= __highest_known_arch; |
There was a problem hiding this comment.
::cuda::in_range 😅 when ready
2de0775 to
a8077a0
Compare
a8077a0 to
519dfec
Compare
|
pre-commit.ci autofix |
|
/ok to test 162b3e9 |
d3d12dc to
40f39d9
Compare
|
We discussed changes in this PR with @pciolkosz and we decided to remove |
| sm_110 = 110, | ||
| sm_120 = 120, | ||
| sm_121 = 121, | ||
| sm_90a = 90 * __arch_specific_id_multiplier, |
There was a problem hiding this comment.
for my personal knowledge, how we support f variants? e.g. sm_110f
There was a problem hiding this comment.
This is a question for @pciolkosz, we can add them in a separate PR, I need to merge this now
This comment has been minimized.
This comment has been minimized.
🥳 CI Workflow Results🟩 Finished in 5h 28m: Pass: 100%/116 | Total: 12h 13m | Max: 29m 19s | Hits: 99%/226531See results here. |
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin branch/3.1.x
git worktree add -d .worktree/backport-6150-to-branch/3.1.x origin/branch/3.1.x
cd .worktree/backport-6150-to-branch/3.1.x
git switch --create backport-6150-to-branch/3.1.x
git cherry-pick -x d6f4c8a6b4d0dab95ad64385dc30dd97d20e0774 |
Co-authored-by: pciolkosz <pciolkosz@nvidia.com> (cherry picked from commit d6f4c8a)
Co-authored-by: pciolkosz <pciolkosz@nvidia.com> (cherry picked from commit d6f4c8a)
This PR refactors the CUDA architecture traits.
cuda::arch::namespace is removed and the functions and types are prefixed witharch_directlycuda::current_arch_traits()was moved tocuda::device::namespace, because it's device-only functioncuda::device::current_arch_id()function was added