forked from NVIDIA/cccl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure that
cuda::aligned_size_t
is usable in a constepxr context
Fixes [BUG]: `aligned_size_t` constructor and conversion operator are not constexpr NVIDIA#1563
- Loading branch information
Showing
2 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
libcudacxx/test/libcudacxx/cuda/barrier/aligned_size_t.pass.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// 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) 2024 NVIDIA CORPORATION & AFFILIATES. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
// UNSUPPORTED: libcpp-has-no-threads | ||
// UNSUPPORTED: pre-sm-70 | ||
|
||
// <cuda/barrier> | ||
|
||
#include <cuda/barrier> | ||
#include <cuda/std/cassert> | ||
#include <cuda/std/type_traits> | ||
|
||
__host__ __device__ constexpr bool test() { | ||
using aligned_t = cuda::aligned_size_t<1>; | ||
static_assert(!cuda::std::is_default_constructible<aligned_t>::value, ""); | ||
static_assert(aligned_t::align == 1, ""); | ||
{ | ||
const aligned_t aligned{42}; | ||
assert(aligned.value == 42); | ||
assert(static_cast<cuda::std::size_t>(aligned) == 42); | ||
} | ||
return true; | ||
} | ||
|
||
int main(int, char**) | ||
{ | ||
test(); | ||
static_assert(test(), ""); | ||
return 0; | ||
} |