diff --git a/RTCP/CNProc/src/BeamFormer.cc b/RTCP/CNProc/src/BeamFormer.cc index 9869350c1ebf7ee107bf949d96dd20724c325247..cd59deee820a2c4b70ae989d39574388ac578231 100644 --- a/RTCP/CNProc/src/BeamFormer.cc +++ b/RTCP/CNProc/src/BeamFormer.cc @@ -20,7 +20,7 @@ namespace RTCP { static NSTimer beamFormTimer("BeamFormer::formBeams()", true, true); -BeamFormer::BeamFormer(const unsigned nrPencilBeams, const unsigned nrStations, const unsigned nrChannels, const unsigned nrSamplesPerIntegration, const double channelBandwidth, const std::vector<unsigned> &station2BeamFormedStation, const bool flysEye, const unsigned integrationSteps ) +BeamFormer::BeamFormer(const unsigned nrPencilBeams, const unsigned nrStations, const unsigned nrChannels, const unsigned nrSamplesPerIntegration, const double channelBandwidth, const std::vector<unsigned> &station2BeamFormedStation, const bool flysEye ) : itsDelays( nrStations, nrPencilBeams ), itsNrStations(nrStations), @@ -31,10 +31,7 @@ BeamFormer::BeamFormer(const unsigned nrPencilBeams, const unsigned nrStations, itsNrValidStations( 0 ), itsValidStations( itsNrStations ), itsFlysEye( flysEye ), - itsIntegrationSteps( integrationSteps ) { - ASSERT( itsNrSamplesPerIntegration % itsIntegrationSteps == 0 ); - initStationMergeMap( station2BeamFormedStation ); } @@ -209,12 +206,29 @@ void BeamFormer::computeComplexVoltages( const SampleData<> *in, SampleData<> *o { const double averagingSteps = 1.0 / itsNrValidStations; - for( unsigned beam = 0; beam < itsNrPencilBeams; beam++ ) { + for (unsigned ch = 0; ch < itsNrChannels; ch ++) { const double frequency = baseFrequency + ch * itsChannelBandwidth; + // construct the weights, with zeroes for unused data + fcomplex weights[itsNrStations][itsNrPencilBeams] __attribute__ ((aligned(128))); + + for( unsigned s = 0; s < itsNrStations; s++ ) { + if( itsValidStations[s] ) { + for( unsigned b = 0; b < itsNrPencilBeams; b++ ) { + weights[s][b] = phaseShift( frequency, itsDelays[s][b] ); + } + } else { + // a dropped station has a weight of 0, so we can just add them blindly + for( unsigned b = 0; b < itsNrPencilBeams; b++ ) { + weights[s][b] = makefcomplex( 0, 0 ); + } + } + } + + for( unsigned beam = 0; beam < itsNrPencilBeams; beam++ ) { for (unsigned time = 0; time < itsNrSamplesPerIntegration; time ++) { - if( !out->flags[beam].test(time) ) { + if( 1 || !out->flags[beam].test(time) ) { for (unsigned pol = 0; pol < NR_POLARIZATIONS; pol ++) { fcomplex &dest = out->samples[beam][ch][time][pol]; const float factor = averagingSteps; @@ -223,11 +237,11 @@ void BeamFormer::computeComplexVoltages( const SampleData<> *in, SampleData<> *o dest = makefcomplex( 0, 0 ); for( unsigned stat = 0; stat < itsNrStations; stat++ ) { - if( itsValidStations[stat] ) { + if( 1 || itsValidStations[stat] ) { // note: for beam #0 (central beam), the phaseShift is 1 // // static_cast<fcomplex> is required here since GCC can't seem to figure it out otherwise - const fcomplex shift = static_cast<fcomplex>( phaseShift( frequency, itsDelays[stat][beam] ) ); + const fcomplex shift = weights[stat][beam]; dest += in->samples[ch][stat][time][pol] * shift; } @@ -540,33 +554,17 @@ void BeamFormer::preTransposeBeams( const BeamFormedData *in, PreTransposeBeamFo ASSERT( out->samples.shape()[0] > beam ); ASSERT( out->samples.shape()[1] == NR_POLARIZATIONS ); - ASSERT( out->samples.shape()[2] >= itsNrSamplesPerIntegration / itsIntegrationSteps ); + ASSERT( out->samples.shape()[2] >= itsNrSamplesPerIntegration ); ASSERT( out->samples.shape()[3] == itsNrChannels ); out->flags[beam] = in->flags[beam]; #if 0 /* reference implementation */ - if (itsIntegrationSteps > 1) { - for (unsigned c = 0; c < itsNrChannels; c++) { - for (unsigned t = 0; t < itsNrSamplesPerIntegration / itsIntegrationSteps; t++) { - unsigned tin = t * itsIntegrationSteps; - - for (unsigned p = 0; p < NR_POLARIZATIONS; p++) { - out->samples[beam][p][t][c] = in->samples[beam][c][tin++][p]; - - for (unsigned i = 1; i < itsIntegrationSteps; i++) { - out->samples[beam][p][t][c] += in->samples[beam][c][tin++][p]; - } - } - } - } - } else { - for (unsigned c = 0; c < itsNrChannels; c++) { - for (unsigned t = 0; t < itsNrSamplesPerIntegration; t++) { - for (unsigned p = 0; p < NR_POLARIZATIONS; p++) { - out->samples[beam][p][t][c] = in->samples[beam][c][t][p]; - } + for (unsigned c = 0; c < itsNrChannels; c++) { + for (unsigned t = 0; t < itsNrSamplesPerIntegration; t++) { + for (unsigned p = 0; p < NR_POLARIZATIONS; p++) { + out->samples[beam][p][t][c] = in->samples[beam][c][t][p]; } } } @@ -576,41 +574,17 @@ void BeamFormer::preTransposeBeams( const BeamFormedData *in, PreTransposeBeamFo /* in_stride == 1 */ unsigned out_stride = &out->samples[0][0][1][0] - &out->samples[0][0][0][0]; - if (itsIntegrationSteps > 1) { - for (unsigned c = 0; c < itsNrChannels; c++) { - const fcomplex *inb = &in->samples[beam][c][0][0]; - fcomplex *outbX = &out->samples[beam][0][0][c]; - fcomplex *outbY = &out->samples[beam][1][0][c]; - - for (unsigned s = 0; s < itsNrSamplesPerIntegration / itsIntegrationSteps; s++ ) { - fcomplex accX = *inb++; - fcomplex accY = *inb++; - - for (unsigned i = 1; i < itsIntegrationSteps; i++) { - accX += *inb++; - accY += *inb++; - } - - *outbX = accX; - *outbY = accY; - - outbX += out_stride; - outbY += out_stride; - } - } - } else { - for (unsigned c = 0; c < itsNrChannels; c++) { - const fcomplex *inb = &in->samples[beam][c][0][0]; - fcomplex *outbX = &out->samples[beam][0][0][c]; - fcomplex *outbY = &out->samples[beam][1][0][c]; + for (unsigned c = 0; c < itsNrChannels; c++) { + const fcomplex *inb = &in->samples[beam][c][0][0]; + fcomplex *outbX = &out->samples[beam][0][0][c]; + fcomplex *outbY = &out->samples[beam][1][0][c]; - for (unsigned s = 0; s < itsNrSamplesPerIntegration; s++) { - *outbX = *inb++; - *outbY = *inb++; + for (unsigned s = 0; s < itsNrSamplesPerIntegration; s++) { + *outbX = *inb++; + *outbY = *inb++; - outbX += out_stride; - outbY += out_stride; - } + outbX += out_stride; + outbY += out_stride; } } #endif @@ -619,10 +593,10 @@ void BeamFormer::preTransposeBeams( const BeamFormedData *in, PreTransposeBeamFo void BeamFormer::postTransposeBeams( const TransposedBeamFormedData *in, FinalBeamFormedData *out, unsigned sb ) { ASSERT( in->samples.shape()[0] > sb ); - ASSERT( in->samples.shape()[1] >= itsNrSamplesPerIntegration / itsIntegrationSteps ); + ASSERT( in->samples.shape()[1] >= itsNrSamplesPerIntegration ); ASSERT( in->samples.shape()[2] == itsNrChannels ); - ASSERT( out->samples.shape()[0] >= itsNrSamplesPerIntegration / itsIntegrationSteps ); + ASSERT( out->samples.shape()[0] >= itsNrSamplesPerIntegration ); ASSERT( out->samples.shape()[1] > sb ); ASSERT( out->samples.shape()[2] == itsNrChannels ); @@ -631,7 +605,7 @@ void BeamFormer::postTransposeBeams( const TransposedBeamFormedData *in, FinalBe #if 0 /* reference implementation */ for (unsigned c = 0; c < itsNrChannels; c++) { - for (unsigned t = 0; t < itsNrSamplesPerIntegration / itsIntegrationSteps; t++) { + for (unsigned t = 0; t < itsNrSamplesPerIntegration; t++) { out->samples[t][sb][c] = in->samples[sb][t][c]; } } @@ -644,7 +618,7 @@ void BeamFormer::postTransposeBeams( const TransposedBeamFormedData *in, FinalBe fcomplex *outb = &out->samples[0][sb][0]; unsigned out_stride = &out->samples[1][sb][0] - &out->samples[0][sb][0]; - for (unsigned t = 0; t < itsNrSamplesPerIntegration / itsIntegrationSteps; t++) { + for (unsigned t = 0; t < itsNrSamplesPerIntegration; t++) { memcpy( outb, inb, allChannelSize ); inb += in_stride; diff --git a/RTCP/CNProc/src/BeamFormer.h b/RTCP/CNProc/src/BeamFormer.h index 2f3e6a677e450bd8a397f855f6229e3b75fbf529..bdafb4efce2aa2e00a2807646eb36283cc1c5f9c 100644 --- a/RTCP/CNProc/src/BeamFormer.h +++ b/RTCP/CNProc/src/BeamFormer.h @@ -47,7 +47,7 @@ class BeamFormer public: static const float MAX_FLAGGED_PERCENTAGE = 0.9f; - BeamFormer(const unsigned nrPencilBeams, const unsigned nrStations, const unsigned nrChannels, const unsigned nrSamplesPerIntegration, const double channelBandwidth, const std::vector<unsigned> &station2BeamFormedStation, const bool flysEye, const unsigned integrationSteps ); + BeamFormer(const unsigned nrPencilBeams, const unsigned nrStations, const unsigned nrChannels, const unsigned nrSamplesPerIntegration, const double channelBandwidth, const std::vector<unsigned> &station2BeamFormedStation, const bool flysEye ); // merges stations into superstations in sampleData void mergeStations( SampleData<> *sampleData ); @@ -106,8 +106,6 @@ class BeamFormer std::vector<bool> itsValidStations; // [itsNrStations] whether each station is valid const bool itsFlysEye; - - const unsigned itsIntegrationSteps; }; inline dcomplex BeamFormer::phaseShift( const double frequency, const double delay ) const diff --git a/RTCP/CNProc/src/CN_Processing.cc b/RTCP/CNProc/src/CN_Processing.cc index 7f726eb986c1fbb49ce240b032b616997c832b8d..0b80736c66f88386f583d4b5a6554f6ea865cd64 100644 --- a/RTCP/CNProc/src/CN_Processing.cc +++ b/RTCP/CNProc/src/CN_Processing.cc @@ -242,7 +242,7 @@ template <typename SAMPLE_TYPE> void CN_Processing<SAMPLE_TYPE>::preprocess(CN_C itsMyCoreIndex = std::find(phaseOneTwoCores.begin(), phaseOneTwoCores.end(), myCoreInPset) - phaseOneTwoCores.begin(); if (itsHasPhaseTwo || itsHasPhaseThree) { - itsBeamFormer = new BeamFormer(itsNrPencilBeams, itsNrStations, nrChannels, nrSamplesPerIntegration, configuration.sampleRate() / nrChannels, configuration.tabList(), configuration.flysEye(), configuration.nrSamplesPerStokesIntegration() ); + itsBeamFormer = new BeamFormer(itsNrPencilBeams, itsNrStations, nrChannels, nrSamplesPerIntegration, configuration.sampleRate() / nrChannels, configuration.tabList(), configuration.flysEye() ); } if (itsHasPhaseTwo) { @@ -446,7 +446,7 @@ template <typename SAMPLE_TYPE> int CN_Processing<SAMPLE_TYPE>::transposeBeams(u unsigned partNr = *itsCurrentSubband / itsNrSubbandsPerPart; -#if 0 +#if 1 /* overlap computation and transpose */ /* this makes async send timing worse -- due to caches? remember that we do async sends, so we're not actually using the data we just calculated, just diff --git a/RTCP/Interface/src/CN_Mapping.cc b/RTCP/Interface/src/CN_Mapping.cc index 77a8e796f1ff65a414bdd6ac6eab10b3d29c9487..b1f4f104d617cff4adc28ed10ea40160cf47e432 100644 --- a/RTCP/Interface/src/CN_Mapping.cc +++ b/RTCP/Interface/src/CN_Mapping.cc @@ -28,6 +28,8 @@ namespace RTCP { unsigned CN_Mapping::mapCoreOnPset(unsigned core, unsigned pset) { #if defined HAVE_BGP + //return core ^ ((pset & 0x1) << 2) ^ ((pset & 0x02) >> 1) ^ ((pset & 0x04) >> 1) ^ ((pset & 0x08)) ^ ((pset & 0x10) >> 1) ^ ((pset & 0x20) >> 3); + // TODO: there may be better mappings for partitions larger than one rack static unsigned char mapX[] = { 0, 12 }; static unsigned char mapY[] = { 0, 2, 10, 8 }; @@ -37,6 +39,7 @@ unsigned CN_Mapping::mapCoreOnPset(unsigned core, unsigned pset) mapX[((pset & 0x08) >> 3)] ^ mapY[((pset & 0x01) >> 0) | ((pset & 0x10) >> 3)] ^ mapZ[((pset & 0x03) >> 1) | ((pset & 0x20) >> 3)]; + #else (void)pset; diff --git a/RTCP/Interface/src/Stream.cc b/RTCP/Interface/src/Stream.cc index 1a5d6a361facffaae144f607c8fa50102f752f0d..73cbac619d622c147ab61d885c04982a35e8cb08 100644 --- a/RTCP/Interface/src/Stream.cc +++ b/RTCP/Interface/src/Stream.cc @@ -106,7 +106,7 @@ std::string getStreamDescriptorBetweenIONandStorage(const Parset &parset, const if (connectionType == "NULL") { return "null:"; } else if (connectionType == "TCP") { - return str(format("tcpkey:%s:ion-storage-obs-%s-file-%s") % host % parset.observationID() % filename); + return str(format("tcpkey:%s.online.lofar:ion-storage-obs-%s-file-%s") % host % parset.observationID() % filename); } else if (connectionType == "FILE") { return str(format("file:%s") % filename ); } else {