//===----------------------------------------------------------------------===// // // Part of the libcu++ Project, 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) 2025 NVIDIA CORPORATION & AFFILIATES. // //===----------------------------------------------------------------------===// #include #include #include #include #include "test_macros.h" template __host__ __device__ constexpr bool test() { using nl = cuda::std::numeric_limits; constexpr T all_ones = static_cast(~T{0}); unused(all_ones); assert(cuda::bitmask(0, 0) == 0); assert(cuda::bitmask(0, 1) == 1); assert(cuda::bitmask(1, 0) == 0); assert(cuda::bitmask(1, 1) == 0b10); assert(cuda::bitmask(0, 2) == 0b11); assert(cuda::bitmask(2, 2) == 0b1100); assert(cuda::bitmask(0, 2) == 0b11); assert(cuda::bitmask(3, 2) == 0b11000); assert(cuda::bitmask(nl::digits - 1, 1) == (T{1} << (nl::digits - 1u))); assert(cuda::bitmask(0, nl::digits) == all_ones); assert(cuda::bitmask(nl::digits, 0) == 0); return true; } __host__ __device__ constexpr bool test() { test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); test(); #if _CCCL_HAS_INT128() test<__uint128_t>(); #endif // _CCCL_HAS_INT128() return true; } int main(int, char**) { assert(test()); static_assert(test()); return 0; }