//===----------------------------------------------------------------------===// // // 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) 2023 NVIDIA CORPORATION & AFFILIATES. // //===----------------------------------------------------------------------===// // Modifications Copyright (c) 2025 Advanced Micro Devices, Inc. // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // UNSUPPORTED: nvrtc, hiprtc, pre-sm-60 // UNSUPPORTED: windows && pre-sm-70 #include #include #include "helpers.h" template struct int_generator { __host__ __device__ auto operator()() const { return Value; } }; struct nullopt_generator { __host__ __device__ auto operator()() const { return cuda::std::nullopt; } }; template struct assign_tester { template __host__ __device__ static void initialize(Opt& opt) { opt = OperandGenerator()(); } template __host__ __device__ static void validate(Opt& opt) { assert(opt == OperandGenerator()()); } }; struct reset_tester { template __host__ __device__ static void initialize(Opt& opt) { opt.reset(); } template __host__ __device__ static void validate(Opt& opt) { assert(!opt.has_value()); } }; template struct swap_tester { template __host__ __device__ static void initialize(Opt& opt) { auto original = opt; cuda::std::optional val = OperandGenerator()(); opt.swap(val); assert(val == original); } template __host__ __device__ static void validate(Opt& opt) { cuda::std::optional val = OperandGenerator()(); assert(opt == val); } }; using testers = tester_list, assign_tester>, assign_tester, swap_tester>, reset_tester, assign_tester>, swap_tester>; struct non_trivial { int i; __host__ __device__ non_trivial(int i) : i(i) {} non_trivial(const non_trivial&) = default; non_trivial& operator=(const non_trivial&) = default; __host__ __device__ friend bool operator==(non_trivial lhs, non_trivial rhs) { return lhs.i == rhs.i; } }; void kernel_invoker() { // TODO: add validate_movable validate_pinned, testers>(); validate_pinned, testers>(); } int main(int arg, char** argv) { NV_IF_TARGET(NV_IS_HOST, (kernel_invoker();)) return 0; }