Skip to content

Commit

Permalink
enable on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyncs committed Feb 4, 2024
1 parent 1080249 commit f8f8335
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 34 deletions.
16 changes: 7 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@ set(CUTLASS_ENABLE_HEADERS_ONLY ON CACHE BOOL "Enable only the header library")

FetchContent_MakeAvailable(repo-cutlass)

if (NOT WIN32)
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
)
FetchContent_MakeAvailable(spdlog)
include_directories(${CMAKE_BINARY_DIR}/_deps/spdlog-src/include)
endif ()
FetchContent_Declare(
spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.13.0
)
FetchContent_MakeAvailable(spdlog)
include_directories(${CMAKE_BINARY_DIR}/_deps/spdlog-src/include)

set(CUTLASS_HEADER_DIR ${PROJECT_SOURCE_DIR}/3rdparty/cutlass/include)
set(CUTLASS_EXTENSIONS_DIR ${PROJECT_SOURCE_DIR}/src/turbomind/cutlass_extensions/include)
Expand Down
7 changes: 2 additions & 5 deletions src/turbomind/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ target_link_libraries(cuda_utils PUBLIC CUDA::cudart)
add_library(logger STATIC logger.cc)
set_property(TARGET logger PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET logger PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS ON)
if (NOT WIN32)
target_link_libraries(logger PUBLIC CUDA::cudart -lpthread)
else ()
target_link_libraries(logger PUBLIC CUDA::cudart)
endif ()

target_link_libraries(logger PUBLIC CUDA::cudart Threads::Threads)

add_library(cublasAlgoMap STATIC cublasAlgoMap.cc)
set_property(TARGET cublasAlgoMap PROPERTY POSITION_INDEPENDENT_CODE ON)
Expand Down
11 changes: 4 additions & 7 deletions src/turbomind/utils/logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,26 @@

#include "src/turbomind/utils/logger.h"
#include <cuda_runtime.h>

#ifndef _MSC_VER
#include <spdlog/async.h>
#include <spdlog/sinks/basic_file_sink.h>
#include <spdlog/sinks/hourly_file_sink.h>
#include <spdlog/sinks/rotating_file_sink.h>
#endif

namespace turbomind {

Logger::Logger()
{
#ifndef _MSC_VER
char* log_path = std::getenv("TM_LOG_PATH");
if (log_path != nullptr) {
SpdLogger::get_instance().set_log_path(std::string(log_path));
} else {
#ifndef _MSC_VER
SpdLogger::get_instance().set_log_path("/var/log/lmdeploy.log");
#else
SpdLogger::get_instance().set_log_path("C:\Users\lmdeploy.log");
#endif
}
SpdLogger::get_instance().init();
#endif
char* is_first_rank_only_char = std::getenv("TM_LOG_FIRST_RANK_ONLY");
bool is_first_rank_only =
(is_first_rank_only_char != nullptr && std::string(is_first_rank_only_char) == "ON") ? true : false;
Expand Down Expand Up @@ -72,7 +71,6 @@ Logger::Logger()
}
}

#ifndef _MSC_VER
void SpdLogger::init()
{
if (inited_) {
Expand All @@ -99,6 +97,5 @@ void SpdLogger::init()

inited_ = true;
}
#endif

} // namespace turbomind
13 changes: 0 additions & 13 deletions src/turbomind/utils/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
#include <cstdlib>
#include <map>
#include <string>

#ifndef _MSC_VER
#include <spdlog/spdlog.h>
#endif

#include "src/turbomind/utils/string_utils.h"

Expand All @@ -34,7 +31,6 @@ namespace turbomind {
#undef ERROR
#endif

#ifndef _MSC_VER
class SpdLogger {
public:
static SpdLogger& get_instance()
Expand Down Expand Up @@ -63,7 +59,6 @@ class SpdLogger {
bool inited_ = false;
std::shared_ptr<spdlog::logger> logger_;
};
#endif

class Logger {

Expand Down Expand Up @@ -91,11 +86,7 @@ class Logger {
if (level_ <= level) {
std::string fmt = getPrefix(level) + format + "\n";
std::string logstr = fmtstr(fmt, args...);
#ifdef _MSC_VER
fprintf(stderr, "%s", logstr.c_str());
#else
SpdLogger::get_instance().get_logger()->log(spdlog::level::trace, logstr);
#endif
}
}

Expand All @@ -105,11 +96,7 @@ class Logger {
if (level_ <= level) {
std::string fmt = getPrefix(level, rank) + format + "\n";
std::string logstr = fmtstr(fmt, args...);
#ifdef _MSC_VER
fprintf(stderr, "%s", logstr.c_str());
#else
SpdLogger::get_instance().get_logger()->log(spdlog::level::trace, logstr);
#endif
}
}

Expand Down

0 comments on commit f8f8335

Please sign in to comment.