diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.cc b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.cc index ebee3492efb16a10b0d7182071a19bec0d1ac439..4455064b32dc7b6e4c7cb8ec5e4c55ac986d1b78 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.cc +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.cc @@ -78,11 +78,11 @@ int MSWriter::addField (double azimuth, double elevation) } void MSWriter::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { - itsWriter->write (rowNr, bandId, fieldId, channelId, timeCounter, nrdata, - data, flags); + itsWriter->write (rowNr, bandId, fieldId, channelId, nrChannels, timeCounter, + nrdata, data, flags); } int MSWriter::nrAntennas() const diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.h b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.h index f003577793e6a63935fa490cce247bed76640b80..0ae7d35d3948b69b23062fd8dd9689443e69d54f 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.h +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriter.h @@ -92,7 +92,7 @@ public: // <br>The number of data points (nrdata) given should match the // number of antennas, bands, and polarizations for this bandId. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags = 0); // Get the number of antennas. diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc index 3e61559f2b888ed5f81338bf7f0b1bf2ebca6f71..4edf578a137ace83ef01f741efccea92cdcac48c 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc @@ -29,6 +29,7 @@ #include <tables/Tables/IncrementalStMan.h> #include <tables/Tables/StandardStMan.h> #include <tables/Tables/TiledColumnStMan.h> +#include <tables/Tables/TiledStManAccessor.h> //# include <tables/Tables/TiledShapeStMan.h> #include <tables/Tables/SetupNewTab.h> #include <tables/Tables/TableDesc.h> @@ -556,8 +557,8 @@ void MSWriterImpl::updateTimes() } void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { ASSERT(bandId >= 0 && bandId < itsNrBand); ASSERT(fieldId >= 0 && fieldId < itsNrField); @@ -568,9 +569,9 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Find the shape of the data array in each table row. IPosition shape(2, (*itsNrPol)[bandId], (*itsNrChan)[bandId]); Int nrel = shape[0]; // == number of polarisations/correlations - ASSERTSTR (nrdata == nrel*itsNrAnt*(itsNrAnt+1)/2, + ASSERTSTR (nrdata == nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2, "incorrect nr of data points for this band; should be " + - String::toString(nrel*itsNrAnt*(itsNrAnt+1)/2)); + String::toString(nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2)); Array<Bool> defFlags(shape); int nrbasel = itsNrAnt*(itsNrAnt+1)/2; @@ -579,6 +580,15 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Add the number of rows needed. rowNr = itsMS->nrow(); itsMS->addRow (nrbasel); + + // If first time, set the cache size for the tiled data and flags. + ROTiledStManAccessor accData(*itsMS, "TiledData"); + accData.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accData.setCacheSize (0, 1); + ROTiledStManAccessor accFlag(*itsMS, "TiledFlag"); + accFlag.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accFlag.setCacheSize (0, 1); + defFlags = False; Array<Float> sigma(IPosition(1, shape(0))); sigma = 0; @@ -634,18 +644,18 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, } } // End if (rowNr < 0) - IPosition dShape(2, shape[0], 1); // Shape of data field + IPosition dShape(2, shape[0], nrChannels); // Shape of data field int rowNumber = rowNr; for (int i=0; i<itsNrAnt; i++) { for (int j=0; j<=i; j++) { try { - // Write all polarisations of this channel for each baseline. - // The input data array has shape nrpol,nrant,nrant. + // Write all polarisations and nrChannels for each baseline. + // The input data array has shape nrant,nrant,nchan(subs),npol. // So we can form an AIPS++ array for each baseline. Array<Complex> array(dShape, (Complex*)data, SHARE); IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition leng(2, shape[0], nrChannels); itsMSCol->data().putSlice(rowNumber, Slicer(start, leng), array); } catch (AipsError& e) @@ -656,12 +666,12 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, itsMSCol->flag().put(rowNumber, defFlags); } else { Array<Bool> flagArray(dShape, const_cast<Bool*>(flags), SHARE); - IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition start(2, 0, channelId); // Start position + IPosition leng(2, shape[0], nrChannels); // Length: ncorr, nchan itsMSCol->flag().putSlice(rowNumber, Slicer(start, leng), flagArray); } rowNumber++; - data += nrel; // Go to next baseline data + data += nrel*nrChannels; // Go to next baseline data if (flags != 0) { flags += nrel; } diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h index b2d6861e0578a2b1c736b6fd22c44179da407e08..c0a7ba532c474c16f7854fbb7aaff1c9fd25a5b8 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h @@ -91,7 +91,7 @@ public: // If rowNr is -1, new subband rows will be added to the MS and the // new first row number is returned. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags); // Get the number of antennas. diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc index f88672bb447dccea0c78b0a583934fa12ba9f81d..b626105fbff6d552887972b78e30e9c1636f4fde 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc @@ -55,6 +55,8 @@ WH_Storage::WH_Storage(const string& name, #endif itsNstations = itsPS.getInt32("PPF.NrStations"); itsNChannels = itsPS.getInt32("PPF.NrSubChannels"); + itsNCorrPerFilt = itsPS.getInt32("PPF.NrCorrelatorsPerFilter"); + itsNChanPerVis = itsNChannels/itsNCorrPerFilt; int pols = itsPS.getInt32("Input.NPolarisations"); itsNpolSquared = pols*pols; @@ -141,20 +143,21 @@ void WH_Storage::process() for (int i=0; i<itsNinputs; i++) // Loop over subbands/inputs { inputDH = (DH_VisArray*)getDataManager().getInHolder(i); + int rownr = -1; // Set rownr -1 when new rows need to be added // when writing a new subband - int dataSize = (inputDH->getBufSize())/itsNChannels; + int dataSize = (inputDH->getBufSize())/(inputDH->getNumVis()); - for (uint ch=0; ch < itsNChannels; ch++) // Loop over frequency channels + for (uint v=0; v < inputDH->getNumVis(); v++) // Loop over "DH_Vis"s { // Check if channel frequency is ascending. - if (ch > 0) { - DBGASSERT(inputDH->getCenterFreq(ch) > inputDH->getCenterFreq(ch-1)); + if (v > 0) { + // DBGASSERT(inputDH->getCenterFreq(v) > inputDH->getCenterFreq(v-1)); } - // Write 1 frequency - itsWriter->write (rownr, itsBandIds[i], itsFieldId, ch, + // Write 1 DH_Vis size fcomplex[nbaselines][nChannelsPerVis][npol][npol] + itsWriter->write (rownr, itsBandIds[i], itsFieldId, v*itsNChanPerVis, itsNChanPerVis, itsCounter, dataSize, - inputDH->getBufferElement(ch, 0,0,0)); // To do: add flags + inputDH->getBufferElement(v)); // To do: add flags } } diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.h b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.h index 37ad2cf10d3bbbbf07eef686bec20360bfd39caf..ebd1bf2e1e5fb5bfd68a393510b0ed454b8bdc14 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.h +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/src/WH_Storage.h @@ -61,6 +61,8 @@ class WH_Storage: public WorkHolder const ACC::APS::ParameterSet itsPS; int itsNstations; int itsNChannels; + int itsNCorrPerFilt; + int itsNChanPerVis; int itsNpolSquared; MSWriter* itsWriter; diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc b/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc index e42b027ff3ae718af9df731579603c7d36afefec..6c039e3ba0a15911e7ac030a8d840954377489cb 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc @@ -41,7 +41,8 @@ namespace LOFAR itsInCon1(0), itsInCon2(0), itsNStations(0), - itsNChannels(0) + itsNChannels(0), + itsNVis (0) { } @@ -58,9 +59,11 @@ namespace LOFAR myPset.add("Storage.WriteToMAC", "F"); myPset.add("Storage.MSName", "TestPattern.MS"); myPset.add("Storage.refFreqs", "[1.0e8, 2.0e8]"); - myPset.add("PPF.NrSubChannels", "6"); - itsNChannels = 6; - myPset.add("Storage.NVisPerInput", "6"); + myPset.add("PPF.NrSubChannels", "16"); + myPset.add("PPF.NrCorrelatorsPerFilter", "4"); + itsNChannels = 16; + itsNVis = 4; + myPset.add("Storage.NVisPerInput", "4"); myPset.add("Storage.chanWidth", "1.0e8"); myPset.add("Storage.startTime", "123"); myPset.add("Storage.timeStep", "1"); @@ -81,13 +84,13 @@ namespace LOFAR itsWH->getDataManager().getInHolder(0), new TH_Mem(), false); - itsWH->getDataManager().setInConnection(0, itsInCon1); + itsWH->getDataManager().setInConnection(0, itsInCon1); itsInCon2 = new Connection("in2", itsInDH2, itsWH->getDataManager().getInHolder(1), new TH_Mem(), false); - itsWH->getDataManager().setInConnection(1, itsInCon2); + itsWH->getDataManager().setInConnection(1, itsInCon2); } @@ -99,40 +102,49 @@ namespace LOFAR // Fill DH1 DH_VisArray* dh1Ptr = (DH_VisArray*)itsInDH1; - for (int ch=0; ch<itsNChannels; ch++) + + int nChanPerVis = itsNChannels/itsNVis; + + for (int v=0; v<itsNVis; v++) { - fcomplex* dataPtr = dh1Ptr->getBufferElement(ch, 0,0,0); + fcomplex* dataPtr = dh1Ptr->getBufferElement(v); for (int st1=0; st1<itsNStations; st1++) { for (int st2=0; st2<=st1; st2++) { - dataPtr[0] = makefcomplex(st1, ch+100); - dataPtr[1] = makefcomplex(st1+10, ch+100); - dataPtr[2] = makefcomplex(st2, ch+100); - dataPtr[3] = makefcomplex(st2+10, ch+100); - dataPtr += 4; + for (int ch=0; ch<nChanPerVis; ch++) + { + dataPtr[0] = makefcomplex(st1, v*nChanPerVis+ch+100); + dataPtr[1] = makefcomplex(st1+10, v*nChanPerVis+ch+100); + dataPtr[2] = makefcomplex(st2, v*nChanPerVis+ch+100); + dataPtr[3] = makefcomplex(st2+10, v*nChanPerVis+ch+100); + dataPtr += 4; + } } } - dh1Ptr->setCenterFreq(ch*1.0e07+1.0e08, ch); + dh1Ptr->setCenterFreq(v*1.0e07+1.0e08, v); } // Fill DH2 DH_VisArray* dh2Ptr = (DH_VisArray*)itsInDH2; - for (int ch=0; ch<itsNChannels; ch++) + for (int v=0; v<itsNVis; v++) { - fcomplex* dataPtr = dh2Ptr->getBufferElement(ch, 0,0,0); + fcomplex* dataPtr = dh2Ptr->getBufferElement(v); for (int st1=0; st1<itsNStations; st1++) { for (int st2=0; st2<=st1; st2++) { - dataPtr[0] = makefcomplex(st1, ch+200); - dataPtr[1] = makefcomplex(st1+10, ch+200); - dataPtr[2] = makefcomplex(st2, ch+200); - dataPtr[3] = makefcomplex(st2+10, ch+200); - dataPtr += 4; + for (int ch=0; ch<nChanPerVis; ch++) + { + dataPtr[0] = makefcomplex(st1, v*nChanPerVis+ch+200); + dataPtr[1] = makefcomplex(st1+10, v*nChanPerVis+ch+200); + dataPtr[2] = makefcomplex(st2, v*nChanPerVis+ch+200); + dataPtr[3] = makefcomplex(st2+10, v*nChanPerVis+ch+200); + dataPtr += 4; + } } } - dh2Ptr->setCenterFreq(ch*1.0e07+2.0e08, ch); + dh2Ptr->setCenterFreq(v*1.0e07+2.0e08, v); } } @@ -140,7 +152,8 @@ namespace LOFAR for (int i = 0; i < nsteps; i++) { itsInCon1->write(); - itsInCon2->write(); + itsInCon2->write(); + itsWH->baseProcess(); } } diff --git a/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h b/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h index 7ee962e152e64d290b72a027c342bdded1cf9fd7..b984c87e55b9a8c101f73a4a47886c3d2c2b5acb 100644 --- a/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h +++ b/CEP/Demo/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h @@ -53,6 +53,7 @@ namespace LOFAR Connection* itsInCon2; int itsNStations; int itsNChannels; + int itsNVis; }; } // namespace LOFAR diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.cc index ebee3492efb16a10b0d7182071a19bec0d1ac439..4455064b32dc7b6e4c7cb8ec5e4c55ac986d1b78 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.cc @@ -78,11 +78,11 @@ int MSWriter::addField (double azimuth, double elevation) } void MSWriter::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { - itsWriter->write (rowNr, bandId, fieldId, channelId, timeCounter, nrdata, - data, flags); + itsWriter->write (rowNr, bandId, fieldId, channelId, nrChannels, timeCounter, + nrdata, data, flags); } int MSWriter::nrAntennas() const diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.h index f003577793e6a63935fa490cce247bed76640b80..0ae7d35d3948b69b23062fd8dd9689443e69d54f 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriter.h @@ -92,7 +92,7 @@ public: // <br>The number of data points (nrdata) given should match the // number of antennas, bands, and polarizations for this bandId. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags = 0); // Get the number of antennas. diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.cc index 3e61559f2b888ed5f81338bf7f0b1bf2ebca6f71..4edf578a137ace83ef01f741efccea92cdcac48c 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.cc @@ -29,6 +29,7 @@ #include <tables/Tables/IncrementalStMan.h> #include <tables/Tables/StandardStMan.h> #include <tables/Tables/TiledColumnStMan.h> +#include <tables/Tables/TiledStManAccessor.h> //# include <tables/Tables/TiledShapeStMan.h> #include <tables/Tables/SetupNewTab.h> #include <tables/Tables/TableDesc.h> @@ -556,8 +557,8 @@ void MSWriterImpl::updateTimes() } void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { ASSERT(bandId >= 0 && bandId < itsNrBand); ASSERT(fieldId >= 0 && fieldId < itsNrField); @@ -568,9 +569,9 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Find the shape of the data array in each table row. IPosition shape(2, (*itsNrPol)[bandId], (*itsNrChan)[bandId]); Int nrel = shape[0]; // == number of polarisations/correlations - ASSERTSTR (nrdata == nrel*itsNrAnt*(itsNrAnt+1)/2, + ASSERTSTR (nrdata == nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2, "incorrect nr of data points for this band; should be " + - String::toString(nrel*itsNrAnt*(itsNrAnt+1)/2)); + String::toString(nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2)); Array<Bool> defFlags(shape); int nrbasel = itsNrAnt*(itsNrAnt+1)/2; @@ -579,6 +580,15 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Add the number of rows needed. rowNr = itsMS->nrow(); itsMS->addRow (nrbasel); + + // If first time, set the cache size for the tiled data and flags. + ROTiledStManAccessor accData(*itsMS, "TiledData"); + accData.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accData.setCacheSize (0, 1); + ROTiledStManAccessor accFlag(*itsMS, "TiledFlag"); + accFlag.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accFlag.setCacheSize (0, 1); + defFlags = False; Array<Float> sigma(IPosition(1, shape(0))); sigma = 0; @@ -634,18 +644,18 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, } } // End if (rowNr < 0) - IPosition dShape(2, shape[0], 1); // Shape of data field + IPosition dShape(2, shape[0], nrChannels); // Shape of data field int rowNumber = rowNr; for (int i=0; i<itsNrAnt; i++) { for (int j=0; j<=i; j++) { try { - // Write all polarisations of this channel for each baseline. - // The input data array has shape nrpol,nrant,nrant. + // Write all polarisations and nrChannels for each baseline. + // The input data array has shape nrant,nrant,nchan(subs),npol. // So we can form an AIPS++ array for each baseline. Array<Complex> array(dShape, (Complex*)data, SHARE); IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition leng(2, shape[0], nrChannels); itsMSCol->data().putSlice(rowNumber, Slicer(start, leng), array); } catch (AipsError& e) @@ -656,12 +666,12 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, itsMSCol->flag().put(rowNumber, defFlags); } else { Array<Bool> flagArray(dShape, const_cast<Bool*>(flags), SHARE); - IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition start(2, 0, channelId); // Start position + IPosition leng(2, shape[0], nrChannels); // Length: ncorr, nchan itsMSCol->flag().putSlice(rowNumber, Slicer(start, leng), flagArray); } rowNumber++; - data += nrel; // Go to next baseline data + data += nrel*nrChannels; // Go to next baseline data if (flags != 0) { flags += nrel; } diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.h index b2d6861e0578a2b1c736b6fd22c44179da407e08..c0a7ba532c474c16f7854fbb7aaff1c9fd25a5b8 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/MSWriterImpl.h @@ -91,7 +91,7 @@ public: // If rowNr is -1, new subband rows will be added to the MS and the // new first row number is returned. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags); // Get the number of antennas. diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.cc index f88672bb447dccea0c78b0a583934fa12ba9f81d..b626105fbff6d552887972b78e30e9c1636f4fde 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.cc @@ -55,6 +55,8 @@ WH_Storage::WH_Storage(const string& name, #endif itsNstations = itsPS.getInt32("PPF.NrStations"); itsNChannels = itsPS.getInt32("PPF.NrSubChannels"); + itsNCorrPerFilt = itsPS.getInt32("PPF.NrCorrelatorsPerFilter"); + itsNChanPerVis = itsNChannels/itsNCorrPerFilt; int pols = itsPS.getInt32("Input.NPolarisations"); itsNpolSquared = pols*pols; @@ -141,20 +143,21 @@ void WH_Storage::process() for (int i=0; i<itsNinputs; i++) // Loop over subbands/inputs { inputDH = (DH_VisArray*)getDataManager().getInHolder(i); + int rownr = -1; // Set rownr -1 when new rows need to be added // when writing a new subband - int dataSize = (inputDH->getBufSize())/itsNChannels; + int dataSize = (inputDH->getBufSize())/(inputDH->getNumVis()); - for (uint ch=0; ch < itsNChannels; ch++) // Loop over frequency channels + for (uint v=0; v < inputDH->getNumVis(); v++) // Loop over "DH_Vis"s { // Check if channel frequency is ascending. - if (ch > 0) { - DBGASSERT(inputDH->getCenterFreq(ch) > inputDH->getCenterFreq(ch-1)); + if (v > 0) { + // DBGASSERT(inputDH->getCenterFreq(v) > inputDH->getCenterFreq(v-1)); } - // Write 1 frequency - itsWriter->write (rownr, itsBandIds[i], itsFieldId, ch, + // Write 1 DH_Vis size fcomplex[nbaselines][nChannelsPerVis][npol][npol] + itsWriter->write (rownr, itsBandIds[i], itsFieldId, v*itsNChanPerVis, itsNChanPerVis, itsCounter, dataSize, - inputDH->getBufferElement(ch, 0,0,0)); // To do: add flags + inputDH->getBufferElement(v)); // To do: add flags } } diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.h index 37ad2cf10d3bbbbf07eef686bec20360bfd39caf..ebd1bf2e1e5fb5bfd68a393510b0ed454b8bdc14 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/Attic/WH_Storage.h @@ -61,6 +61,8 @@ class WH_Storage: public WorkHolder const ACC::APS::ParameterSet itsPS; int itsNstations; int itsNChannels; + int itsNCorrPerFilt; + int itsNChanPerVis; int itsNpolSquared; MSWriter* itsWriter; diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.cc index ebee3492efb16a10b0d7182071a19bec0d1ac439..4455064b32dc7b6e4c7cb8ec5e4c55ac986d1b78 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.cc @@ -78,11 +78,11 @@ int MSWriter::addField (double azimuth, double elevation) } void MSWriter::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { - itsWriter->write (rowNr, bandId, fieldId, channelId, timeCounter, nrdata, - data, flags); + itsWriter->write (rowNr, bandId, fieldId, channelId, nrChannels, timeCounter, + nrdata, data, flags); } int MSWriter::nrAntennas() const diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.h index f003577793e6a63935fa490cce247bed76640b80..0ae7d35d3948b69b23062fd8dd9689443e69d54f 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriter.h @@ -92,7 +92,7 @@ public: // <br>The number of data points (nrdata) given should match the // number of antennas, bands, and polarizations for this bandId. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags = 0); // Get the number of antennas. diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc index 3e61559f2b888ed5f81338bf7f0b1bf2ebca6f71..4edf578a137ace83ef01f741efccea92cdcac48c 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.cc @@ -29,6 +29,7 @@ #include <tables/Tables/IncrementalStMan.h> #include <tables/Tables/StandardStMan.h> #include <tables/Tables/TiledColumnStMan.h> +#include <tables/Tables/TiledStManAccessor.h> //# include <tables/Tables/TiledShapeStMan.h> #include <tables/Tables/SetupNewTab.h> #include <tables/Tables/TableDesc.h> @@ -556,8 +557,8 @@ void MSWriterImpl::updateTimes() } void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, const fcomplex* data, - const bool* flags) + int nrChannels, int timeCounter, int nrdata, + const fcomplex* data, const bool* flags) { ASSERT(bandId >= 0 && bandId < itsNrBand); ASSERT(fieldId >= 0 && fieldId < itsNrField); @@ -568,9 +569,9 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Find the shape of the data array in each table row. IPosition shape(2, (*itsNrPol)[bandId], (*itsNrChan)[bandId]); Int nrel = shape[0]; // == number of polarisations/correlations - ASSERTSTR (nrdata == nrel*itsNrAnt*(itsNrAnt+1)/2, + ASSERTSTR (nrdata == nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2, "incorrect nr of data points for this band; should be " + - String::toString(nrel*itsNrAnt*(itsNrAnt+1)/2)); + String::toString(nrel*nrChannels*itsNrAnt*(itsNrAnt+1)/2)); Array<Bool> defFlags(shape); int nrbasel = itsNrAnt*(itsNrAnt+1)/2; @@ -579,6 +580,15 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, // Add the number of rows needed. rowNr = itsMS->nrow(); itsMS->addRow (nrbasel); + + // If first time, set the cache size for the tiled data and flags. + ROTiledStManAccessor accData(*itsMS, "TiledData"); + accData.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accData.setCacheSize (0, 1); + ROTiledStManAccessor accFlag(*itsMS, "TiledFlag"); + accFlag.setCacheSize (0, itsNrAnt*(itsNrAnt+1)/2); + //// accFlag.setCacheSize (0, 1); + defFlags = False; Array<Float> sigma(IPosition(1, shape(0))); sigma = 0; @@ -634,18 +644,18 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, } } // End if (rowNr < 0) - IPosition dShape(2, shape[0], 1); // Shape of data field + IPosition dShape(2, shape[0], nrChannels); // Shape of data field int rowNumber = rowNr; for (int i=0; i<itsNrAnt; i++) { for (int j=0; j<=i; j++) { try { - // Write all polarisations of this channel for each baseline. - // The input data array has shape nrpol,nrant,nrant. + // Write all polarisations and nrChannels for each baseline. + // The input data array has shape nrant,nrant,nchan(subs),npol. // So we can form an AIPS++ array for each baseline. Array<Complex> array(dShape, (Complex*)data, SHARE); IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition leng(2, shape[0], nrChannels); itsMSCol->data().putSlice(rowNumber, Slicer(start, leng), array); } catch (AipsError& e) @@ -656,12 +666,12 @@ void MSWriterImpl::write (int& rowNr, int bandId, int fieldId, int channelId, itsMSCol->flag().put(rowNumber, defFlags); } else { Array<Bool> flagArray(dShape, const_cast<Bool*>(flags), SHARE); - IPosition start(2, 0, channelId); - IPosition leng(2, shape[0], 1); + IPosition start(2, 0, channelId); // Start position + IPosition leng(2, shape[0], nrChannels); // Length: ncorr, nchan itsMSCol->flag().putSlice(rowNumber, Slicer(start, leng), flagArray); } rowNumber++; - data += nrel; // Go to next baseline data + data += nrel*nrChannels; // Go to next baseline data if (flags != 0) { flags += nrel; } diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h index b2d6861e0578a2b1c736b6fd22c44179da407e08..c0a7ba532c474c16f7854fbb7aaff1c9fd25a5b8 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/MSWriterImpl.h @@ -91,7 +91,7 @@ public: // If rowNr is -1, new subband rows will be added to the MS and the // new first row number is returned. void write (int& rowNr, int bandId, int fieldId, int channelId, - int timeCounter, int nrdata, + int nrChannels, int timeCounter, int nrdata, const fcomplex* data, const bool* flags); // Get the number of antennas. diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc index f88672bb447dccea0c78b0a583934fa12ba9f81d..b626105fbff6d552887972b78e30e9c1636f4fde 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.cc @@ -55,6 +55,8 @@ WH_Storage::WH_Storage(const string& name, #endif itsNstations = itsPS.getInt32("PPF.NrStations"); itsNChannels = itsPS.getInt32("PPF.NrSubChannels"); + itsNCorrPerFilt = itsPS.getInt32("PPF.NrCorrelatorsPerFilter"); + itsNChanPerVis = itsNChannels/itsNCorrPerFilt; int pols = itsPS.getInt32("Input.NPolarisations"); itsNpolSquared = pols*pols; @@ -141,20 +143,21 @@ void WH_Storage::process() for (int i=0; i<itsNinputs; i++) // Loop over subbands/inputs { inputDH = (DH_VisArray*)getDataManager().getInHolder(i); + int rownr = -1; // Set rownr -1 when new rows need to be added // when writing a new subband - int dataSize = (inputDH->getBufSize())/itsNChannels; + int dataSize = (inputDH->getBufSize())/(inputDH->getNumVis()); - for (uint ch=0; ch < itsNChannels; ch++) // Loop over frequency channels + for (uint v=0; v < inputDH->getNumVis(); v++) // Loop over "DH_Vis"s { // Check if channel frequency is ascending. - if (ch > 0) { - DBGASSERT(inputDH->getCenterFreq(ch) > inputDH->getCenterFreq(ch-1)); + if (v > 0) { + // DBGASSERT(inputDH->getCenterFreq(v) > inputDH->getCenterFreq(v-1)); } - // Write 1 frequency - itsWriter->write (rownr, itsBandIds[i], itsFieldId, ch, + // Write 1 DH_Vis size fcomplex[nbaselines][nChannelsPerVis][npol][npol] + itsWriter->write (rownr, itsBandIds[i], itsFieldId, v*itsNChanPerVis, itsNChanPerVis, itsCounter, dataSize, - inputDH->getBufferElement(ch, 0,0,0)); // To do: add flags + inputDH->getBufferElement(v)); // To do: add flags } } diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.h index 37ad2cf10d3bbbbf07eef686bec20360bfd39caf..ebd1bf2e1e5fb5bfd68a393510b0ed454b8bdc14 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/src/WH_Storage.h @@ -61,6 +61,8 @@ class WH_Storage: public WorkHolder const ACC::APS::ParameterSet itsPS; int itsNstations; int itsNChannels; + int itsNCorrPerFilt; + int itsNChanPerVis; int itsNpolSquared; MSWriter* itsWriter; diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc b/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc index e42b027ff3ae718af9df731579603c7d36afefec..6c039e3ba0a15911e7ac030a8d840954377489cb 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.cc @@ -41,7 +41,8 @@ namespace LOFAR itsInCon1(0), itsInCon2(0), itsNStations(0), - itsNChannels(0) + itsNChannels(0), + itsNVis (0) { } @@ -58,9 +59,11 @@ namespace LOFAR myPset.add("Storage.WriteToMAC", "F"); myPset.add("Storage.MSName", "TestPattern.MS"); myPset.add("Storage.refFreqs", "[1.0e8, 2.0e8]"); - myPset.add("PPF.NrSubChannels", "6"); - itsNChannels = 6; - myPset.add("Storage.NVisPerInput", "6"); + myPset.add("PPF.NrSubChannels", "16"); + myPset.add("PPF.NrCorrelatorsPerFilter", "4"); + itsNChannels = 16; + itsNVis = 4; + myPset.add("Storage.NVisPerInput", "4"); myPset.add("Storage.chanWidth", "1.0e8"); myPset.add("Storage.startTime", "123"); myPset.add("Storage.timeStep", "1"); @@ -81,13 +84,13 @@ namespace LOFAR itsWH->getDataManager().getInHolder(0), new TH_Mem(), false); - itsWH->getDataManager().setInConnection(0, itsInCon1); + itsWH->getDataManager().setInConnection(0, itsInCon1); itsInCon2 = new Connection("in2", itsInDH2, itsWH->getDataManager().getInHolder(1), new TH_Mem(), false); - itsWH->getDataManager().setInConnection(1, itsInCon2); + itsWH->getDataManager().setInConnection(1, itsInCon2); } @@ -99,40 +102,49 @@ namespace LOFAR // Fill DH1 DH_VisArray* dh1Ptr = (DH_VisArray*)itsInDH1; - for (int ch=0; ch<itsNChannels; ch++) + + int nChanPerVis = itsNChannels/itsNVis; + + for (int v=0; v<itsNVis; v++) { - fcomplex* dataPtr = dh1Ptr->getBufferElement(ch, 0,0,0); + fcomplex* dataPtr = dh1Ptr->getBufferElement(v); for (int st1=0; st1<itsNStations; st1++) { for (int st2=0; st2<=st1; st2++) { - dataPtr[0] = makefcomplex(st1, ch+100); - dataPtr[1] = makefcomplex(st1+10, ch+100); - dataPtr[2] = makefcomplex(st2, ch+100); - dataPtr[3] = makefcomplex(st2+10, ch+100); - dataPtr += 4; + for (int ch=0; ch<nChanPerVis; ch++) + { + dataPtr[0] = makefcomplex(st1, v*nChanPerVis+ch+100); + dataPtr[1] = makefcomplex(st1+10, v*nChanPerVis+ch+100); + dataPtr[2] = makefcomplex(st2, v*nChanPerVis+ch+100); + dataPtr[3] = makefcomplex(st2+10, v*nChanPerVis+ch+100); + dataPtr += 4; + } } } - dh1Ptr->setCenterFreq(ch*1.0e07+1.0e08, ch); + dh1Ptr->setCenterFreq(v*1.0e07+1.0e08, v); } // Fill DH2 DH_VisArray* dh2Ptr = (DH_VisArray*)itsInDH2; - for (int ch=0; ch<itsNChannels; ch++) + for (int v=0; v<itsNVis; v++) { - fcomplex* dataPtr = dh2Ptr->getBufferElement(ch, 0,0,0); + fcomplex* dataPtr = dh2Ptr->getBufferElement(v); for (int st1=0; st1<itsNStations; st1++) { for (int st2=0; st2<=st1; st2++) { - dataPtr[0] = makefcomplex(st1, ch+200); - dataPtr[1] = makefcomplex(st1+10, ch+200); - dataPtr[2] = makefcomplex(st2, ch+200); - dataPtr[3] = makefcomplex(st2+10, ch+200); - dataPtr += 4; + for (int ch=0; ch<nChanPerVis; ch++) + { + dataPtr[0] = makefcomplex(st1, v*nChanPerVis+ch+200); + dataPtr[1] = makefcomplex(st1+10, v*nChanPerVis+ch+200); + dataPtr[2] = makefcomplex(st2, v*nChanPerVis+ch+200); + dataPtr[3] = makefcomplex(st2+10, v*nChanPerVis+ch+200); + dataPtr += 4; + } } } - dh2Ptr->setCenterFreq(ch*1.0e07+2.0e08, ch); + dh2Ptr->setCenterFreq(v*1.0e07+2.0e08, v); } } @@ -140,7 +152,8 @@ namespace LOFAR for (int i = 0; i < nsteps; i++) { itsInCon1->write(); - itsInCon2->write(); + itsInCon2->write(); + itsWH->baseProcess(); } } diff --git a/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h b/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h index 7ee962e152e64d290b72a027c342bdded1cf9fd7..b984c87e55b9a8c101f73a4a47886c3d2c2b5acb 100644 --- a/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h +++ b/Demo/CEP/TFlopCorrelator/TFC_Storage/test/tAH_TestStorage.h @@ -53,6 +53,7 @@ namespace LOFAR Connection* itsInCon2; int itsNStations; int itsNChannels; + int itsNVis; }; } // namespace LOFAR