MUDA
Loading...
Searching...
No Matches
print.h
1#pragma once
2#include <cstdio>
3#include <cuda.h>
4#include <cuda_runtime.h>
5#include <cuda_runtime_api.h>
6
7namespace muda
8{
9template <typename InType, typename OutType = InType>
10MUDA_INLINE MUDA_GENERIC OutType print_convert(const InType& v)
11{
12 return v;
13}
14
15MUDA_INLINE MUDA_GENERIC auto print_convert(const char* v)
16{
17 return v;
18}
19
20template <typename T>
21MUDA_INLINE MUDA_GENERIC const T& print_check(const T& t)
22{
23 static_assert(std::is_arithmetic_v<T> || std::is_pointer_v<T>
24 || std::is_same_v<T, std::nullptr_t>,
25 "not supported type T in printf!");
26 return t;
27}
28
29MUDA_INLINE MUDA_GENERIC auto print_check(const char* t)
30{
31 return t;
32}
33
34template <typename... Args>
35MUDA_INLINE MUDA_GENERIC void print(const char* const fmt, Args&&... arg)
36{
37 ::printf(fmt, print_check(print_convert(std::forward<Args>(arg)))...);
38}
39} // namespace muda