Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First cut at adding printf, help builds. #40

Merged
merged 2 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions ports-of-call/portability.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ constexpr bool EXECUTION_IS_HOST{false};
#else
constexpr bool EXECUTION_IS_HOST{true};
#endif
// portable printf
template <typename ... Ts>
PORTABLE_INLINE_FUNCTION void printf(char const * const format, Ts ... ts) {
// disable for hip
#ifndef __HIPCC__
std::printf(format, ts...);
#endif // __HIPCC__
return;
}
} // PortsOfCall

template <typename T>
Expand Down
9 changes: 6 additions & 3 deletions ports-of-call/portable_errors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ PORTABLE_INLINE_FUNCTION void require(bool condition_bool,
const char *const message,
const char *const filename,
int const linenumber) {
using PortsOfCall::printf;
if (!condition_bool) {
std::printf(
printf(
"### ERROR\n Condition: %s\n Message: %s\n File: "
"%s\n Line number: %i\n",
condition, message, filename, linenumber);
Expand All @@ -134,7 +135,8 @@ inline void require(bool condition_bool, const char *const condition,
[[noreturn]] PORTABLE_INLINE_FUNCTION void abort(const char *const message,
const char *const filename,
int const linenumber) {
std::printf(
using PortsOfCall::printf;
printf(
"### ERROR\n Message: %s\n File: %s\n Line number: %i\n",
message, filename, linenumber);
impl::abort();
Expand Down Expand Up @@ -177,7 +179,8 @@ inline void require(bool condition_bool, const char *const condition,
PORTABLE_INLINE_FUNCTION
void warn(const char *const message, const char *const filename,
int const linenumber) {
std::printf(
using PortsOfCall::printf;
printf(
"### WARNING\n Message: %s\n File: %s\n Line number: "
"%i\n",
message, filename, linenumber);
Expand Down
Loading