Everything goes to a raw string
You can use Strf on CUDA devices but there are some limitations.
Naturally, you can’t write to FILE*
nor std::string
,
but you can write raw strings using basic_cstr_writer
.
So, the kernel — the function marked with __global__
qualifier — receives a char*
( or a pointer to another character type )
where it writes the content, which must later be transferred to the host memory
so that the host code can do something useful with it ( like sending to stdout
).
#include <strf.hpp>
__global__ void sample(char* dest, std::size_t dest_size)
{
strf::cstr_writer writer{dest, dest_size};
auto print = strf::to(writer);
print("Hello World!\n");
print("blah blah blah", 1234, '\n');
writer.finish();
}
Unsupported features on CUDA devices
The folowing features are not supported on device code:
-
destinations types
-
to_basic_string
,to_string
,to_u8string
,to_u16string
,to_u32string
,to_wstring
-
to(std::basic_streambuf</*…*/>
-
to(FILE*)
-
wto(FILE*)
-
-
uppercase
,lowercase
,mixedcase
( instead, you need to typelettercase::upper
,lettercase::lower
andlettercase::mixed
).