// SPDX-FileCopyrightText: Copyright (c) 2011-2024, NVIDIA CORPORATION. All rights reserved. // SPDX-License-Identifier: BSD-3 #pragma once #include #include #include #include #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA # include #else # include # include #endif namespace c2h { #if THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA template using host_vector = THRUST_NS_QUALIFIER::detail::vector_base>; template using device_vector = THRUST_NS_QUALIFIER::detail::vector_base>; #else // THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA using THRUST_NS_QUALIFIER::device_vector; using THRUST_NS_QUALIFIER::host_vector; #endif // THRUST_DEVICE_SYSTEM == THRUST_DEVICE_SYSTEM_CUDA } // namespace c2h // We specialize how Catch2 prints ([signed|unsigned]) char vectors for better readability. Let's print them as numbers // instead of characters. template struct Catch::StringMaker, ::cuda::std::enable_if_t>> { // Copied from `rangeToString` in catch_tostring.hpp static auto convert(const THRUST_NS_QUALIFIER::detail::vector_base& v) -> std::string { auto first = v.begin(); auto last = v.end(); ReusableStringStream rss; rss << "{ "; if (first != last) { rss << Detail::stringify(static_cast(static_cast(*first))); for (++first; first != last; ++first) { rss << ", " << Detail::stringify(static_cast(static_cast(*first))); } } rss << " }"; return rss.str(); } }; // due to an nvcc bug, the above specialization of StringMaker is ambiguous with one inside Catch2, so let's disable // Catch2 range formatting for vector_base with sizeof(T) == 1 entirely template struct Catch::is_range> { static constexpr bool value = !(sizeof(T) == 1 && ::cuda::std::is_fundamental_v); };