From 76c6524fa2b02f6ca339aa517475f0846f9b67ee Mon Sep 17 00:00:00 2001 From: Alexander van Amesfoort <amesfoort@astron.nl> Date: Tue, 4 Mar 2014 23:37:00 +0000 Subject: [PATCH] Task #4804: move a bit of GPUProcIO.cc code to outputProc.cc, mainly to have the first log indicator early + minor improvements around there. --- RTCP/Cobalt/OutputProc/src/GPUProcIO.cc | 29 +++++-------------- RTCP/Cobalt/OutputProc/src/GPUProcIO.h | 4 +-- RTCP/Cobalt/OutputProc/src/outputProc.cc | 36 ++++++++++++++++-------- 3 files changed, 34 insertions(+), 35 deletions(-) diff --git a/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc b/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc index 751a1ad3e95..58c419c6627 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 ac5ad2b6443..e0f8e2a7477 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 65f04c65b2f..95c44a70313 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; } -- GitLab