Skip to content
Open
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
6 changes: 5 additions & 1 deletion Simulator/Connections/Neuro/ConnGrowth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
#include "OperationManager.h"
#include "ParameterManager.h"
#include "ParseParamError.h"
#include <log4cplus/loggingmacros.h>

#ifdef USE_HDF5
#include "Hdf5Recorder.h"
Expand Down Expand Up @@ -324,7 +325,10 @@ void ConnGrowth::updateEdgesWeights()
/// Prints radii
void ConnGrowth::printRadii() const
{
log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
for (int i = 0; i < radiiSize_; i++) {
cout << "radii[" << i << "] = " << radii_[i] << endl;
// cout << "radii[" << i << "] = " << radii_[i] << endl;
string msg = "radii[" + to_string(i) + "] = " + to_string(radii_[i]);
LOG4CPLUS_TRACE(consoleLogger, msg);
}
}
23 changes: 17 additions & 6 deletions Simulator/Core/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#include "ParameterManager.h"
#include "Serializer.h"
#include "config.h" // build/config.h contains the git commit id

#include <iostream>
#include <string>
// Uncomment to use visual leak detector (Visual Studios Plugin)
// #include <vld.h>
#if defined(USE_GPU)
Expand All @@ -51,6 +52,8 @@ bool Core::parseCommandLine(string executableName, string cmdLineArguments)
"The UW Bothell graph-based simulation environment, for high-performance neural network and other graph-based problems\n Usage: "
+ executableName + " "));

log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));

// Set up the comment line parser.
if ((cl.addParam("configfile", 'c', ParamContainer::filename, "parameter configuration filepath")
!= ParamContainer::errOk)
Expand All @@ -69,7 +72,7 @@ bool Core::parseCommandLine(string executableName, string cmdLineArguments)
|| (cl.addParam("version", 'v', ParamContainer::novalue,
"output current git commit ID and exit")
!= ParamContainer::errOk)) {
cerr << "Internal error creating command line parser" << endl;
LOG4CPLUS_FATAL(consoleLogger, ("Internal error creating command line parser\n"));
return false;
}

Expand All @@ -80,7 +83,9 @@ bool Core::parseCommandLine(string executableName, string cmdLineArguments)
}

if (cl["version"].compare("") != 0) {
cout << "Git commit ID: " << GIT_COMMIT_ID << endl;
string str(GIT_COMMIT_ID);
string message = "Git commit ID: " + str + "\n";
LOG4CPLUS_TRACE(consoleLogger, message);
exit(0);
}

Expand Down Expand Up @@ -243,8 +248,14 @@ int Core::runSimulation(string executableName, string cmdLineArguments)
time(&end_time);
double timeElapsed = difftime(end_time, start_time);
double ssps = simulator.getEpochDuration() * simulator.getNumEpochs() / timeElapsed;
cout << "time simulated: " << simulator.getEpochDuration() * simulator.getNumEpochs() << endl;
cout << "time elapsed: " << timeElapsed << endl;
cout << "ssps (simulation seconds / real time seconds): " << ssps << endl;
// cout << "time simulated: " << simulator.getEpochDuration() * simulator.getNumEpochs() << endl;
// cout << "time elapsed: " << timeElapsed << endl;
// cout << "ssps (simulation seconds / real time seconds): " << ssps << endl;
string message = "time simulated: " + to_string(simulator.getEpochDuration() * simulator.getNumEpochs()) + "\n";
LOG4CPLUS_TRACE(consoleLogger, message);
message = "time elapsed: " + to_string(timeElapsed) + "\n";
LOG4CPLUS_TRACE(consoleLogger, message);
message = "ssps (simulation seconds / real time seconds): " + to_string(ssps) + "\n";
LOG4CPLUS_TRACE(consoleLogger, message);
return 0;
}
17 changes: 11 additions & 6 deletions Simulator/Core/Serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ bool Serializer::deserialize()
ifstream memory_in(simulator.getDeserializationFileName().c_str());
//ifstream memory_in (simInfo->memInputFileName.c_str(), std::ios::binary);

log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));

// Checks to see if serialization file exists
if (!memory_in) {
cerr << "The serialization file doesn't exist" << endl;
LOG4CPLUS_FATAL(consoleLogger, "The serialization file doesn't exist");
return false;
}

Expand All @@ -60,7 +62,7 @@ bool Serializer::deserialize()
//cereal::BinaryInputArchive archive(memory_in);

if (!processArchive(archive, simulator)) {
cerr << "Failed to deserialize" << endl;
LOG4CPLUS_FATAL(consoleLogger, "Failed to deserialize");
return false;
}

Expand All @@ -79,17 +81,19 @@ void Serializer::serialize()
{
Simulator &simulator = Simulator::getInstance();

log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));

// We can serialize to a variety of archive file formats. Below, comment out
// all but the two lines that correspond to the desired format.
ofstream memory_out(simulator.getSerializationFileName().c_str());
cout << "Please find the serialized file in " << simulator.getSerializationFileName().c_str();

string message = "Please find the serialized file in " + simulator.getSerializationFileName();
LOG4CPLUS_TRACE(consoleLogger, message);
cereal::XMLOutputArchive archive(memory_out);
//ofstream memory_out (simInfo->memOutputFileName.c_str(), std::ios::binary);
//cereal::BinaryOutputArchive archive(memory_out);

if (!processArchive(archive, simulator)) {
cerr << "Failed to serialize" << endl;
LOG4CPLUS_ERROR(consoleLogger, "Failed to serialize");
}
}

Expand All @@ -103,7 +107,8 @@ template <typename Archive> bool Serializer::processArchive(Archive &archive, Si
// Serialize/Deserialize required global variables
archive(initRNG, noiseRNG, g_simulationStep);
} catch (cereal::Exception e) {
cerr << e.what() << endl;
log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
LOG4CPLUS_ERROR(consoleLogger, e.what());
return false;
}
return true;
Expand Down
2 changes: 1 addition & 1 deletion Simulator/Core/Simulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ void Simulator::simulate()
// Time since start of simulation
double total_time = timer.lap() / 1000000.0;

cout << "\ntotal_time: " << total_time << " seconds" << endl;
LOG4CPLUS_TRACE(consoleLogger_, "\ntotal_time: " << total_time << " seconds");
printPerformanceMetrics(total_time, currentEpoch);
cout << endl;
#endif
Expand Down
22 changes: 15 additions & 7 deletions Simulator/Edges/Neuro/AllDSSynapses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,15 +187,23 @@ void AllDSSynapses::changePSR(BGSIZE iEdg, BGFLOAT deltaT)
void AllDSSynapses::printSynapsesProps() const
{
AllSpikingSynapses::printSynapsesProps();
log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) {
if (W_[i] != 0.0) {
cout << "lastSpike[" << i << "] = " << lastSpike_[i];
cout << " r: " << r_[i];
cout << " u: " << u_[i];
cout << " D: " << D_[i];
cout << " U: " << U_[i];
cout << " F: " << F_[i] << endl;
string message = ("lastSpike[" + to_string(i) + "] = " + to_string(lastSpike_[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" r: " + to_string(r_[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" u: " + to_string(u_[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" D: " + to_string(D_[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" U: " + to_string(U_[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" F: " + to_string(F_[i]) + "\n");
LOG4CPLUS_INFO(consoleLogger, message);
}
}
cout << endl;
LOG4CPLUS_INFO(consoleLogger, endl);

}
52 changes: 35 additions & 17 deletions Simulator/Edges/Neuro/AllDSSynapses_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,25 +302,43 @@ void AllDSSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const
cudaMemcpy(FPrint, allSynapsesProps.F_, size * sizeof(BGFLOAT), cudaMemcpyDeviceToHost));


log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));

for (int i = 0; i < size; i++) {
if (WPrint[i] != 0.0) {
cout << "GPU W[" << i << "] = " << WPrint[i];
cout << " GPU sourNeuron: " << sourceNeuronIndexPrint[i];
cout << " GPU desNeuron: " << destNeuronIndexPrint[i];
cout << " GPU type: " << typePrint[i];
cout << " GPU psr: " << psrPrint[i];
cout << " GPU in_use:" << (inUsePrint[i] == 1 ? "true" : "false");

cout << " GPU decay: " << decayPrint[i];
cout << " GPU tau: " << tauPrint[i];
cout << " GPU total_delay: " << totalDelayPrint[i];

cout << " GPU lastSpike: " << lastSpikePrint[i];
cout << " GPU r: " << rPrint[i];
cout << " GPU u: " << uPrint[i];
cout << " GPU D: " << DPrint[i];
cout << " GPU U: " << UPrint[i];
cout << " GPU F: " << FPrint[i] << endl;
string message = ("GPU W[" + to_string(i) + "] = " + to_string(WPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU sourNeuron: " + sourceNeuronIndexPrint[i]);
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU desNeuron: " + destNeuronIndexPrint[i]);
LOG4CPLUS_INFO(consoleLogger, message);
int currType = (int)typePrint[i];
message = (" GPU type: " + to_string(currType));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU psr: " + to_string(psrPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU in_use:" + inUsePrint[i]);
LOG4CPLUS_INFO(consoleLogger, message);

message = (" GPU decay: " + to_string(decayPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU tau: " + to_string(tauPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU total_delay: " + totalDelayPrint[i]);
LOG4CPLUS_INFO(consoleLogger, message);

message = (" GPU lastSpike: " + lastSpikePrint[i]);
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU r: " + to_string(rPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU u: " + to_string(uPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU D: " + to_string(DPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU U: " + to_string(UPrint[i]));
LOG4CPLUS_INFO(consoleLogger, message);
message = (" GPU F: " + to_string(FPrint[i]) + "\n");
LOG4CPLUS_INFO(consoleLogger, message);
}
}

Expand Down
13 changes: 7 additions & 6 deletions Simulator/Edges/Neuro/AllDynamicSTDPSynapses.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ void AllDynamicSTDPSynapses::changePSR(BGSIZE iEdg, BGFLOAT deltaT)
void AllDynamicSTDPSynapses::printSynapsesProps() const
{
AllSTDPSynapses::printSynapsesProps();
log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) {
if (W_[i] != 0.0) {
cout << "lastSpike[" << i << "] = " << lastSpike_[i];
cout << " r: " << r_[i];
cout << " u: " << u_[i];
cout << " D: " << D_[i];
cout << " U: " << U_[i];
cout << " F: " << F_[i] << endl;
LOG4CPLUS_TRACE(consoleLogger, "lastSpike[" << i << "] = " << lastSpike_[i]);
LOG4CPLUS_TRACE(consoleLogger, " r: " << r_[i]);
LOG4CPLUS_TRACE(consoleLogger, " u: " << u_[i]);
LOG4CPLUS_TRACE(consoleLogger, " D: " << D_[i]);
LOG4CPLUS_TRACE(consoleLogger, " U: " << U_[i]);
LOG4CPLUS_TRACE(consoleLogger, " F: " << F_[i] << endl);
}
}
}
69 changes: 35 additions & 34 deletions Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,48 +344,49 @@ void AllDynamicSTDPSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const
HANDLE_ERROR(
cudaMemcpy(FPrint, allSynapsesProps.F_, size * sizeof(BGFLOAT), cudaMemcpyDeviceToHost));

log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) {
if (WPrint[i] != 0.0) {
cout << "GPU W[" << i << "] = " << WPrint[i];
cout << " GPU sourNeuron: " << sourceNeuronIndexPrint[i];
cout << " GPU desNeuron: " << destNeuronIndexPrint[i];
cout << " GPU type: " << typePrint[i];
cout << " GPU psr: " << psrPrint[i];
cout << " GPU in_use:" << (inUsePrint[i] == 1 ? "true" : "false");

cout << " GPU decay: " << decayPrint[i];
cout << " GPU tau: " << tauPrint[i];
cout << " GPU total_delay: " << totalDelayPrint[i];

cout << " GPU total_delayPost: " << totalDelayPostPrint[i];
cout << " GPU tauspost_: " << tauspost_Print[i];
cout << " GPU tauspre_: " << tauspre_Print[i];
cout << " GPU taupos_: " << taupos_Print[i];
cout << " GPU tauneg_: " << tauneg_Print[i];
cout << " GPU STDPgap_: " << STDPgap_Print[i];
cout << " GPU Wex_: " << Wex_Print[i];
cout << " GPU Aneg_: " << Aneg_Print[i];
cout << " GPU Apos_: " << Apos_Print[i];
cout << " GPU mupos_: " << mupos_Print[i];
cout << " GPU muneg_: " << muneg_Print[i];
cout << " GPU useFroemkeDanSTDP_: " << useFroemkeDanSTDP_Print[i];

cout << " GPU lastSpike: " << lastSpikePrint[i];
cout << " GPU r: " << rPrint[i];
cout << " GPU u: " << uPrint[i];
cout << " GPU D: " << DPrint[i];
cout << " GPU U: " << UPrint[i];
cout << " GPU F: " << FPrint[i] << endl;
LOG4CPLUS_INFO(consoleLogger, "GPU W[" << i << "] = " << WPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU sourNeuron: " << sourceNeuronIndexPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU desNeuron: " << destNeuronIndexPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU type: " << typePrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU psr: " << psrPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU in_use:" << (inUsePrint[i] == 1 ? "true" : "false"));

LOG4CPLUS_INFO(consoleLogger, " GPU decay: " << decayPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU tau: " << tauPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU total_delay: " << totalDelayPrint[i]);

LOG4CPLUS_INFO(consoleLogger, " GPU total_delayPost: " << totalDelayPostPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU tauspost_: " << tauspost_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU tauspre_: " << tauspre_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU taupos_: " << taupos_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU tauneg_: " << tauneg_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU STDPgap_: " << STDPgap_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU Wex_: " << Wex_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU Aneg_: " << Aneg_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU Apos_: " << Apos_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU mupos_: " << mupos_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU muneg_: " << muneg_Print[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU useFroemkeDanSTDP_: " << useFroemkeDanSTDP_Print[i]);

LOG4CPLUS_INFO(consoleLogger, " GPU lastSpike: " << lastSpikePrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU r: " << rPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU u: " << uPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU D: " << DPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU U: " << UPrint[i]);
LOG4CPLUS_INFO(consoleLogger, " GPU F: " << FPrint[i] << endl);
}
}

for (int i = 0; i < countVertices_; i++) {
cout << "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl;
LOG4CPLUS_INFO(consoleLogger, "GPU edge_counts:" << "neuron[" << i << "]" << synapseCountsPrint[i] << endl);
}

cout << "GPU totalSynapseCount:" << totalSynapseCountPrint << endl;
cout << "GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl;
cout << "GPU countVertices_:" << countNeuronsPrint << endl;
LOG4CPLUS_INFO(consoleLogger, "GPU totalSynapseCount:" << totalSynapseCountPrint << endl);
LOG4CPLUS_INFO(consoleLogger, "GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl);
LOG4CPLUS_INFO(consoleLogger, "GPU countVertices_:" << countNeuronsPrint << endl);


// Set countVertices_ to 0 to avoid illegal memory deallocation
Expand Down
24 changes: 13 additions & 11 deletions Simulator/Edges/Neuro/AllNeuroEdges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,25 @@ int AllNeuroEdges::edgSign(const edgeType type)
/// Prints SynapsesProps data to console.
void AllNeuroEdges::printSynapsesProps() const
{
cout << "This is SynapsesProps data:" << endl;
log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console"));
LOG4CPLUS_TRACE(consoleLogger, "This is SynapsesProps data:" << endl);
for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) {
if (W_[i] != 0.0) {
cout << "W[" << i << "] = " << W_[i];
cout << " sourNeuron: " << sourceVertexIndex_[i];
cout << " desNeuron: " << destVertexIndex_[i];
cout << " type: " << type_[i];
cout << " psr: " << psr_[i];
cout << " in_use:" << (inUse_[i] == 1 ? "true" : "false");
string message = "W[" + to_string(i) + "] = " + to_string(W_[i]) + "\n";
LOG4CPLUS_TRACE(consoleLogger, message);
LOG4CPLUS_TRACE(consoleLogger, " sourNeuron: " << sourceVertexIndex_[i]);
LOG4CPLUS_TRACE(consoleLogger, " desNeuron: " << destVertexIndex_[i]);
LOG4CPLUS_TRACE(consoleLogger, " type: " << type_[i]);
LOG4CPLUS_TRACE(consoleLogger, " psr: " << psr_[i]);
LOG4CPLUS_TRACE(consoleLogger, " in_use:" << (inUse_[i] == 1 ? "true" : "false"));
}
}

for (int i = 0; i < countVertices_; i++) {
cout << "edge_counts:" << "vertex[" << i << "]" << edgeCounts_[i] << endl;
LOG4CPLUS_TRACE(consoleLogger, "edge_counts:" << "vertex[" << i << "]" << edgeCounts_[i] << endl);
}

cout << "totalEdgeCount:" << totalEdgeCount_ << endl;
cout << "maxEdgesPerVertex:" << maxEdgesPerVertex_ << endl;
cout << "count_neurons:" << countVertices_ << endl;
LOG4CPLUS_TRACE(consoleLogger, "totalEdgeCount:" << totalEdgeCount_ << endl);
LOG4CPLUS_TRACE(consoleLogger, "maxEdgesPerVertex:" << maxEdgesPerVertex_ << endl);
LOG4CPLUS_TRACE(consoleLogger, "count_neurons:" << countVertices_ << endl);
}
Loading
Loading