#pragma once #include #include #include #include #include #include namespace unittest { template std::string type_name() { return demangle(typeid(T).name()); } // end type_name() // Use this with counting_iterator to avoid generating a range larger than we // can represent. template typename THRUST_NS_QUALIFIER::detail::disable_if<::cuda::std::is_floating_point::value, T>::type truncate_to_max_representable(std::size_t n) { return static_cast( THRUST_NS_QUALIFIER::min(n, static_cast(::cuda::std::numeric_limits::max()))); } // TODO: This probably won't work for `half`. template typename ::cuda::std::enable_if_t<::cuda::std::is_floating_point::value, T> truncate_to_max_representable(std::size_t n) { return THRUST_NS_QUALIFIER::min(static_cast(n), ::cuda::std::numeric_limits::max()); } } // namespace unittest template void PRINT(Iterator first, Iterator last) { size_t n = 0; for (Iterator i = first; i != last; i++, n++) { std::cout << ">>> [" << n << "] = " << *i << '\n'; } } template void PRINT(const Container& c) { PRINT(c.begin(), c.end()); } template void PRINT(const char (&c)[N]) { std::cout << std::string(c, c + N) << '\n'; }