diff --git a/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc b/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc index 751a1ad3e956dcf5d0184368f7ed75781284d15d..58c419c662798d819f2008bced394d2c3a0b6a93 100644 --- a/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc +++ b/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc @@ -1,5 +1,5 @@ //# GPUProcIO.cc: Routines for communicating with GPUProc -//# Copyright (C) 2008-2013 ASTRON (Netherlands Institute for Radio Astronomy) +//# Copyright (C) 2008-2014 ASTRON (Netherlands Institute for Radio Astronomy) //# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands //# //# This file is part of the LOFAR software suite. @@ -21,14 +21,11 @@ //# Always #include <lofar_config.h> first! #include <lofar_config.h> -#include <omp.h> - #include <string> #include <vector> +#include <omp.h> #include <boost/format.hpp> -#include <ApplCommon/PVSSDatapointDefs.h> -#include <ApplCommon/StationInfo.h> #include <Common/LofarLogger.h> #include <Common/StringUtil.h> #include <Common/Exceptions.h> @@ -42,27 +39,13 @@ using namespace LOFAR; using namespace LOFAR::Cobalt; using namespace std; -using boost::format; namespace LOFAR { namespace Cobalt { -void process(Stream &controlStream, size_t myRank) +void process(Stream &controlStream, const string& myHostName) { Parset parset(&controlStream); - - // Send identification string to the MAC Log Processor - string fmtStr(createPropertySetName(PSN_COBALT_OUTPUT_PROC, "", - parset.getString("_DPname"))); - format prFmt; - prFmt.exceptions(boost::io::no_error_bits); // avoid throw - prFmt.parse(fmtStr); - LOG_INFO_STR("MACProcessScope: " << str(prFmt % myRank)); - - const vector<string> &hostnames = parset.settings.outputProcHosts; - ASSERT(myRank < hostnames.size()); - string myHostName = hostnames[myRank]; - { // make sure "parset" stays in scope for the lifetime of the SubbandWriters @@ -80,7 +63,8 @@ void process(Stream &controlStream, size_t myRank) if (parset.settings.correlator.files[fileIdx].location.host != myHostName) continue; - string logPrefix = str(format("[obs %u correlated stream %3u] ") % parset.observationID() % fileIdx); + string logPrefix = boost::str(boost::format("[obs %u correlated stream %3u] ") + % parset.observationID() % fileIdx); SubbandWriter *writer = new SubbandWriter(parset, fileIdx, logPrefix); subbandWriters.push_back(writer); @@ -117,7 +101,8 @@ void process(Stream &controlStream, size_t myRank) collectors[fileIdx] = new TABTranspose::BlockCollector( *outputPools[fileIdx], fileIdx, parset.nrBeamFormedBlocks(), parset.realTime() ? 4 : 0); - string logPrefix = str(format("[obs %u beamformed stream %3u] ") % parset.observationID() % fileIdx); + string logPrefix = boost::str(boost::format("[obs %u beamformed stream %3u] ") + % parset.observationID() % fileIdx); TABOutputThread *writer = new TABOutputThread(parset, fileIdx, *outputPools[fileIdx], logPrefix); tabWriters.push_back(writer); diff --git a/RTCP/Cobalt/OutputProc/src/GPUProcIO.h b/RTCP/Cobalt/OutputProc/src/GPUProcIO.h index ac5ad2b64438b97ef2da042481563622a4236bc1..e0f8e2a7477298314e77ba61401b06bfd353cbfa 100644 --- a/RTCP/Cobalt/OutputProc/src/GPUProcIO.h +++ b/RTCP/Cobalt/OutputProc/src/GPUProcIO.h @@ -1,5 +1,5 @@ //# GPUProcIO.h -//# Copyright (C) 2009-2013 ASTRON (Netherlands Institute for Radio Astronomy) +//# Copyright (C) 2009-2014 ASTRON (Netherlands Institute for Radio Astronomy) //# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands //# //# This file is part of the LOFAR software suite. @@ -43,7 +43,7 @@ namespace LOFAR // and send it to all writers. // * Call writeFeedbackLTA to obtain the LTA feedback from all writers, // and write it to GPUProc. - void process(Stream &controlStream, size_t myRank); + void process(Stream &controlStream, const std::string& myHostName); } // namespace Cobalt } // namespace LOFAR diff --git a/RTCP/Cobalt/OutputProc/src/outputProc.cc b/RTCP/Cobalt/OutputProc/src/outputProc.cc index 65f04c65b2fe32451b9e54128e5753afac3fa800..95c44a70313d75c20886789aed068323a7a3f986 100644 --- a/RTCP/Cobalt/OutputProc/src/outputProc.cc +++ b/RTCP/Cobalt/OutputProc/src/outputProc.cc @@ -1,5 +1,5 @@ //# outputProc.cc -//# Copyright (C) 2008-2013 ASTRON (Netherlands Institute for Radio Astronomy) +//# Copyright (C) 2008-2014 ASTRON (Netherlands Institute for Radio Astronomy) //# P.O. Box 2, 7990 AA Dwingeloo, The Netherlands //# //# This file is part of the LOFAR software suite. @@ -22,10 +22,9 @@ #include <lofar_config.h> #include <cstdio> // for setvbuf -#include <omp.h> - #include <string> #include <stdexcept> +#include <omp.h> #include <boost/format.hpp> #include <boost/lexical_cast.hpp> @@ -33,6 +32,9 @@ #include <Common/CasaLogSink.h> #include <Common/Exceptions.h> #include <Common/NewHandler.h> +#include <ApplCommon/PVSSDatapointDefs.h> +#include <ApplCommon/StationInfo.h> +#include <MACIO/RTmetadata.h> #include <Stream/PortBroker.h> #include <CoInterface/Exceptions.h> #include <CoInterface/Parset.h> @@ -41,18 +43,20 @@ #include "GPUProcIO.h" #include "IOPriority.h" +#define STDLOG_BUFFER_SIZE 1024 + // install a new handler to produce backtraces for bad_alloc LOFAR::NewHandler h(LOFAR::BadAllocException::newHandler); using namespace LOFAR; using namespace LOFAR::Cobalt; using namespace std; -using boost::format; // Use a terminate handler that can produce a backtrace. Exception::TerminateHandler t(Exception::terminate); -char stdoutbuf[1024], stderrbuf[1024]; +static char stdoutbuf[STDLOG_BUFFER_SIZE]; +static char stderrbuf[STDLOG_BUFFER_SIZE]; static void usage(const char *argv0) { @@ -67,16 +71,22 @@ static void usage(const char *argv0) int main(int argc, char *argv[]) { - INIT_LOGGER("outputProc"); + INIT_LOGGER("outputProc"); // also attaches to CasaLogSink - LOG_INFO_STR("OutputProc version " << OutputProcVersion::getVersion() << " r" << OutputProcVersion::getRevision()); + // Send identification string to the MAC Log Processor before other logging + string fmtStr(createPropertySetName(PSN_COBALT_OUTPUT_PROC, "", + parset.getString("_DPname"))); + boost::format prFmt; + prFmt.exceptions(boost::io::no_error_bits); // avoid throw + prFmt.parse(fmtStr); + LOG_INFO_STR("MACProcessScope: " << str(prFmt % myRank)); - CasaLogSink::attach(); + LOG_INFO_STR("OutputProc version " << OutputProcVersion::getVersion() << " r" << OutputProcVersion::getRevision()); if (argc != 3) { usage(argv[0]); - return 1; + return EXIT_FAILURE; } setvbuf(stdout, stdoutbuf, _IOLBF, sizeof stdoutbuf); @@ -99,10 +109,14 @@ int main(int argc, char *argv[]) string resource = getStorageControlDescription(observationID, myRank); PortBroker::ServerStream controlStream(resource); - process(controlStream, myRank); + const vector<string> &hostnames = parset.settings.outputProcHosts; + ASSERT(myRank < hostnames.size()); + string myHostName = hostnames[myRank]; + + process(controlStream, myHostName); LOG_INFO("Program end"); - return 0; + return EXIT_SUCCESS; }