From 0bc4b73306bdbcc3d40d4e7f7ad8daa756e1405e Mon Sep 17 00:00:00 2001 From: Alexander van Amesfoort <amesfoort@astron.nl> Date: Tue, 27 May 2014 09:51:17 +0000 Subject: [PATCH] Task #4804: more build fixes. Move metadata init string back into GPUProcIO, as we need the parset. --- RTCP/Cobalt/OutputProc/src/GPUProcIO.cc | 29 +++++++++++--- RTCP/Cobalt/OutputProc/src/GPUProcIO.h | 6 +-- RTCP/Cobalt/OutputProc/src/outputProc.cc | 49 ++++++++---------------- 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc b/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc index db4adb37f29..8b2a32e1997 100644 --- a/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc +++ b/RTCP/Cobalt/OutputProc/src/GPUProcIO.cc @@ -21,7 +21,8 @@ //# Always #include <lofar_config.h> first! #include <lofar_config.h> -#include <string> +#include "GPUProcIO.h" + #include <vector> #include <omp.h> #include <boost/format.hpp> @@ -30,9 +31,14 @@ #include <Common/StringUtil.h> #include <Common/Exceptions.h> #include <Stream/PortBroker.h> +#include <ApplCommon/PVSSDatapointDefs.h> +#include <ApplCommon/StationInfo.h> +#include <MACIO/RTmetadata.h> #include <CoInterface/Exceptions.h> #include <CoInterface/Parset.h> +#include <CoInterface/FinalMetaData.h> #include <CoInterface/Stream.h> +#include <CoInterface/SmartPtr.h> #include "SubbandWriter.h" #include "OutputThread.h" @@ -44,10 +50,23 @@ using boost::format; namespace LOFAR { namespace Cobalt { -bool process(Stream &controlStream, const string& myHostName) +bool process(Stream &controlStream, unsigned myRank) { bool success(true); 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 @@ -65,8 +84,8 @@ bool process(Stream &controlStream, const string& myHostName) if (parset.settings.correlator.files[fileIdx].location.host != myHostName) continue; - string logPrefix = boost::str(boost::format("[obs %u correlated stream %3u] ") - % parset.observationID() % fileIdx); + string logPrefix = str(format("[obs %u correlated stream %3u] ") + % parset.observationID() % fileIdx); SubbandWriter *writer = new SubbandWriter(parset, fileIdx, logPrefix); subbandWriters.push_back(writer); @@ -107,7 +126,7 @@ bool process(Stream &controlStream, const string& myHostName) collectors[fileIdx] = new TABTranspose::BlockCollector( *outputPools[fileIdx], fileIdx, nrSubbands, nrChannels, nrSamples, parset.nrBeamFormedBlocks(), parset.realTime() ? 5 : 0); - string logPrefix = boost::str(boost::format("[obs %u beamformed stream %3u] ") + string logPrefix = str(format("[obs %u beamformed stream %3u] ") % parset.observationID() % fileIdx); TABOutputThread *writer = new TABOutputThread(parset, fileIdx, *outputPools[fileIdx], logPrefix); diff --git a/RTCP/Cobalt/OutputProc/src/GPUProcIO.h b/RTCP/Cobalt/OutputProc/src/GPUProcIO.h index 0358302f110..e2aa7f70964 100644 --- a/RTCP/Cobalt/OutputProc/src/GPUProcIO.h +++ b/RTCP/Cobalt/OutputProc/src/GPUProcIO.h @@ -24,11 +24,7 @@ //# Never #include <config.h> or #include <lofar_config.h> in a header file! #include <string> -#include <vector> - #include <Stream/Stream.h> -#include <CoInterface/SmartPtr.h> -#include <CoInterface/FinalMetaData.h> namespace LOFAR { @@ -44,7 +40,7 @@ namespace LOFAR // * Call writeFeedbackLTA to obtain the LTA feedback from all writers, // and write it to GPUProc. // \return \c true upon success, \c false upon failure. - bool process(Stream &controlStream, const std::string& myHostName); + bool process(Stream &controlStream, unsigned myRank); } // namespace Cobalt } // namespace LOFAR diff --git a/RTCP/Cobalt/OutputProc/src/outputProc.cc b/RTCP/Cobalt/OutputProc/src/outputProc.cc index 14a61ce3e00..113dda17fbf 100644 --- a/RTCP/Cobalt/OutputProc/src/outputProc.cc +++ b/RTCP/Cobalt/OutputProc/src/outputProc.cc @@ -28,14 +28,10 @@ #include <omp.h> #include <boost/format.hpp> #include <boost/lexical_cast.hpp> - #include <Common/LofarLogger.h> #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> @@ -46,12 +42,13 @@ #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; + +// install a new handler to produce backtraces for bad_alloc +LOFAR::NewHandler h(LOFAR::BadAllocException::newHandler); // Use a terminate handler that can produce a backtrace. Exception::TerminateHandler t(Exception::terminate); @@ -76,46 +73,36 @@ static void usage(const char *argv0) int main(int argc, char *argv[]) { - INIT_LOGGER("outputProc"); // also attaches to CasaLogSink - - // 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)); - - LOG_INFO_STR("OutputProc version " << OutputProcVersion::getVersion() << " r" << OutputProcVersion::getRevision()); + setvbuf(stdout, stdoutbuf, _IOLBF, sizeof stdoutbuf); + setvbuf(stderr, stderrbuf, _IOLBF, sizeof stderrbuf); int opt; while ((opt = getopt(argc, argv, "h")) != -1) { switch (opt) { case 'h': usage(argv[0]); - exit(0); + exit(EXIT_SUCCESS); default: /* '?' */ usage(argv[0]); - exit(1); + exit(EXIT_FAILURE); } } - if (argc != 3) - { + if (argc != 3) { usage(argv[0]); return EXIT_FAILURE; } - - setvbuf(stdout, stdoutbuf, _IOLBF, sizeof stdoutbuf); - setvbuf(stderr, stderrbuf, _IOLBF, sizeof stderrbuf); - omp_set_nested(true); + INIT_LOGGER("outputProc"); // also attaches to CasaLogSink LOG_DEBUG_STR("Started: " << argv[0] << ' ' << argv[1] << ' ' << argv[2]); + LOG_INFO_STR("OutputProc version " << OutputProcVersion::getVersion() << " r" << OutputProcVersion::getRevision()); int observationID = boost::lexical_cast<int>(argv[1]); - size_t myRank = boost::lexical_cast<size_t>(argv[2]); + unsigned myRank = boost::lexical_cast<unsigned>(argv[2]); + + omp_set_nested(true); setIOpriority(); setRTpriority(); @@ -123,15 +110,11 @@ int main(int argc, char *argv[]) PortBroker::createInstance(storageBrokerPort(observationID)); - // retrieve the parset + // retrieve control stream to receive the parset and report back string resource = getStorageControlDescription(observationID, myRank); PortBroker::ServerStream controlStream(resource); - const vector<string> &hostnames = parset.settings.outputProcHosts; - ASSERT(myRank < hostnames.size()); - string myHostName = hostnames[myRank]; - - if (process(controlStream, myHostName)) { + if (process(controlStream, myRank)) { LOG_INFO("Program terminated succesfully"); return EXIT_SUCCESS; } else { -- GitLab