Skip to content

Commit

Permalink
add spdlog flush and rank support log
Browse files Browse the repository at this point in the history
  • Loading branch information
hxu65 committed Jan 15, 2024
1 parent b1cf3f7 commit e0d47ef
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 23 deletions.
7 changes: 4 additions & 3 deletions include/common/Tracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class TraceLogger {
+ ", \"tid\": " + threadID
+ "";

std::cout << logEntry << std::endl;
//std::cout << logEntry << std::endl;
auto my_logger = spdlog::get("trace_logger");

if (my_logger) {
Expand All @@ -100,8 +100,9 @@ class TraceLogger {
spdlog::warn("Logger not found, unable to log the message");
}


log->info(logEntry);

my_logger->flush();

}
};

Expand Down
51 changes: 31 additions & 20 deletions src/hermes_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ HermesEngine::HermesEngine(adios2::core::IO &io,//NOLINT
Init_();
engine_logger->info("rank {} with name {} and mode {}", rank, name, adios2::ToString(mode));
// debug model
engine_logger->info("Debug: initial done");
engine_logger->info("Debug: initial done rank: {}", rank);
}

/**
Expand All @@ -52,7 +52,7 @@ HermesEngine::HermesEngine(std::shared_ptr<coeus::IHermes> h,
Init_();
engine_logger->info("rank {} with name {} and mode {}", rank, name, adios2::ToString(mode));
// debug model
engine_logger->info("Debug: initial done 2");
engine_logger->info("Debug: initial done 2 rank: {}", rank);
}

/**
Expand Down Expand Up @@ -97,12 +97,14 @@ void HermesEngine::Init_() {
logger.set_level(spdlog::level::debug);
engine_logger = std::make_shared<spdlog::logger>(logger);

engine_logger->info("rank {}", rank);


//MPI setup
rank = m_Comm.Rank();
comm_size = m_Comm.Size();

engine_logger->info("rank {}", rank);

//Identifier, should be the file, but we don't get it
uid = this->m_IO.m_Name;

Expand Down Expand Up @@ -156,20 +158,20 @@ void HermesEngine::Init_() {
}
open = true;
// debug mode
engine_logger->info("initial Done 3");
engine_logger->info("initial Done 3, rank {}", rank);
engine_logger->flush();
}

/**
* Close the Engine.
* */
void HermesEngine::DoClose(const int transportIndex) {
TRACE_FUNC();
engine_logger->info("rank {}", rank);
engine_logger->info("Do close rank {}", rank);
open = false;
// mpiComm->free();

// debug mode
engine_logger->info("DoClose done");

engine_logger->flush();
}

HermesEngine::~HermesEngine() {
Expand All @@ -179,7 +181,8 @@ HermesEngine::~HermesEngine() {
delete db;

// debug mode
engine_logger->info("deconstrctor Done");
engine_logger->info("deconstrctor Done, rank {}", rank);
engine_logger->flush();
}

/**
Expand All @@ -191,7 +194,7 @@ adios2::StepStatus HermesEngine::BeginStep(adios2::StepMode mode,
TRACE_FUNC();
IncrementCurrentStep();
// debug mode
engine_logger->info("finish IncrementCurrentStep");
engine_logger->info("finish IncrementCurrentStep, rank {}", rank);


if (m_OpenMode == adios2::Mode::Read) {
Expand All @@ -207,7 +210,8 @@ adios2::StepStatus HermesEngine::BeginStep(adios2::StepMode mode,

Hermes->GetBucket(bucket_name);

engine_logger->info("finish BeginStep and Hermes getBucket");
engine_logger->info("finish BeginStep and Hermes getBucket, rank {}", rank);
engine_logger->flush();
return adios2::StepStatus::OK;
}

Expand All @@ -230,9 +234,10 @@ void HermesEngine::EndStep() {
}
}
// debug Mode
engine_logger->info("Finish EndStep");
engine_logger->info("Finish EndStep, rank {}", rank);
delete Hermes->bkt;
engine_logger->info("Finish EndStep and delete Hermes->bkt");
engine_logger->info("Finish EndStep and delete Hermes->bkt, rank {}", rank);
engine_logger->flush();
}

/**
Expand All @@ -248,7 +253,7 @@ bool HermesEngine::VariableMinMax(const adios2::core::VariableBase &Var,
// Obtain the blob from Hermes using the filename and variable name
hermes::Blob blob = Hermes->bkt->Get(Var.m_Name);
// debug Mode
engine_logger->info("finish VariableMinMax.");
engine_logger->info("finish VariableMinMax, rank {}", rank);
#define DEFINE_VARIABLE(T) \
if (adios2::helper::GetDataType<T>() == Var.m_Type) { \
size_t dataSize = blob.size() / sizeof(T); \
Expand Down Expand Up @@ -323,7 +328,8 @@ void HermesEngine::ElementMinMax(adios2::MinMaxStruct &MinMax, void *element) {
max = value;
}
// debug mode
engine_logger->info("ElementMinMax Done");
engine_logger->info("ElementMinMax Done, rank {}", rank);
engine_logger->flush();
}

void HermesEngine::LoadMetadata() {
Expand All @@ -336,7 +342,8 @@ void HermesEngine::LoadMetadata() {


// debug mode
engine_logger->info("LoadMetadata Done");
engine_logger->info("LoadMetadata Done, rank {}", rank);
engine_logger->flush();
}

void HermesEngine::DefineVariable(const VariableMetadata& variableMetadata) {
Expand Down Expand Up @@ -380,7 +387,8 @@ void HermesEngine::DoGetSync_(const adios2::core::Variable<T> &variable,
memcpy(values, blob.data(), blob.size());

// debug mode
engine_logger->info("Get Done");
engine_logger->info("Get Done, rank {}", rank);
engine_logger->flush();
}


Expand All @@ -402,7 +410,8 @@ void HermesEngine::DoGetDeferred_(
memcpy(values, blob.data(), blob.size());

// debug mode
engine_logger->info("Get Done");
engine_logger->info("Get Done, rank {}", rank);
engine_logger->flush();
}

template<typename T>
Expand Down Expand Up @@ -446,7 +455,8 @@ void HermesEngine::DoPutSync_(const adios2::core::Variable<T> &variable,
client.Mdm_insertRoot(DomainId::GetGlobal(), db_op);

// debug mode
engine_logger->info("Put Done");
engine_logger->info("Put Done, rank {}", rank);
engine_logger->flush();

}

Expand Down Expand Up @@ -492,7 +502,8 @@ void HermesEngine::DoPutDeferred_(
client.Mdm_insertRoot(DomainId::GetGlobal(), db_op);

// debug mode
engine_logger->info("Put Done");
engine_logger->info("Put Done, rank {}", rank);
engine_logger->flush();
}


Expand Down

0 comments on commit e0d47ef

Please sign in to comment.