Skip to content

Commit

Permalink
Fix building cuda version of k2 on Windows (#1257)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Oct 29, 2023
1 parent d12eec7 commit 20750d9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions k2/csrc/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,21 @@ enum class LogLevel {
// K2_LOG(TRACE) << "some message";
// K2_LOG(DEBUG) << "some message";
//
#ifndef _MSC_VER
constexpr LogLevel TRACE = LogLevel::kTrace;
constexpr LogLevel DEBUG = LogLevel::kDebug;
constexpr LogLevel INFO = LogLevel::kInfo;
constexpr LogLevel WARNING = LogLevel::kWarning;
constexpr LogLevel ERROR = LogLevel::kError;
constexpr LogLevel FATAL = LogLevel::kFatal;
#else
#define TRACE LogLevel::kTrace
#define DEBUG LogLevel::kDebug
#define INFO LogLevel::kInfo
#define WARNING LogLevel::kWarning
#define ERROR LogLevel::kError
#define FATAL LogLevel::kFatal
#endif

std::string GetStackTrace();

Expand All @@ -110,9 +119,8 @@ K2_CUDA_HOSTDEV LogLevel GetCurrentLogLevel();
inline bool EnableAbort() {
static std::once_flag init_flag;
static bool enable_abort = false;
std::call_once(init_flag, []() {
enable_abort = (std::getenv("K2_ABORT") != nullptr);
});
std::call_once(init_flag,
[]() { enable_abort = (std::getenv("K2_ABORT") != nullptr); });
return enable_abort;
}

Expand Down Expand Up @@ -274,7 +282,7 @@ class Logger {

class Voidifier {
public:
K2_CUDA_HOSTDEV void operator&(const Logger &)const {}
K2_CUDA_HOSTDEV void operator&(const Logger &) const {}
};

inline bool EnableCudaDeviceSync() {
Expand Down

0 comments on commit 20750d9

Please sign in to comment.