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

Task #11406: Statically allocate flagsPerChannel, and removed unused propagateFlags.

parent e55be390
Branches
Tags
No related merge requests found
...@@ -80,7 +80,7 @@ namespace LOFAR ...@@ -80,7 +80,7 @@ namespace LOFAR
void process(const SubbandProcInputData &input); void process(const SubbandProcInputData &input);
private: private:
// Flags for FFT-ed data // Preallocated flags for FFT-ed data -- used locally
MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel; MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel;
//Data members //Data members
......
...@@ -77,31 +77,6 @@ namespace LOFAR ...@@ -77,31 +77,6 @@ namespace LOFAR
{ {
} }
void CorrelatorStep::Flagger::propagateFlags(
Parset const &parset,
MultiDimArray<LOFAR::SparseSet<unsigned>, 1>const &inputFlags,
SubbandProcOutputData::CorrelatedData &output)
{
// Object for storing transformed flags
MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel(
boost::extents[parset.settings.antennaFields.size()]);
// First transform the flags to channel flags: taking in account
// reduced resolution in time and the size of the filter
Cobalt::Flagger::convertFlagsToChannelFlags(
inputFlags,
flagsPerChannel,
parset.settings.blockSize,
parset.settings.correlator.nrChannels,
parset.settings.correlator.nrChannels == 1 ? 0 : NR_TAPS - 1);
// Calculate the number of flags per baseline and assign to
// output object.
calcNrValidSamples(parset, flagsPerChannel, output);
}
namespace { namespace {
// Return the baseline number for a pair of stations // Return the baseline number for a pair of stations
unsigned baseline(unsigned major, unsigned minor) unsigned baseline(unsigned major, unsigned minor)
...@@ -260,6 +235,8 @@ namespace LOFAR ...@@ -260,6 +235,8 @@ namespace LOFAR
: :
ProcessStep(parset, i_queue), ProcessStep(parset, i_queue),
correlatorPPF(ps.settings.correlator.nrChannels > 1), correlatorPPF(ps.settings.correlator.nrChannels > 1),
flagsWithHistorySamples(boost::extents[parset.settings.antennaFields.size()]),
flagsPerChannel(boost::extents[parset.settings.antennaFields.size()]),
devE(context, std::max(factories.correlator.bufferSize(CorrelatorKernel::INPUT_DATA), devE(context, std::max(factories.correlator.bufferSize(CorrelatorKernel::INPUT_DATA),
factories.correlator.bufferSize(CorrelatorKernel::OUTPUT_DATA))), factories.correlator.bufferSize(CorrelatorKernel::OUTPUT_DATA))),
outputCounter(context, "output (correlator)"), outputCounter(context, "output (correlator)"),
...@@ -320,15 +297,13 @@ namespace LOFAR ...@@ -320,15 +297,13 @@ namespace LOFAR
fftKernel->enqueue(input.blockID); fftKernel->enqueue(input.blockID);
// Process flags enough to determine which data to zero // Process flags enough to determine which data to zero
MultiDimArray<LOFAR::SparseSet<unsigned>, 1> flags = input.inputFlags; flagsWithHistorySamples = input.inputFlags;
MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel(
boost::extents[ps.settings.antennaFields.size()]);
firFilterKernel->prefixHistoryFlags( firFilterKernel->prefixHistoryFlags(
flags, input.blockID.subbandProcSubbandIdx); flagsWithHistorySamples, input.blockID.subbandProcSubbandIdx);
Cobalt::Flagger::convertFlagsToChannelFlags( Cobalt::Flagger::convertFlagsToChannelFlags(
flags, flagsWithHistorySamples,
flagsPerChannel, flagsPerChannel,
ps.settings.blockSize, ps.settings.blockSize,
ps.settings.correlator.nrChannels, ps.settings.correlator.nrChannels,
...@@ -366,16 +341,31 @@ namespace LOFAR ...@@ -366,16 +341,31 @@ namespace LOFAR
void CorrelatorStep::processCPU(const SubbandProcInputData &input, SubbandProcOutputData &output) void CorrelatorStep::processCPU(const SubbandProcInputData &input, SubbandProcOutputData &output)
{ {
// Propagate the flags. // Propagate the flags.
MultiDimArray<LOFAR::SparseSet<unsigned>, 1> flags = input.inputFlags;
if (correlatorPPF) { if (correlatorPPF) {
flagsWithHistorySamples = input.inputFlags;
// Put the history flags in front of the sample flags, // Put the history flags in front of the sample flags,
// because Flagger::propagateFlags expects it that way.
firFilterKernel->prefixHistoryFlags( firFilterKernel->prefixHistoryFlags(
flags, input.blockID.subbandProcSubbandIdx); flagsWithHistorySamples, input.blockID.subbandProcSubbandIdx);
}
// Transform the flags to channel flags: taking in account
// reduced resolution in time and the size of the filter
Cobalt::Flagger::convertFlagsToChannelFlags(
flagsWithHistorySamples,
flagsPerChannel,
ps.settings.blockSize,
ps.settings.correlator.nrChannels,
NR_TAPS - 1);
Flagger::propagateFlags(ps, flags, output.correlatedData); // Calculate the number of flags per baseline and assign to
// output object.
Flagger::calcNrValidSamples(ps, flagsPerChannel, output.correlatedData);
} else {
// Calculate the number of flags per baseline and assign to
// output object.
Flagger::calcNrValidSamples(ps, input.inputFlags, output.correlatedData);
}
} }
......
...@@ -95,12 +95,6 @@ namespace LOFAR ...@@ -95,12 +95,6 @@ namespace LOFAR
class Flagger: public Cobalt::Flagger class Flagger: public Cobalt::Flagger
{ {
public: public:
// 1. Convert input flags to channel flags, calculate the amount flagged
// samples and save this in output
static void propagateFlags(Parset const & parset,
MultiDimArray<LOFAR::SparseSet<unsigned>, 1>const &inputFlags,
SubbandProcOutputData::CorrelatedData &output);
// 1.1 Convert the flags per station to channel flags, change time scale // 1.1 Convert the flags per station to channel flags, change time scale
// if nchannel > 1 // if nchannel > 1
// (Uses convertFlagsToChannelFlags) // (Uses convertFlagsToChannelFlags)
...@@ -136,6 +130,12 @@ namespace LOFAR ...@@ -136,6 +130,12 @@ namespace LOFAR
private: private:
const bool correlatorPPF; const bool correlatorPPF;
// Preallocated flags for input data, to prefix with FIR history -- used locally
MultiDimArray<SparseSet<unsigned>, 1> flagsWithHistorySamples;
// Preallocated flags for FFT-ed data -- used locally
MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel;
//Data members //Data members
boost::shared_ptr<gpu::DeviceMemory> devA; boost::shared_ptr<gpu::DeviceMemory> devA;
boost::shared_ptr<gpu::DeviceMemory> devB; boost::shared_ptr<gpu::DeviceMemory> devB;
......
...@@ -142,8 +142,24 @@ TEST(propagateFlags) ...@@ -142,8 +142,24 @@ TEST(propagateFlags)
BudgetTimer processCPUTimer("processCPU", parset.settings.blockDuration() / nrSubbandsPerSubbandProc, true, true); BudgetTimer processCPUTimer("processCPU", parset.settings.blockDuration() / nrSubbandsPerSubbandProc, true, true);
//propageFlags: exercise the functionality
MultiDimArray<LOFAR::SparseSet<unsigned>, 1> flagsPerChannel(boost::extents[parset.settings.antennaFields.size()]);
processCPUTimer.start(); processCPUTimer.start();
CorrelatorStep::Flagger::propagateFlags(parset, flags, correlatedData);
// Compress input flags to flags per channel
Flagger::convertFlagsToChannelFlags(
flags,
flagsPerChannel,
parset.settings.blockSize,
parset.settings.correlator.nrChannels,
// we don't have a FIR history to prepend
0);
// calculate nr of valid samples per baseline
CorrelatorStep::Flagger::calcNrValidSamples(parset, flagsPerChannel, correlatedData);
processCPUTimer.stop(); processCPUTimer.stop();
} }
......
...@@ -87,7 +87,20 @@ TEST(propagateFlags) ...@@ -87,7 +87,20 @@ TEST(propagateFlags)
// ********************************************************************************************* // *********************************************************************************************
//propageFlags: exercise the functionality //propageFlags: exercise the functionality
CorrelatorStep::Flagger::propagateFlags(parset, inputFlags, output); MultiDimArray<SparseSet<unsigned>, 1> flagsPerChannel(boost::extents[parset.settings.antennaFields.size()]);
// Compress input flags to flags per channel
Cobalt::Flagger::convertFlagsToChannelFlags(
inputFlags,
flagsPerChannel,
parset.settings.blockSize,
parset.settings.correlator.nrChannels,
// We don't prepend FIR history, but we need it to obtain the right weights
NR_TAPS - 1);
// calculate nr of valid samples per baseline
CorrelatorStep::Flagger::calcNrValidSamples(parset, flagsPerChannel, output);
// now perform weighting of the data based on the number of valid samples // now perform weighting of the data based on the number of valid samples
CorrelatorStep::Flagger::applyNrValidSamples(parset, *output.subblocks[0]); CorrelatorStep::Flagger::applyNrValidSamples(parset, *output.subblocks[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment