Skip to content
Snippets Groups Projects
Commit 10ece6ad authored by Jan David Mol's avatar Jan David Mol
Browse files

Task #3696: Replaced GPUProc/Delays by latest version from IONProc, and force...

Task #3696: Replaced GPUProc/Delays by latest version from IONProc, and force the use of SAP 0 to fix RTCP.cc
parent fa878e40
No related branches found
No related tags found
No related merge requests found
...@@ -18,12 +18,13 @@ ...@@ -18,12 +18,13 @@
//# along with this program; if not, write to the Free Software //# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//# //#
//# $Id: Delays.cc 17975 2011-05-10 09:52:51Z mol $ //# $Id: Delays.cc 23195 2012-12-06 16:01:41Z mol $
//# Always #include <lofar_config.h> first! //# Always #include <lofar_config.h> first!
#include <lofar_config.h> #include <lofar_config.h>
#include <Delays.h> #include <Delays.h>
#include <Scheduling.h>
#include <Common/LofarLogger.h> #include <Common/LofarLogger.h>
#include <Common/PrettyUnits.h> #include <Common/PrettyUnits.h>
#include <Interface/Exceptions.h> #include <Interface/Exceptions.h>
...@@ -53,22 +54,29 @@ Delays::Delays(const Parset &parset, const string &stationName, const TimeStamp ...@@ -53,22 +54,29 @@ Delays::Delays(const Parset &parset, const string &stationName, const TimeStamp
itsParset(parset), itsParset(parset),
stop(false), stop(false),
// we need an extra entry for the central beam // we need an extra entry for the central beam
itsBuffer(bufferSize, parset.nrBeams(), parset.nrTABs() + 1), itsBuffer(bufferSize, parset.nrBeams(), parset.maxNrTABs() + 1),
head(0), head(0),
tail(0), tail(0),
bufferFree(bufferSize), bufferFree(bufferSize),
bufferUsed(0), bufferUsed(0),
itsNrCalcDelays(parset.nrCalcDelays()), itsNrCalcDelays(parset.nrCalcDelays()),
itsNrBeams(parset.nrBeams()), itsNrBeams(parset.nrBeams()),
itsMaxNrTABs(parset.maxNrTABs()),
itsNrTABs(parset.nrTABs()), itsNrTABs(parset.nrTABs()),
itsDirectionType(MDirection::J2000),
itsStartTime(startTime), itsStartTime(startTime),
itsNrSamplesPerSec(parset.nrSamplesPerSubband()), itsNrSamplesPerSec(parset.nrSamplesPerSubband()),
itsSampleDuration(parset.sampleDuration()), itsSampleDuration(parset.sampleDuration()),
itsStationName(stationName), itsStationName(stationName),
itsDelayTimer("delay producer", true, true), itsDelayTimer("delay producer", true, true)
itsThread(this, &Delays::mainLoop, "[DelayCompensation] ")
{ {
// FIXME: call from outside this class
start();
}
void Delays::start()
{
itsThread = new Thread(this, &Delays::mainLoop, "[DelayCompensation] ");
} }
...@@ -115,15 +123,28 @@ void Delays::init() ...@@ -115,15 +123,28 @@ void Delays::init()
// Set the position for the itsFrame. // Set the position for the itsFrame.
itsFrame.set(itsPhaseCentre); itsFrame.set(itsPhaseCentre);
// Set-up the conversion engine, using reference direction ITRF. // Set-up the conversion engines, using reference direction ITRF.
itsConverter = new MDirection::Convert(itsDirectionType, MDirection::Ref(MDirection::ITRF, itsFrame)); for (unsigned beam = 0; beam < itsNrBeams; beam++) {
const casa::MDirection::Types &dirtype = itsDirectionTypes[beam];
if (itsConverters.find(dirtype) == itsConverters.end())
itsConverters[dirtype] = MDirection::Convert(dirtype, MDirection::Ref(MDirection::ITRF, itsFrame));
}
} }
void Delays::mainLoop() void Delays::mainLoop()
{ {
#if defined HAVE_BGP_ION
doNotRunOnCore0();
#endif
LOG_DEBUG("Delay compensation thread running"); LOG_DEBUG("Delay compensation thread running");
#if defined HAVE_BGP_ION
runOnCore0();
#endif
init(); init();
// the current time, in samples // the current time, in samples
...@@ -153,13 +174,14 @@ void Delays::mainLoop() ...@@ -153,13 +174,14 @@ void Delays::mainLoop()
// For each given direction in the sky ... // For each given direction in the sky ...
for (uint b = 0; b < itsNrBeams; b ++) { for (uint b = 0; b < itsNrBeams; b ++) {
for (uint p = 0; p < itsNrTABs + 1; p ++) { MDirection::Convert &converter = itsConverters[itsDirectionTypes[b]];
for (uint p = 0; p < itsNrTABs[b] + 1; p ++) {
// Define the astronomical direction as a J2000 direction. // Define the astronomical direction as a J2000 direction.
MVDirection &sky = itsBeamDirections[b][p]; MVDirection &sky = itsBeamDirections[b][p];
// Convert this direction, using the conversion engine. // Convert this direction, using the conversion engine.
MDirection dir = (*itsConverter)(sky); MDirection dir = converter(sky);
// Add to the return vector // Add to the return vector
itsBuffer[tail][b][p] = dir.getValue(); itsBuffer[tail][b][p] = dir.getValue();
...@@ -184,6 +206,10 @@ void Delays::mainLoop() ...@@ -184,6 +206,10 @@ void Delays::mainLoop()
bufferUsed.up(itsNrCalcDelays); bufferUsed.up(itsNrCalcDelays);
} }
} catch (AipsError &ex) { } catch (AipsError &ex) {
// trigger getNextDelays and force it to stop
stop = true;
bufferUsed.up(1);
THROW(GPUProcException, "AipsError: " << ex.what()); THROW(GPUProcException, "AipsError: " << ex.what());
} }
...@@ -193,18 +219,23 @@ void Delays::mainLoop() ...@@ -193,18 +219,23 @@ void Delays::mainLoop()
void Delays::getNextDelays(Matrix<MVDirection> &directions, Matrix<double> &delays) void Delays::getNextDelays(Matrix<MVDirection> &directions, Matrix<double> &delays)
{ {
ASSERTSTR(directions.num_elements() == itsNrBeams * (itsNrTABs + 1), ASSERTSTR(directions.num_elements() == itsNrBeams * (itsMaxNrTABs + 1),
directions.num_elements() << " == " << itsNrBeams << "*" << (itsNrTABs + 1)); directions.num_elements() << " == " << itsNrBeams << "*" << (itsMaxNrTABs + 1));
ASSERTSTR(delays.num_elements() == itsNrBeams * (itsMaxNrTABs + 1),
delays.num_elements() << " == " << itsNrBeams << "*" << (itsMaxNrTABs + 1));
ASSERTSTR(delays.num_elements() == itsNrBeams * (itsNrTABs + 1), ASSERT(itsThread);
delays.num_elements() << " == " << itsNrBeams << "*" << (itsNrTABs + 1));
bufferUsed.down(); bufferUsed.down();
if (stop)
THROW(GPUProcException, "Cannot obtain delays -- delay thread stopped running");
// copy the directions at itsBuffer[head] into the provided buffer, // copy the directions at itsBuffer[head] into the provided buffer,
// and calculate the respective delays // and calculate the respective delays
for (unsigned b = 0; b < itsNrBeams; b ++) { for (unsigned b = 0; b < itsNrBeams; b ++) {
for (unsigned p = 0; p < itsNrTABs + 1; p ++) { for (unsigned p = 0; p < itsNrTABs[b] + 1; p ++) {
const MVDirection &dir = itsBuffer[head][b][p]; const MVDirection &dir = itsBuffer[head][b][p];
directions[b][p] = dir; directions[b][p] = dir;
...@@ -222,39 +253,33 @@ void Delays::getNextDelays(Matrix<MVDirection> &directions, Matrix<double> &dela ...@@ -222,39 +253,33 @@ void Delays::getNextDelays(Matrix<MVDirection> &directions, Matrix<double> &dela
void Delays::setBeamDirections(const Parset &parset) void Delays::setBeamDirections(const Parset &parset)
{ {
const BeamCoordinates& pencilBeams = parset.pencilBeams();
// TODO: For now, we include pencil beams for all regular beams, // TODO: For now, we include pencil beams for all regular beams,
// and use the pencil beam offsets as offsets in J2000. // and use the pencil beam offsets as offsets in J2000.
// To do the coordinates properly, the offsets should be applied // To do the coordinates properly, the offsets should be applied
// in today's coordinates (JMEAN/JTRUE?), not J2000. // in today's coordinates (JMEAN/JTRUE?), not J2000.
itsBeamDirections.resize(itsNrBeams, itsNrTABs + 1); itsBeamDirections.resize(itsNrBeams, itsMaxNrTABs + 1);
itsDirectionTypes.resize(itsNrBeams);
// We only support beams of the same direction type for now for (unsigned beam = 0; beam < itsNrBeams; beam ++) {
const string type0 = toUpper(parset.getBeamDirectionType(0)); const string type = toUpper(parset.getBeamDirectionType(beam));
for (unsigned beam = 1; beam < itsNrBeams; beam ++) {
const string typeN = toUpper(parset.getBeamDirectionType(beam));
if (type0 != typeN) if (!MDirection::getType(itsDirectionTypes[beam], type))
THROW(GPUProcException, "All beams must use the same coordinate system (beam 0 uses " << type0 << " but beam " << beam << " uses " << typeN << ")"); THROW(GPUProcException, "Beam direction type unknown: " << type);
} }
if (!MDirection::getType(itsDirectionType, type0))
THROW(GPUProcException, "Beam direction type unknown: " << type0);
// Get the source directions from the parameter set. // Get the source directions from the parameter set.
// Split the \a dir vector into separate Direction objects. // Split the \a dir vector into separate Direction objects.
for (unsigned beam = 0; beam < itsNrBeams; beam ++) { for (unsigned beam = 0; beam < itsNrBeams; beam ++) {
const vector<double> beamDir = parset.getBeamDirection(beam); const vector<double> beamDir = parset.getBeamDirection(beam);
const BeamCoordinates& TABs = parset.TABs(beam);
// add central beam coordinates for non-beamforming pipelines // add central beam coordinates for non-beamforming pipelines
itsBeamDirections[beam][0] = MVDirection(beamDir[0], beamDir[1]); itsBeamDirections[beam][0] = MVDirection(beamDir[0], beamDir[1]);
for (unsigned pencil = 0; pencil < itsNrTABs; pencil ++) { for (unsigned pencil = 0; pencil < itsNrTABs[beam]; pencil ++) {
// obtain pencil coordinate // obtain pencil coordinate
const BeamCoord3D &pencilCoord = pencilBeams[pencil]; const BeamCoord3D &pencilCoord = TABs[pencil];
// apply angle modification // apply angle modification
const double angle1 = beamDir[0] + pencilCoord[0]; const double angle1 = beamDir[0] + pencilCoord[0];
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
//# along with this program; if not, write to the Free Software //# along with this program; if not, write to the Free Software
//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//# //#
//# $Id: Delays.h 17975 2011-05-10 09:52:51Z mol $ //# $Id: Delays.h 23195 2012-12-06 16:01:41Z mol $
#ifndef LOFAR_GPUPROC_DELAYS_H #ifndef LOFAR_GPUPROC_DELAYS_H
#define LOFAR_GPUPROC_DELAYS_H #define LOFAR_GPUPROC_DELAYS_H
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
//# Never #include <config.h> or #include <lofar_config.h> in a header file! //# Never #include <config.h> or #include <lofar_config.h> in a header file!
//# Includes //# Includes
#include "Common/Timer.h" #include <Common/Timer.h>
#include "Interface/MultiDimArray.h" #include <Interface/MultiDimArray.h>
#include "Interface/Parset.h" #include <Interface/Parset.h>
#include "Interface/RSPTimeStamp.h" #include <Interface/RSPTimeStamp.h>
#include "Interface/SmartPtr.h" #include <Interface/SmartPtr.h>
#include "Common/Thread/Semaphore.h" #include <Common/Thread/Semaphore.h>
#include "Common/Thread/Thread.h" #include <Common/Thread/Thread.h>
#include <measures/Measures/MeasConvert.h> #include <measures/Measures/MeasConvert.h>
#include <measures/Measures/MDirection.h> #include <measures/Measures/MDirection.h>
...@@ -83,8 +83,10 @@ class Delays ...@@ -83,8 +83,10 @@ class Delays
Delays(const Parset &ps, const string &stationName, const TimeStamp &startTime); Delays(const Parset &ps, const string &stationName, const TimeStamp &startTime);
~Delays(); ~Delays();
void start();
// get the set of directions (ITRF) and delays for the beams, for the next CN integration time // get the set of directions (ITRF) and delays for the beams, for the next CN integration time
// Both matrices must have dimensions [itsNrBeams][itsNrTABs+1] // Both matrices must have dimensions [itsNrBeams][itsMaxNrTABs+1]
void getNextDelays(Matrix<casa::MVDirection> &directions, Matrix<double> &delays); void getNextDelays(Matrix<casa::MVDirection> &directions, Matrix<double> &delays);
private: private:
...@@ -132,9 +134,10 @@ class Delays ...@@ -132,9 +134,10 @@ class Delays
// Beam info. // Beam info.
const unsigned itsNrBeams; const unsigned itsNrBeams;
const unsigned itsNrTABs; const unsigned itsMaxNrTABs;
casa::MDirection::Types itsDirectionType; const std::vector<unsigned> itsNrTABs;
Matrix<casa::MVDirection> itsBeamDirections; // [itsNrBeams][itsNrTABs+1] Vector<casa::MDirection::Types> itsDirectionTypes;
Matrix<casa::MVDirection> itsBeamDirections; // [itsNrBeams][itsMaxNrTABs+1]
// Sample timings. // Sample timings.
const TimeStamp itsStartTime; const TimeStamp itsStartTime;
...@@ -144,7 +147,7 @@ class Delays ...@@ -144,7 +147,7 @@ class Delays
// Station Name. // Station Name.
const string itsStationName; const string itsStationName;
casa::MeasFrame itsFrame; casa::MeasFrame itsFrame;
SmartPtr<casa::MDirection::Convert> itsConverter; std::map<casa::MDirection::Types, casa::MDirection::Convert> itsConverters;
// Station phase centre. // Station phase centre.
casa::MPosition itsPhaseCentre; casa::MPosition itsPhaseCentre;
...@@ -154,7 +157,7 @@ class Delays ...@@ -154,7 +157,7 @@ class Delays
NSTimer itsDelayTimer; NSTimer itsDelayTimer;
Thread itsThread; SmartPtr<Thread> itsThread;
}; };
} // namespace RTCP } // namespace RTCP
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment