You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello fmt maintainers, thanks for such a neat library.
I would like to use fmt in GPU code and have been exploring what would be necessary to make that possible. I've had some success with the Circle compiler. Here is my fork with a demo program: https://github.com/jaredhoberock/fmt/blob/circle/hello_gpu.cpp
I found it necessary to make one small edit to fmt::detail::assert_fail to make this work. GPU code cannot call std::fprintf or std::terminate, so another option was necessary:
FMT_FUNC void assert_fail(const char* file, int line, const char* message) {
#if defined(__circle_lang__) and defined(__CUDACC__)
NV_IF_ELSE_TARGET(NV_IS_DEVICE, (
// GPU code has no access to either std::fprintf or std::terminate, so call __assert_fail
__assert_fail(message, file, line, /*function=*/nullptr);
), (
// Use unchecked std::fprintf to avoid triggering another assertion when
// writing to stderr fails
std::fprintf(stderr, "%s:%d: assertion failed: %s", file, line, message);
// Chosen instead of std::abort to satisfy Clang in CUDA mode during device
// code pass.
std::terminate();
))
#else
// Use unchecked std::fprintf to avoid triggering another assertion when
// writing to stderr fails
...
#endif
}
I know that fmt is flexible, so I wonder if there already exists an option to configure fmt to achieve this sort of thing without editing the source.
Failing that, would the maintainers be interested in brainstorming an enhancement that could deal this issue directly?
The text was updated successfully, but these errors were encountered:
Hello fmt maintainers, thanks for such a neat library.
I would like to use fmt in GPU code and have been exploring what would be necessary to make that possible. I've had some success with the Circle compiler. Here is my fork with a demo program: https://github.com/jaredhoberock/fmt/blob/circle/hello_gpu.cpp
I found it necessary to make one small edit to
fmt::detail::assert_fail
to make this work. GPU code cannot callstd::fprintf
orstd::terminate
, so another option was necessary:I know that fmt is flexible, so I wonder if there already exists an option to configure fmt to achieve this sort of thing without editing the source.
Failing that, would the maintainers be interested in brainstorming an enhancement that could deal this issue directly?
The text was updated successfully, but these errors were encountered: