diff --git a/Simulator/Connections/Neuro/ConnGrowth.cpp b/Simulator/Connections/Neuro/ConnGrowth.cpp index 01cf3fa4b..a333fec4e 100644 --- a/Simulator/Connections/Neuro/ConnGrowth.cpp +++ b/Simulator/Connections/Neuro/ConnGrowth.cpp @@ -303,6 +303,6 @@ void ConnGrowth::updateSynapsesWeights() void ConnGrowth::printRadii() const { for (int i = 0; i < radiiSize_; i++) { - cout << "radii[" << i << "] = " << radii_[i] << endl; + LOG4CPLUS_TRACE(consoleLogger_, ("radii[" << i << "] = " << radii_[i] << endl)); } } diff --git a/Simulator/Connections/Neuro/ConnGrowth.h b/Simulator/Connections/Neuro/ConnGrowth.h index 0a4c87ffc..e090647b0 100644 --- a/Simulator/Connections/Neuro/ConnGrowth.h +++ b/Simulator/Connections/Neuro/ConnGrowth.h @@ -216,7 +216,7 @@ template void ConnGrowth::load(Archive &archive, std::uint32_t c // check to see if serialized data size matches object size if (radiiSize != radiiSize_ || radiiSize != radiiVector.size()) { - cerr << "Failed deserializing radii. Please verify totalVertices data member." << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed deserializing radii. Please verify totalVertices data member." << endl); throw cereal::Exception("Deserialization Error"); } diff --git a/Simulator/Core/Core.cpp b/Simulator/Core/Core.cpp index b1bb14567..50b1550b7 100644 --- a/Simulator/Core/Core.cpp +++ b/Simulator/Core/Core.cpp @@ -45,6 +45,10 @@ using namespace std; /// @returns true if successful, false otherwise. bool Core::parseCommandLine(string executableName, string cmdLineArguments) { + + // Get the instance of the console logger + log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console")); + ParamContainer cl; // todo: note as third party class. cl.initOptions(false); // don't allow unknown parameters cl.setHelpString(string( @@ -69,7 +73,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" << endl)); return false; } @@ -80,7 +84,8 @@ bool Core::parseCommandLine(string executableName, string cmdLineArguments) } if (cl["version"].compare("") != 0) { - cout << "Git commit ID: " << GIT_COMMIT_ID << endl; + + LOG4CPLUS_TRACE(consoleLogger, ("Git commit ID: " << GIT_COMMIT_ID << endl)); exit(0); } @@ -213,8 +218,8 @@ 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; + LOG4CPLUS_TRACE(consoleLogger, "time simulated: " << simulator.getEpochDuration() * simulator.getNumEpochs() << endl); + LOG4CPLUS_TRACE(consoleLogger, "time elapsed: " << timeElapsed << endl); + LOG4CPLUS_TRACE(consoleLogger, "ssps (simulation seconds / real time seconds): " << ssps << endl); return 0; } diff --git a/Simulator/Core/Model.cpp b/Simulator/Core/Model.cpp index b7d950df3..c0e57050e 100644 --- a/Simulator/Core/Model.cpp +++ b/Simulator/Core/Model.cpp @@ -113,7 +113,8 @@ void Model::logSimStep() const if (pConnGrowth == nullptr) return; - cout << "format:\ntype,radius,firing rate" << endl; + LOG4CPLUS_TRACE(consoleLogger_, ("format:\ntype,radius,firing rate" << endl)); + for (int y = 0; y < Simulator::getInstance().getHeight(); y++) { stringstream ss; @@ -152,7 +153,7 @@ void Model::logSimStep() const } ss << endl; - cout << ss.str(); + LOG4CPLUS_TRACE(consoleLogger_, ss.str()); } } diff --git a/Simulator/Core/Serializer.cpp b/Simulator/Core/Serializer.cpp index c40b2d4b0..ad15d8391 100644 --- a/Simulator/Core/Serializer.cpp +++ b/Simulator/Core/Serializer.cpp @@ -38,7 +38,7 @@ bool Serializer::deserializeSynapses() // Checks to see if serialization file exists if (!memory_in) { - cerr << "The serialization file doesn't exist" << endl; + LOG4CPLUS_ERROR(fileLogger_, "The serialization file doesn't exist" << endl); return false; } @@ -55,9 +55,9 @@ bool Serializer::deserializeSynapses() try { archive(dynamic_cast(connections.getEdges())); } catch (cereal::Exception e) { - cerr << e.what() << endl + LOG4CPLUS_ERROR(fileLogger_, e.what() << endl << "Failed to deserialize synapse weights, source vertices, and/or destination vertices." - << endl; + << endl); return false; } @@ -88,7 +88,7 @@ bool Serializer::deserializeSynapses() try { archive(dynamic_cast(connections)); } catch (cereal::Exception e) { - cerr << e.what() << endl << "Failed to deserialize radii." << endl; + LOG4CPLUS_ERROR(fileLogger_, e.what() << endl << "Failed to deserialize radii." << endl); return false; } @@ -102,10 +102,13 @@ void Serializer::serializeSynapses() { Simulator &simulator = Simulator::getInstance(); + // Get the instance of the console logger + 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(); + LOG4CPLUS_TRACE(consoleLogger, ("PLease find the serialized file in " << simulator.getSerializationFileName().c_str())); // Options parameter are optional which sets // 1. Sets the Preceision of floating point number to 30 diff --git a/Simulator/Core/Simulator.cpp b/Simulator/Core/Simulator.cpp index 466aaae73..e469ce62d 100644 --- a/Simulator/Core/Simulator.cpp +++ b/Simulator/Core/Simulator.cpp @@ -46,13 +46,13 @@ void Simulator::setup() { #ifdef PERFORMANCE_METRICS // Start overall simulation timer - cerr << "Starting main timer... "; + LOG4CPLUS_ERROR(fileLogger_, "Starting main timer... "); t_host_initialization_layout = 0.0; t_host_initialization_connections = 0.0; t_host_advance = 0.0; t_host_adjustEdges = 0.0; timer.start(); - cerr << "done." << endl; + LOG4CPLUS_ERROR(fileLogger_, "done." << endl); #endif LOG4CPLUS_INFO(fileLogger_, "Initializing models in network... "); model_->setupSim(); @@ -181,9 +181,9 @@ 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" << endl)); printPerformanceMetrics(total_time, currentEpoch); - cout << endl; + LOG4CPLUS_TRACE(consoleLogger_, endl); #endif } LOG4CPLUS_TRACE(workbenchLogger_, "Complete"); diff --git a/Simulator/Edges/AllEdges.h b/Simulator/Edges/AllEdges.h index a080cbcc7..b3a7ac1e8 100644 --- a/Simulator/Edges/AllEdges.h +++ b/Simulator/Edges/AllEdges.h @@ -264,23 +264,20 @@ template void AllEdges::load(Archive &archive, std::uint32_t con // check to see if serialized data sizes matches object sizes int requiredSize = maxEdgesPerVertex_ * countVertices_; if (WVectorSize != requiredSize || WVectorSize != WVector.size()) { - cerr - << "Failed deserializing edge weights. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." - << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed deserializing edge weights. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." + << endl); throw cereal::Exception("Deserialization Error"); } if (sourceVertexLayoutIndexVectorSize != requiredSize || sourceVertexLayoutIndexVectorSize != sourceVertexLayoutIndexVector.size()) { - cerr - << "Failed deserializing source vertices. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." - << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed deserializing source vertices. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." + << endl); throw cereal::Exception("Deserialization Error"); } if (destVertexLayoutIndexVectorSize != requiredSize || destVertexLayoutIndexVectorSize != destVertexLayoutIndexVector.size()) { - cerr - << "Failed deserializing destination vertices. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." - << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed deserializing destination vertices. Please verify maxEdgesPerVertex and count_neurons data members in AllEdges class." + << endl); throw cereal::Exception("Deserialization Error"); } diff --git a/Simulator/Edges/Neuro/AllDSSynapses.cpp b/Simulator/Edges/Neuro/AllDSSynapses.cpp index 9193986fe..6f0e8be6d 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses.cpp @@ -190,13 +190,14 @@ void AllDSSynapses::printSynapsesProps() const AllSpikingSynapses::printSynapsesProps(); 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_INFO(consoleLogger, ("lastSpike[" << i << "] = " << lastSpike_[i])); + LOG4CPLUS_INFO(consoleLogger, (" r: " << r_[i])); + LOG4CPLUS_INFO(consoleLogger, (" u: " << u_[i])); + LOG4CPLUS_INFO(consoleLogger, (" D: " << D_[i])); + LOG4CPLUS_INFO(consoleLogger, (" U: " << U_[i])); + LOG4CPLUS_INFO(consoleLogger, (" F: " << F_[i] << endl)); } } - cout << endl; + LOG4CPLUS_INFO(consoleLogger, endl); } diff --git a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp index efbb2f278..a6a8b0ade 100644 --- a/Simulator/Edges/Neuro/AllDSSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDSSynapses_d.cpp @@ -305,34 +305,35 @@ void AllDSSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const 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]; - - 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; + 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])); + + 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 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 diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.cpp index 9ca1ae547..f82cb2daa 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses.cpp @@ -190,12 +190,13 @@ void AllDynamicSTDPSynapses::printSynapsesProps() const AllSTDPSynapses::printSynapsesProps(); 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)); } } } diff --git a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp index 63673945c..94151d1d6 100644 --- a/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllDynamicSTDPSynapses_d.cpp @@ -341,50 +341,52 @@ void AllDynamicSTDPSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const cudaMemcpy(UPrint, allSynapsesProps.U_, size * sizeof(BGFLOAT), cudaMemcpyDeviceToHost)); HANDLE_ERROR( cudaMemcpy(FPrint, allSynapsesProps.F_, size * sizeof(BGFLOAT), cudaMemcpyDeviceToHost)); - + 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]; - - 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_TRACE(consoleLogger_, ("GPU W[" << i << "] = " << WPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU sourNeuron: " << sourceNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU desNeuron: " << destNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU type: " << typePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU psr: " << psrPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU in_use:" << inUsePrint[i])); + + LOG4CPLUS_TRACE(consoleLogger_, (" GPU decay: " << decayPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tau: " << tauPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU total_delay: " << totalDelayPrint[i])); + + LOG4CPLUS_TRACE(consoleLogger_, (" GPU total_delayPost: " << totalDelayPostPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauspost_: " << tauspost_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauspre_: " << tauspre_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU taupos_: " << taupos_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauneg_: " << tauneg_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU STDPgap_: " << STDPgap_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Wex_: " << Wex_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Aneg_: " << Aneg_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Apos_: " << Apos_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU mupos_: " << mupos_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU muneg_: " << muneg_Print[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU useFroemkeDanSTDP_: " << useFroemkeDanSTDP_Print[i])); + + LOG4CPLUS_TRACE(consoleLogger_, (" GPU lastSpike: " << lastSpikePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU r: " << rPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU u: " << uPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU D: " << DPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU U: " << UPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU F: " << FPrint[i] << endl)); } } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" - << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + LOG4CPLUS_TRACE(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_TRACE(consoleLogger_, ("GPU totalSynapseCount:" << totalSynapseCountPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU countVertices_:" << countNeuronsPrint << endl)); + + // Set countVertices_ to 0 to avoid illegal memory deallocation diff --git a/Simulator/Edges/Neuro/AllNeuroEdges.cpp b/Simulator/Edges/Neuro/AllNeuroEdges.cpp index f04023dbb..2e3843df9 100644 --- a/Simulator/Edges/Neuro/AllNeuroEdges.cpp +++ b/Simulator/Edges/Neuro/AllNeuroEdges.cpp @@ -100,29 +100,30 @@ int AllNeuroEdges::edgSign(const edgeType type) /// Prints SynapsesProps data to console. void AllNeuroEdges::printSynapsesProps() const { - cout << "This is SynapsesProps data:" << endl; + 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]; + LOG4CPLUS_TRACE(consoleLogger, ("W[" << i << "] = " << W_[i])); + 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])); + if (summationPoint_[i] != nullptr) { - cout << " summationPoint: is created!" << endl; + LOG4CPLUS_TRACE(consoleLogger, (" summationPoint: is created!" << endl)); } else { - cout << " summationPoint: is EMPTY!!!!!" << endl; + LOG4CPLUS_TRACE(consoleLogger, (" summationPoint: is EMPTY!!!!!" << endl)); } } } 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)); } diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses.cpp index 92e7f355b..311465314 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses.cpp @@ -539,17 +539,18 @@ void AllSTDPSynapses::printSynapsesProps() const AllSpikingSynapses::printSynapsesProps(); for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) { if (W_[i] != 0.0) { - cout << "total_delayPost[" << i << "] = " << totalDelayPost_[i]; - cout << " tauspost_: " << tauspost_[i]; - cout << " tauspre_: " << tauspre_[i]; - cout << " taupos_: " << taupos_[i]; - cout << " tauneg_: " << tauneg_[i]; - cout << " STDPgap_: " << STDPgap_[i]; - cout << " Wex_: " << Wex_[i]; - cout << " Aneg_: " << Aneg_[i]; - cout << " Apos_: " << Apos_[i]; - cout << " mupos_: " << mupos_[i]; - cout << " muneg_: " << muneg_[i] << endl; + + LOG4CPLUS_TRACE(consoleLogger_, ("total_delayPost[" << i << "] = " << totalDelayPost_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" tauspost_: " << tauspost_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" tauspre_: " << tauspre_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" taupos_: " << taupos_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" tauneg_: " << tauneg_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" STDPgap_: " << STDPgap_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" Wex_: " << Wex_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" Aneg_: " << Aneg_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" Apos_: " << Apos_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" mupos_: " << mupos_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" muneg_: " << muneg_[i] << endl)); } } } diff --git a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp index 9859a9c1e..4dce1f32a 100644 --- a/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSTDPSynapses_d.cpp @@ -380,39 +380,42 @@ void AllSTDPSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const cudaMemcpyDeviceToHost)); HANDLE_ERROR(cudaMemcpy(munegPrint, allSynapsesProps.muneg_, size * sizeof(BGFLOAT), cudaMemcpyDeviceToHost)); + 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]; - - 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_: " << tauspostPrint[i]; - cout << " GPU tauspre_: " << tausprePrint[i]; - cout << " GPU taupos_: " << tauposPrint[i]; - cout << " GPU tauneg_: " << taunegPrint[i]; - cout << " GPU STDPgap_: " << STDPgapPrint[i]; - cout << " GPU Wex_: " << WexPrint[i]; - cout << " GPU Aneg_: " << AnegPrint[i]; - cout << " GPU Apos_: " << AposPrint[i]; - cout << " GPU mupos_: " << muposPrint[i]; - cout << " GPU muneg_: " << munegPrint[i] << endl; + LOG4CPLUS_TRACE(consoleLogger_, ("GPU W[" << i << "] = " << WPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU sourNeuron: " << sourceNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU desNeuron: " << destNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU type: " << typePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU psr: " << psrPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU in_use:" << inUsePrint[i])); + + LOG4CPLUS_TRACE(consoleLogger_, (" GPU decay: " << decayPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tau: " << tauPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU total_delay: " << totalDelayPrint[i])); + + LOG4CPLUS_TRACE(consoleLogger_, (" GPU total_delayPost: " << totalDelayPostPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauspost_: " << tauspostPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauspre_: " << tausprePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU taupos_: " << tauposPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tauneg_: " << taunegPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU STDPgap_: " << STDPgapPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Wex_: " << WexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Aneg_: " << AnegPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU Apos_: " << AposPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU mupos_: " << muposPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU muneg_: " << munegPrint[i] << endl)); + + } } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" - << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + LOG4CPLUS_TRACE(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_TRACE(consoleLogger_, ("GPU totalSynapseCount:" << totalSynapseCountPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU countVertices_:" << countNeuronsPrint << endl)); // Set countVertices_ to 0 to avoid illegal memory deallocation // at AllDSSynapsesProps deconstructor. diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses.cpp index 7ae1850ee..c5caf9bd1 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses.cpp @@ -341,9 +341,10 @@ void AllSpikingSynapses::printSynapsesProps() const AllNeuroEdges::printSynapsesProps(); for (int i = 0; i < maxEdgesPerVertex_ * countVertices_; i++) { if (W_[i] != 0.0) { - cout << "decay[" << i << "] = " << decay_[i]; - cout << " tau: " << tau_[i]; - cout << " total_delay: " << totalDelay_[i] << endl; + + LOG4CPLUS_TRACE(consoleLogger_, ("decay[" << i << "] = " << decay_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" tau: " << tau_[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" total_delay: " << totalDelay_[i] << endl)); } } } diff --git a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp index 41849dadd..8e43c8028 100644 --- a/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp +++ b/Simulator/Edges/Neuro/AllSpikingSynapses_d.cpp @@ -399,25 +399,26 @@ void AllSpikingSynapses::printGPUEdgesProps(void *allEdgesDeviceProps) const 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]; - cout << " GPU decay: " << decayPrint[i]; - cout << " GPU tau: " << tauPrint[i]; - cout << " GPU total_delay: " << totalDelayPrint[i] << endl; + LOG4CPLUS_TRACE(consoleLogger_, ("GPU W[" << i << "] = " << WPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU sourNeuron: " << sourceNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU desNeuron: " << destNeuronIndexPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU type: " << typePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU psr: " << psrPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU in_use:" << inUsePrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU decay: " << decayPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU tau: " << tauPrint[i])); + LOG4CPLUS_TRACE(consoleLogger_, (" GPU total_delay: " << totalDelayPrint[i] << endl)); ; } } for (int i = 0; i < countVertices_; i++) { - cout << "GPU edge_counts:" - << "neuron[" << i << "]" << synapseCountsPrint[i] << endl; + LOG4CPLUS_TRACE(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_TRACE(consoleLogger_, ("GPU totalSynapseCount:" << totalSynapseCountPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU maxEdgesPerVertex:" << maxEdgesPerVertexPrint << endl)); + LOG4CPLUS_TRACE(consoleLogger_, ("GPU countVertices_:" << countNeuronsPrint << endl)); + // Set countVertices_ to 0 to avoid illegal memory deallocation // at AllDSSynapsesProps deconstructor. allSynapsesProps.countVertices_ = 0; diff --git a/Simulator/Utils/Global.cpp b/Simulator/Utils/Global.cpp index 9a68b7264..5cd99506b 100644 --- a/Simulator/Utils/Global.cpp +++ b/Simulator/Utils/Global.cpp @@ -62,7 +62,7 @@ string neuronTypeToString(vertexType t) case EXC: return "EXC"; default: - cerr << "ERROR->neuronTypeToString() failed, unknown type: " << t << endl; + LOG4CPLUS_ERROR(fileLogger_, "ERROR->neuronTypeToString() failed, unknown type: " << t << endl); assert(false); return nullptr; // Must return a value -- this will probably cascade to another failure } @@ -101,33 +101,39 @@ double t_gpu_calcSummation; void printPerformanceMetrics(const float total_time, int steps) { - cout << "t_gpu_rndGeneration: " << t_gpu_rndGeneration << " ms (" - << t_gpu_rndGeneration / total_time * 100 << "%)" << endl; - cout << "t_gpu_advanceNeurons: " << t_gpu_advanceNeurons << " ms (" - << t_gpu_advanceNeurons / total_time * 100 << "%)" << endl; - cout << "t_gpu_advanceSynapses: " << t_gpu_advanceSynapses << " ms (" - << t_gpu_advanceSynapses / total_time * 100 << "%)" << endl; - cout << "t_gpu_calcSummation: " << t_gpu_calcSummation << " ms (" - << t_gpu_calcSummation / total_time * 100 << "%)" << endl; + // Get the instance of the console logger + log4cplus::Logger consoleLogger = log4cplus::Logger::getInstance(LOG4CPLUS_TEXT("console")); - cout << "\nHost initialization (layout): " << t_host_initialization_layout << " seconds (" - << t_host_initialization_layout / total_time * 100 << "%)" << endl; - cout << "\nHost initialization (connections): " << t_host_initialization_connections - << " seconds (" << t_host_initialization_connections / total_time * 100 << "%)" << endl; + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_rndGeneration: " << t_gpu_rndGeneration << " ms (" + << t_gpu_rndGeneration / total_time * 100 << "%)" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_advanceNeurons: " << t_gpu_advanceNeurons << " ms (" + << t_gpu_advanceNeurons / total_time * 100 << "%)" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_advanceSynapses: " << t_gpu_advanceSynapses << " ms (" + << t_gpu_advanceSynapses / total_time * 100 << "%)" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_calcSummation: " << t_gpu_calcSummation << " ms (" + << t_gpu_calcSummation / total_time * 100 << "%)" << endl)); - cout << "\nHost advance: " << t_host_advance << " seconds (" << t_host_advance / total_time * 100 - << "%)" << endl; + LOG4CPLUS_TRACE(consoleLogger, ("\nHost initialization (layout): " << t_host_initialization_layout << " seconds (" + << t_host_initialization_layout / total_time * 100 << "%)" << endl)); - cout << "\nHost adjustEdges: " << t_host_adjustEdges << " seconds (" - << t_host_adjustEdges / total_time * 100 << "%)" << endl; + LOG4CPLUS_TRACE(consoleLogger, ("\nHost initialization (connections): " << t_host_initialization_connections + << " seconds (" << t_host_initialization_connections / total_time * 100 << "%)" << endl)); + + LOG4CPLUS_TRACE(consoleLogger, ("\nHost advance: " << t_host_advance << " seconds (" << t_host_advance / total_time * 100 + << "%)" << endl)); + + LOG4CPLUS_TRACE(consoleLogger, ("\nHost adjustEdges: " << t_host_adjustEdges << " seconds (" + << t_host_adjustEdges / total_time * 100 << "%)" << endl)); + + LOG4CPLUS_TRACE(consoleLogger, ("\nAverage time per simulation epoch:" << endl)); + + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_rndGeneration: " << t_gpu_rndGeneration / steps << " ms/epoch" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_advanceNeurons: " << t_gpu_advanceNeurons / steps << " ms/epoch" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_advanceSynapses: " << t_gpu_advanceSynapses / steps << " ms/epoch" << endl)); + LOG4CPLUS_TRACE(consoleLogger, ("t_gpu_calcSummation: " << t_gpu_calcSummation / steps << " ms/epoch" << endl)); - cout << "\nAverage time per simulation epoch:" << endl; - cout << "t_gpu_rndGeneration: " << t_gpu_rndGeneration / steps << " ms/epoch" << endl; - cout << "t_gpu_advanceNeurons: " << t_gpu_advanceNeurons / steps << " ms/epoch" << endl; - cout << "t_gpu_advanceSynapses: " << t_gpu_advanceSynapses / steps << " ms/epoch" << endl; - cout << "t_gpu_calcSummation: " << t_gpu_calcSummation / steps << " ms/epoch" << endl; } #endif // PERFORMANCE_METRICS diff --git a/Simulator/Utils/GraphManager.cpp b/Simulator/Utils/GraphManager.cpp index 5d90a1675..72e74c80c 100644 --- a/Simulator/Utils/GraphManager.cpp +++ b/Simulator/Utils/GraphManager.cpp @@ -26,13 +26,13 @@ bool GraphManager::readGraph() // string file_name; string path = "//graphmlFile/text()"; if (!ParameterManager::getInstance().getStringByXpath(path, graphFilePath_)) { - cerr << "Could not find XML path: " << path << ".\n"; + LOG4CPLUS_ERROR(fileLogger_, "Could not find XML path: " << path << ".\n"); return false; }; graph_file.open(graphFilePath_.c_str()); if (!graph_file.is_open()) { - cerr << "Failed to open file: " << graphFilePath_ << ".\n"; + LOG4CPLUS_ERROR(fileLogger_, "Failed to open file: " << graphFilePath_ << ".\n"); return false; } diff --git a/Simulator/Utils/Inputs/FSInput.cpp b/Simulator/Utils/Inputs/FSInput.cpp index 5a7fad68c..54c09cf44 100644 --- a/Simulator/Utils/Inputs/FSInput.cpp +++ b/Simulator/Utils/Inputs/FSInput.cpp @@ -29,18 +29,20 @@ ISInput *FSInput::CreateInstance() // load stimulus input file TiXmlDocument siDoc(Simulator::getInstance().getStimulusFileName().c_str()); if (!siDoc.LoadFile()) { - cerr << "Failed loading stimulus input file " + LOG4CPLUS_ERROR(fileLogger_, "Failed loading stimulus input file " << Simulator::getInstance().getStimulusFileName() << ":" - << "\n\t" << siDoc.ErrorDesc() << endl; - cerr << " error: " << siDoc.ErrorRow() << ", " << siDoc.ErrorCol() << endl; + << "\n\t" << siDoc.ErrorDesc() << endl); + + LOG4CPLUS_ERROR(fileLogger_, " error: " << siDoc.ErrorRow() << ", " << siDoc.ErrorCol() << endl); return nullptr; } // load input parameters TiXmlElement *parms = nullptr; if ((parms = siDoc.FirstChildElement("InputParams")) == nullptr) { - cerr << "Could not find in stimulus input file " - << Simulator::getInstance().getStimulusFileName() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Could not find in stimulus input file " + << Simulator::getInstance().getStimulusFileName() << endl); + return nullptr; } @@ -49,11 +51,11 @@ ISInput *FSInput::CreateInstance() string name; if ((temp = parms->FirstChildElement("IMethod")) != nullptr) { if (temp->QueryValueAttribute("name", &name) != TIXML_SUCCESS) { - cerr << "error IMethod:name" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IMethod:name" << endl); return nullptr; } } else { - cerr << "missing IMethod" << endl; + LOG4CPLUS_ERROR(fileLogger_, "missing IMethod" << endl); return nullptr; } @@ -73,7 +75,7 @@ ISInput *FSInput::CreateInstance() pInput = new HostSInputPoisson(parms); #endif } else { - cerr << "unsupported stimulus input method" << endl; + LOG4CPLUS_ERROR(fileLogger_, "unsupported stimulus input method" << endl); } return pInput; diff --git a/Simulator/Utils/Inputs/SInputPoisson.cpp b/Simulator/Utils/Inputs/SInputPoisson.cpp index 21b2a9d17..97cd23d81 100644 --- a/Simulator/Utils/Inputs/SInputPoisson.cpp +++ b/Simulator/Utils/Inputs/SInputPoisson.cpp @@ -25,15 +25,15 @@ SInputPoisson::SInputPoisson(TiXmlElement *parms) : if ((temp = parms->FirstChildElement("IntParams")) != nullptr) { if (temp->QueryFLOATAttribute("fr_mean", &fr_mean) != TIXML_SUCCESS) { - cerr << "error IntParams:fr_mean" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IntParams:fr_mean" << endl); return; } if (temp->QueryFLOATAttribute("weight", &weight) != TIXML_SUCCESS) { - cerr << "error IntParams:weight" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IntParams:weight" << endl); return; } } else { - cerr << "missing IntParams" << endl; + LOG4CPLUS_ERROR(fileLogger_, "missing IntParams" << endl); return; } @@ -66,16 +66,17 @@ SInputPoisson::SInputPoisson(TiXmlElement *parms) : == TIXML_SUCCESS) { TiXmlDocument simDoc(maskNListFileName.c_str()); if (!simDoc.LoadFile()) { - cerr << "Failed loading positions of stimulus input mask neurons list file " + LOG4CPLUS_ERROR(fileLogger_, "Failed loading positions of stimulus input mask neurons list file " << maskNListFileName << ":" - << "\n\t" << simDoc.ErrorDesc() << endl; - cerr << " error: " << simDoc.ErrorRow() << ", " << simDoc.ErrorCol() << endl; + << "\n\t" << simDoc.ErrorDesc() << endl); + + LOG4CPLUS_ERROR(fileLogger_, " error: " << simDoc.ErrorRow() << ", " << simDoc.ErrorCol() << endl); break; } TiXmlNode *temp2 = nullptr; if ((temp2 = simDoc.FirstChildElement("M")) == nullptr) { - cerr << "Could not find in positons of stimulus input mask neurons list file " - << maskNListFileName << endl; + LOG4CPLUS_ERROR(fileLogger_, "Could not find in positons of stimulus input mask neurons list file " + << maskNListFileName << endl); break; } getValueList(temp2->ToElement()->GetText(), &maskIndex); diff --git a/Simulator/Utils/Inputs/SInputRegular.cpp b/Simulator/Utils/Inputs/SInputRegular.cpp index e264ab091..77b25c83a 100644 --- a/Simulator/Utils/Inputs/SInputRegular.cpp +++ b/Simulator/Utils/Inputs/SInputRegular.cpp @@ -26,19 +26,19 @@ SInputRegular::SInputRegular(TiXmlElement *parms) : values(nullptr) string sync; if ((temp = parms->FirstChildElement("IntParams")) != nullptr) { if (temp->QueryFLOATAttribute("duration", &duration) != TIXML_SUCCESS) { - cerr << "error IntParams:duration" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IntParams:duration" << endl); return; } if (temp->QueryFLOATAttribute("interval", &interval) != TIXML_SUCCESS) { - cerr << "error IntParams:interval" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IntParams:interval" << endl); return; } if (temp->QueryValueAttribute("sync", &sync) != TIXML_SUCCESS) { - cerr << "error IntParams:sync" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error IntParams:sync" << endl); return; } } else { - cerr << "missing IntParams" << endl; + LOG4CPLUS_ERROR(fileLogger_, "missing IntParams" << endl); return; } @@ -55,12 +55,12 @@ SInputRegular::SInputRegular(TiXmlElement *parms) : values(nullptr) if (strcmp(pNode->Value(), "I") == 0) { getValueList(pNode->ToElement()->GetText(), &initValues); } else { - cerr << "error I" << endl; + LOG4CPLUS_ERROR(fileLogger_, "error I" << endl); return; } } } else { - cerr << "missing Values" << endl; + LOG4CPLUS_ERROR(fileLogger_, "missing Values" << endl); return; } diff --git a/Simulator/Utils/Matrix/MatrixFactory.cpp b/Simulator/Utils/Matrix/MatrixFactory.cpp index 19e535ed8..b44505fdf 100644 --- a/Simulator/Utils/Matrix/MatrixFactory.cpp +++ b/Simulator/Utils/Matrix/MatrixFactory.cpp @@ -34,7 +34,7 @@ void MatrixFactory::GetAttributes(TiXmlElement *matElement, string &type, string const char *temp = nullptr; #ifdef MDEBUG - cerr << "Getting attributes:" << endl; + LOG4CPLUS_ERROR(fileLogger_, "Getting attributes:" << endl); #endif temp = matElement->Attribute("type"); if (temp != nullptr) @@ -44,26 +44,26 @@ void MatrixFactory::GetAttributes(TiXmlElement *matElement, string &type, string if ((type != "diag") && (type != "complete") && (type != "sparse")) throw KII_invalid_argument("Illegal matrix type: " + type); #ifdef MDEBUG - cerr << "\ttype=" << type << ", "; + LOG4CPLUS_ERROR(fileLogger_, "\ttype=" << type << ", "); #endif if (matElement->QueryIntAttribute("rows", &rows) != TIXML_SUCCESS) throw KII_invalid_argument("Number of rows not specified for Matrix."); #ifdef MDEBUG - cerr << "\trows=" << rows << ", "; + LOG4CPLUS_ERROR(fileLogger_, "\trows=" << rows << ", "); #endif if (matElement->QueryIntAttribute("columns", &columns) != TIXML_SUCCESS) throw KII_invalid_argument("Number of columns not specified for Matrix."); #ifdef MDEBUG - cerr << "\tcolumns=" << columns << ", "; + LOG4CPLUS_ERROR(fileLogger_, "\tcolumns=" << columns << ", "); #endif if (matElement->QueryFLOATAttribute("multiplier", &multiplier) != TIXML_SUCCESS) { multiplier = 1.0; } #ifdef MDEBUG - cerr << "\tmultiplier=" << multiplier << ", "; + LOG4CPLUS_ERROR(fileLogger_, "\tmultiplier=" << multiplier << ", "); #endif temp = matElement->Attribute("init"); @@ -72,7 +72,7 @@ void MatrixFactory::GetAttributes(TiXmlElement *matElement, string &type, string else init = "none"; #ifdef MDEBUG - cerr << "\tinit=" << init << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tinit=" << init << endl); #endif } @@ -99,8 +99,8 @@ Matrix *MatrixFactory::CreateMatrix(TiXmlElement *matElement) GetAttributes(matElement, type, init, rows, columns, multiplier); #ifdef MDEBUG - cerr << "Creating Matrix with attributes: " << type << ", " << init << ", " << rows << "X" - << columns << ", " << multiplier << endl; + LOG4CPLUS_ERROR(fileLogger_, "Creating Matrix with attributes: " << type << ", " << init << ", " << rows << "X" + << columns << ", " << multiplier << endl); #endif if (init == "implementation") @@ -116,7 +116,7 @@ Matrix *MatrixFactory::CreateMatrix(TiXmlElement *matElement) throw KII_invalid_argument("Contents not specified for Matrix with init='none'."); values = valuesNode->Value(); #ifdef MDEBUG - cerr << "\tData present for initialization: " << values << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tData present for initialization: " << values << endl); #endif } if ((rows > 1) && (columns > 1)) // Create a 2D Matrix @@ -131,7 +131,7 @@ Matrix *MatrixFactory::CreateMatrix(TiXmlElement *matElement) "Contents not specified for Sparse Matrix with init='none'."); const char *values = valuesNode->Value(); #ifdef MDEBUG - cerr << "\tData present for initialization: " << values << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tData present for initialization: " << values << endl); #endif theMatrix = new SparseMatrix(rows, columns, multiplier, values); } else if (init == "const") { // No string of values or XML row data @@ -178,8 +178,8 @@ VectorMatrix MatrixFactory::CreateVector(TiXmlElement *matElement) GetAttributes(matElement, type, init, rows, columns, multiplier); #ifdef VDEBUG - cerr << "Creating Vector with attributes: " << type << ", " << init << ", " << rows << "X" - << columns << ", " << multiplier << endl; + LOG4CPLUS_ERROR(fileLogger_, "Creating Vector with attributes: " << type << ", " << init << ", " << rows << "X" + << columns << ", " << multiplier << endl); #endif // Get the Text node that contains the matrix values, if needed @@ -190,7 +190,7 @@ VectorMatrix MatrixFactory::CreateVector(TiXmlElement *matElement) values = valuesNode->Value(); #ifdef VDEBUG - cerr << "\tData present for initialization: " << values << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tData present for initialization: " << values << endl); #endif } else if (init == "implementation") throw KII_invalid_argument( @@ -234,8 +234,8 @@ CompleteMatrix MatrixFactory::CreateComplete(TiXmlElement *matElement) GetAttributes(matElement, type, init, rows, columns, multiplier); #ifdef MDEBUG - cerr << "Creating Matrix with attributes: " << type << ", " << init << ", " << rows << "X" - << columns << ", " << multiplier << endl; + LOG4CPLUS_ERROR(fileLogger_, "Creating Matrix with attributes: " << type << ", " << init << ", " << rows << "X" + << columns << ", " << multiplier << endl); #endif // Get the Text node that contains the matrix values, if needed @@ -246,7 +246,7 @@ CompleteMatrix MatrixFactory::CreateComplete(TiXmlElement *matElement) values = valuesNode->Value(); #ifdef MDEBUG - cerr << "\tData present for initialization: " << values << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tData present for initialization: " << values << endl); #endif } else if (init == "implementation") throw KII_invalid_argument( @@ -281,8 +281,8 @@ SparseMatrix MatrixFactory::CreateSparse(TiXmlElement *matElement) GetAttributes(matElement, type, init, rows, columns, multiplier); #ifdef MDEBUG - cerr << "Creating SparseMatrix with attributes: " << type << ", " << init << ", " << rows << "X" - << columns << ", " << multiplier << endl; + LOG4CPLUS_ERROR(fileLogger_, "Creating SparseMatrix with attributes: " << type << ", " << init << ", " << rows << "X" + << columns << ", " << multiplier << endl); #endif if (type == "diag") { @@ -293,7 +293,7 @@ SparseMatrix MatrixFactory::CreateSparse(TiXmlElement *matElement) "Contents not specified for Sparese Matrix with init='none'."); const char *values = valuesNode->Value(); #ifdef MDEBUG - cerr << "\tData present for initialization: " << values << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tData present for initialization: " << values << endl); #endif return SparseMatrix(rows, columns, multiplier, values); } else if (init == "const") { // No string of values or XML row data diff --git a/Simulator/Utils/Matrix/SparseMatrix.cpp b/Simulator/Utils/Matrix/SparseMatrix.cpp index 0aaf82364..e81395912 100644 --- a/Simulator/Utils/Matrix/SparseMatrix.cpp +++ b/Simulator/Utils/Matrix/SparseMatrix.cpp @@ -249,7 +249,7 @@ SparseMatrix::SparseMatrix(int r, int c, BGFLOAT m, const char *v) : try { theElements.insert(el); } catch (Matrix_invalid_argument e) { - cerr << "Failure during SparseMatrix string constructor: " << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failure during SparseMatrix string constructor: " << e.what() << endl); exit(-1); } } @@ -263,7 +263,7 @@ SparseMatrix::SparseMatrix(int r, int c, BGFLOAT m, const char *v) : try { theElements.insert(el); } catch (Matrix_invalid_argument e) { - cerr << "Failure during SparseMatrix multiplier only constructor: " << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failure during SparseMatrix multiplier only constructor: " << e.what() << endl); exit(-1); } } @@ -325,8 +325,8 @@ SparseMatrix::SparseMatrix(const SparseMatrix &oldM) : try { copy(oldM); } catch (Matrix_invalid_argument e) { - cerr << "Failure during SparseMatrix copy constructor\n" - << "\tError was: " << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failure during SparseMatrix copy constructor\n" + << "\tError was: " << e.what() << endl); exit(-1); } } @@ -360,8 +360,8 @@ SparseMatrix &SparseMatrix::operator=(const SparseMatrix &rhs) try { copy(rhs); } catch (Matrix_invalid_argument e) { - cerr << "\tFailure during SparseMatrix assignment operator\n" - << "\tError was: " << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "\tFailure during SparseMatrix assignment operator\n" + << "\tError was: " << e.what() << endl); exit(-1); } DEBUG_SPARSE(cerr << "\t\tcopy() complete; returning by reference." << endl;) @@ -427,12 +427,12 @@ void SparseMatrix::copy(const SparseMatrix &source) try { theElements.insert(el); } catch (Matrix_invalid_argument e) { - cerr << "\nFailure during SparseMatrix copy() for element " << el->value << " at (" - << el->row << "," << el->column << ")" << endl; - cerr << "\twith " << theElements.size << " elements already copied at i=" << i + LOG4CPLUS_ERROR(fileLogger_, "\nFailure during SparseMatrix copy() for element " << el->value << " at (" + << el->row << "," << el->column << ")" << endl); + LOG4CPLUS_ERROR(fileLogger_, "\twith " << theElements.size << " elements already copied at i=" << i << ", hashed to " << theElements.hash(el) << " in table with capacity " - << theElements.capacity << endl; - cerr << "\tSource was: " << source << endl << endl; + << theElements.capacity << endl); + LOG4CPLUS_ERROR(fileLogger_, "\tSource was: " << source << endl << endl); throw e; } } @@ -464,7 +464,7 @@ void SparseMatrix::rowFromXML(TiXmlElement *rowElement) try { theElements.insert(el); } catch (Matrix_invalid_argument e) { - cerr << "Failure during SparseMatrix rowFromXML: " << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failure during SparseMatrix rowFromXML: " << e.what() << endl); exit(-1); } } @@ -561,8 +561,8 @@ BGFLOAT &SparseMatrix::operator()(int r, int c) try { theElements.insert(el); } catch (Matrix_invalid_argument e) { - cerr << "Failure during SparseMatrix operator() at row " << r << " column " << c << ": " - << e.what() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failure during SparseMatrix operator() at row " << r << " column " << c << ": " + << e.what() << endl); exit(-1); } } diff --git a/Simulator/Utils/ParameterManager.cpp b/Simulator/Utils/ParameterManager.cpp index a213b23f5..8466de72f 100644 --- a/Simulator/Utils/ParameterManager.cpp +++ b/Simulator/Utils/ParameterManager.cpp @@ -55,10 +55,13 @@ bool ParameterManager::loadParameterFile(string path) // load the XML document xmlDocument_.reset(new TiXmlDocument(path.c_str())); if (!xmlDocument_->LoadFile()) { - cerr << "Failed loading simulation parameter file " << path << ":" - << "\n\t" << xmlDocument_->ErrorDesc() << endl; - cerr << " error row: " << xmlDocument_->ErrorRow() - << ", error col: " << xmlDocument_->ErrorCol() << endl; + + LOG4CPLUS_ERROR(fileLogger_, "Failed loading simulation parameter file " << path << ":" + << "\n\t" << xmlDocument_->ErrorDesc() << endl); + LOG4CPLUS_ERROR(fileLogger_, " error row: " << xmlDocument_->ErrorRow() + << ", error col: " << xmlDocument_->ErrorCol() << endl); + + return false; } // assign the document root_ object @@ -94,7 +97,8 @@ bool ParameterManager::getStringByXpath(string xpath, string &referenceVar) string temp; // raise error if tinyxml cannot compute the xpath's value or returns empty if (!TinyXPath::o_xpath_string(root_, xpath.c_str(), temp) || temp == "") { - cerr << "Failed loading simulation parameter for xpath " << xpath << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed loading simulation parameter for xpath " << xpath << endl); + return false; } referenceVar = temp; @@ -119,22 +123,22 @@ bool ParameterManager::getIntByXpath(string xpath, int &referenceVar) // Workaround for standard value conversion functions. // stoi() will cast floats to ints. if (regex_match(tmp, regex("\\d+[.]\\d+(e[+-]?\\d+)?f?|\\d+[.]?\\d+(e[+-]?\\d+)?f"))) { - cerr << "Parsed parameter is likely a float/double value. " - << "Terminating integer cast. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter is likely a float/double value. " + << "Terminating integer cast. Value: " << tmp << endl); return false; } else if (regex_match(tmp, regex(".*[^\\def.]+.*"))) { - cerr << "Parsed parameter is likely a string. " - << "Terminating integer cast. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter is likely a string. " + << "Terminating integer cast. Value: " << tmp << endl); return false; } try { referenceVar = stoi(tmp); } catch (invalid_argument &arg_exception) { - cerr << "Parsed parameter could not be parsed as an integer. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter could not be parsed as an integer. Value: " << tmp << endl); return false; } catch (out_of_range &range_exception) { - cerr << "Parsed string parameter could not be converted to an integer. Value: " << tmp - << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed string parameter could not be converted to an integer. Value: " << tmp + << endl); return false; } return true; @@ -156,17 +160,17 @@ bool ParameterManager::getDoubleByXpath(string xpath, double &referenceVar) return false; } if (regex_match(tmp, regex(".*[^\\def.+-]+.*"))) { - cerr << "Parsed parameter is likely a string. " - << "Terminating double conversion. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter is likely a string. " + << "Terminating double conversion. Value: " << tmp << endl); return false; } try { referenceVar = stod(tmp); } catch (invalid_argument &arg_exception) { - cerr << "Parsed parameter could not be parsed as a double. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter could not be parsed as a double. Value: " << tmp << endl); return false; } catch (out_of_range &range_exception) { - cerr << "Parsed string parameter could not be converted to a double. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed string parameter could not be converted to a double. Value: " << tmp << endl); return false; } return true; @@ -188,17 +192,17 @@ bool ParameterManager::getFloatByXpath(string xpath, float &referenceVariable) return false; } if (regex_match(tmp, regex(".*[^\\def.+-]+.*"))) { - cerr << "Parsed parameter is likely a string. " - << "Terminating double conversion. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter is likely a string. " + << "Terminating double conversion. Value: " << tmp << endl); return false; } try { referenceVariable = stof(tmp); } catch (invalid_argument &arg_exception) { - cerr << "Parsed parameter could not be parsed as a float. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter could not be parsed as a float. Value: " << tmp << endl); return false; } catch (out_of_range &range_exception) { - cerr << "Parsed string parameter could not be converted to a float. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed string parameter could not be converted to a float. Value: " << tmp << endl); return false; } return true; @@ -224,7 +228,7 @@ bool ParameterManager::getBGFloatByXpath(string xpath, BGFLOAT &referenceVar) #ifdef DOUBLEPRECISION return getDoubleByXpath(xpath, referenceVar); #endif - cerr << "Could not infer primitive type for BGFLOAT variable." << endl; + LOG4CPLUS_ERROR(fileLogger_, "Could not infer primitive type for BGFLOAT variable." << endl); return false; } @@ -244,17 +248,17 @@ bool ParameterManager::getLongByXpath(string xpath, long &referenceVar) return false; } if (!regex_match(tmp, regex("[\\d]+l?"))) { - cerr << "Parsed parameter is not a valid long format. " - << "Terminating long conversion. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter is not a valid long format. " + << "Terminating long conversion. Value: " << tmp << endl); return false; } try { referenceVar = stol(tmp); } catch (invalid_argument &arg_exception) { - cerr << "Parsed parameter could not be parsed as a long. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed parameter could not be parsed as a long. Value: " << tmp << endl); return false; } catch (out_of_range &range_exception) { - cerr << "Parsed string parameter could not be converted to a long. Value: " << tmp << endl; + LOG4CPLUS_ERROR(fileLogger_, "Parsed string parameter could not be converted to a long. Value: " << tmp << endl); return false; } return true; @@ -278,15 +282,15 @@ bool ParameterManager::getIntVectorByXpath(const string &path, const string &ele // Open file using a local XmlDocument object TiXmlDocument xmlDocument(path.c_str()); if (!xmlDocument.LoadFile()) { - cerr << "Failed to load " << path.c_str() << ":" - << "\n\t" << xmlDocument.ErrorDesc() << endl; + LOG4CPLUS_ERROR(fileLogger_, "Failed to load " << path.c_str() << ":" + << "\n\t" << xmlDocument.ErrorDesc() << endl); return false; } // Check file for matching element TiXmlNode *xmlNode = nullptr; if ((xmlNode = xmlDocument.FirstChildElement(elementName)) == nullptr) { - cerr << "Could not find <" << elementName << "> in vertex list file " << path << endl; + LOG4CPLUS_ERROR(fileLogger_, "Could not find <" << elementName << "> in vertex list file " << path << endl); return false; } @@ -311,14 +315,14 @@ bool ParameterManager::getFileByXpath(const string &path, ifstream &file) { string file_name; if (!ParameterManager::getInstance().getStringByXpath(path, file_name)) { - cerr << "Could not find XML path: " << path << ".\n"; + LOG4CPLUS_ERROR(fileLogger_, "Could not find XML path: " << path << ".\n"); return false; }; // open file file.open(file_name.c_str()); if (!file.is_open()) { - cerr << "Failed to open file: " << file_name << ".\n"; + LOG4CPLUS_ERROR(fileLogger_, "Failed to open file: " << file_name << ".\n"); return false; } diff --git a/Simulator/Utils/RNG/MersenneTwister_d.cu b/Simulator/Utils/RNG/MersenneTwister_d.cu index e90151495..f54bcc413 100644 --- a/Simulator/Utils/RNG/MersenneTwister_d.cu +++ b/Simulator/Utils/RNG/MersenneTwister_d.cu @@ -61,11 +61,11 @@ unsigned int mt_nPerRng; void loadMTGPU(const char *fname){ FILE *fd = fopen(fname, "rb"); if(!fd){ - cerr << "initMTGPU(): failed to open " << fname << endl << "FAILED" << endl; + LOG4CPLUS_ERROR(fileLogger_, "initMTGPU(): failed to open " << fname << endl << "FAILED" << endl); exit(0); } if( !fread(h_MT, mt_rng_count*sizeof(mt_struct_stripped), 1, fd) ){ - cerr << "initMTGPU(): failed to load " << fname << endl << "FAILED" << endl; + LOG4CPLUS_ERROR(fileLogger_, "initMTGPU(): failed to load " << fname << endl << "FAILED" << endl); exit(0); } fclose(fd); @@ -99,7 +99,7 @@ void seedMTGPU(unsigned int seed){ seedMTGPUState<<>>(seed); if(cudaMemcpyToSymbol(ds_MT, MT, mt_rng_count*sizeof(mt_struct_stripped))!=cudaSuccess){ - cerr << "seedMTGP failed" << endl; + LOG4CPLUS_ERROR(fileLogger_, "seedMTGP failed" << endl); exit(0); }