//===----------------------------------------------------------------------===// // // Part of CUDA Experimental in CUDA C++ Core Libraries, // under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. // //===----------------------------------------------------------------------===// #ifndef COMMON_GROUP_CUH #define COMMON_GROUP_CUH #include #include #include #include #include #include "testing.cuh" namespace { template __device__ T global_barriers_storage; //! @brief Returns reference to an array of N cuda::barrier objects with suitable thread scope for level allocated in //! suitable address space (shared or device memory). Id parameter can be used to create unique object. template __device__ auto& get_barriers(const Level& level) noexcept { constexpr auto scope = cudax::__minimum_required_scope_for(); using Barrier = cuda::barrier; using BarriersStorage = cuda::std::aligned_storage_t; if constexpr (scope >= cuda::thread_scope_block) { __shared__ BarriersStorage shared_barriers_storage; return reinterpret_cast(shared_barriers_storage); } else { return reinterpret_cast(global_barriers_storage); } } struct ThreadsInWarpMappingResult { __device__ static constexpr ::cuda::std::size_t static_group_count() { return 1; } __device__ unsigned group_count() const { return 1; } __device__ unsigned group_rank() const { return 0; } __device__ static constexpr ::cuda::std::size_t static_unit_count() { return 32; } __device__ unsigned unit_count() const { return 32; } __device__ unsigned unit_rank() const { return cuda::gpu_thread.rank_as(cuda::warp); } __device__ cuda::device::lane_mask lane_mask() const noexcept { return cuda::device::lane_mask::all(); } __device__ bool is_valid() const { return true; } __device__ static constexpr bool is_always_exhaustive() noexcept { return true; } __device__ static constexpr bool is_always_contiguous() noexcept { return true; } }; } // namespace #endif // COMMON_GROUP_CUH