Skip to content

Commit

Permalink
set print file
Browse files Browse the repository at this point in the history
  • Loading branch information
Angelyr committed Nov 27, 2024
1 parent 69d43eb commit 4c1073d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions support/ppPrint.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,25 @@ namespace pumipic {
#define ACTIVE_GPU_EXECUTION
#endif

inline FILE* pp_stdout = stdout;
inline FILE* pp_stderr = stderr;

inline void pp_set_stdout(FILE* out) {
assert(out != NULL);
pp_stdout = out;
}

inline void pp_set_stderr(FILE* err) {
assert(err != NULL);
pp_stderr = err;
}

template<typename... Args>
void pPrintError(const char* fmt, const Args&... args) {
#if defined(SPDLOG_ENABLED) && defined(PP_PRINT_ENABLED)
spdlog::error("{}", fmt::sprintf(fmt, args...));
#elif defined(PP_PRINT_ENABLED)
fprintf(stderr, fmt, args...);
fprintf(pp_stderr, fmt, args...);
#endif
}

Expand All @@ -28,8 +41,8 @@ namespace pumipic {
void pPrintInfo(const char* fmt, const Args&... args) {
#if defined(SPDLOG_ENABLED) && defined(PP_PRINT_ENABLED) && !defined(ACTIVE_GPU_EXECUTION)
spdlog::info("{}", fmt::sprintf(fmt, args...));
#elif defined(PP_PRINT_ENABLED)
Kokkos::printf(fmt, args...);
#elif defined(PP_PRINT_ENABLED) && !defined(ACTIVE_GPU_EXECUTION)
fprintf(pp_stdout, fmt, args...);
#endif
}

Expand Down

0 comments on commit 4c1073d

Please sign in to comment.