Skip to content
Snippets Groups Projects
Commit 80d7ba70 authored by Tobias Winchen's avatar Tobias Winchen
Browse files

adapted fft spectrometer interface to match gated interface

parent 5194a9b6
Branches
Tags
No related merge requests found
...@@ -28,8 +28,6 @@ public: ...@@ -28,8 +28,6 @@ public:
std::size_t fft_length, std::size_t fft_length,
std::size_t naccumulate, std::size_t naccumulate,
std::size_t nbits, std::size_t nbits,
float input_level,
float output_level,
HandlerType& handler); HandlerType& handler);
~FftSpectrometer(); ~FftSpectrometer();
......
...@@ -15,8 +15,6 @@ FftSpectrometer<HandlerType>::FftSpectrometer( ...@@ -15,8 +15,6 @@ FftSpectrometer<HandlerType>::FftSpectrometer(
std::size_t fft_length, std::size_t fft_length,
std::size_t naccumulate, std::size_t naccumulate,
std::size_t nbits, std::size_t nbits,
float input_level,
float output_level,
HandlerType& handler) HandlerType& handler)
: _buffer_bytes(buffer_bytes) : _buffer_bytes(buffer_bytes)
, _fft_length(fft_length) , _fft_length(fft_length)
...@@ -180,7 +178,8 @@ bool FftSpectrometer<HandlerType>::operator()(RawBytes& block) ...@@ -180,7 +178,8 @@ bool FftSpectrometer<HandlerType>::operator()(RawBytes& block)
// The handler can't do anything asynchronously without a copy here // The handler can't do anything asynchronously without a copy here
// as it would be unsafe (given that it does not own the memory it // as it would be unsafe (given that it does not own the memory it
// is being passed). // is being passed).
return _handler(bytes); _handler(bytes);
return false;
} }
} //edd } //edd
......
...@@ -33,9 +33,10 @@ int main(int argc, char** argv) ...@@ -33,9 +33,10 @@ int main(int argc, char** argv)
std::time_t now = std::time(NULL); std::time_t now = std::time(NULL);
std::tm * ptm = std::localtime(&now); std::tm * ptm = std::localtime(&now);
char buffer[32]; char default_filename[32];
std::strftime(buffer, 32, "%Y-%m-%d-%H:%M:%S.bp", ptm); std::strftime(default_filename, 32, "%Y-%m-%d-%H:%M:%S.bp", ptm);
std::string filename(buffer); std::string filename(default_filename);
std::string output_type;
/** Define and parse the program options /** Define and parse the program options
*/ */
...@@ -65,12 +66,12 @@ int main(int argc, char** argv) ...@@ -65,12 +66,12 @@ int main(int argc, char** argv)
"The number of bits per sample in the packetiser output (8, 10, or 12)"); "The number of bits per sample in the packetiser output (8, 10, or 12)");
desc.add_options()( desc.add_options()(
"output_type", po::value<std::string>(&ip.output_type)->default_value("file"), "output_type", po::value<std::string>(&output_type)->default_value("file"),
"output type [dada, file, profile]. Default is file. Profile executes the " "output type [dada, file, profile]. Default is file. Profile executes the "
" spectrometer 10x on random data and passes the ouput to a null sink." " spectrometer 10x on random data and passes the ouput to a null sink."
); );
desc.add_options()( desc.add_options()(
"output_key,o", po::value<std::string>(&ip.filename)->default_value(default_filename), "output_key,o", po::value<std::string>(&filename)->default_value(default_filename),
"The key of the output bnuffer / name of the output file to write spectra " "The key of the output bnuffer / name of the output file to write spectra "
"to"); "to");
...@@ -94,9 +95,9 @@ int main(int argc, char** argv) ...@@ -94,9 +95,9 @@ int main(int argc, char** argv)
return SUCCESS; return SUCCESS;
} }
po::notify(vm); po::notify(vm);
if (vm.count("output_type") && (!(ip.output_type == "dada" || ip.output_type == "file" || ip.output_type== "profile") )) if (vm.count("output_type") && (!(output_type == "dada" || output_type == "file" || output_type== "profile") ))
{ {
throw po::validation_error(po::validation_error::invalid_option_value, "output_type", ip.output_type); throw po::validation_error(po::validation_error::invalid_option_value, "output_type", output_type);
} }
} }
...@@ -114,20 +115,25 @@ int main(int argc, char** argv) ...@@ -114,20 +115,25 @@ int main(int argc, char** argv)
std::size_t buffer_bytes = client.data_buffer_size(); std::size_t buffer_bytes = client.data_buffer_size();
if (i.output_type == "file"){ if (output_type == "file"){
SimpleFileWriter sink(filename); SimpleFileWriter sink(filename);
//NullSink sink; //NullSink sink;
effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, input_level, output_level, sink); effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, sink);
} else if (i.output_type == "dada"){
DadaOutputStream sink(string_to_key(i.filename), log);
effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, input_level, output_level, sink); DadaInputStream<decltype(spectrometer)> istream(input_key, log, spectrometer);
istream.start();
} else if (output_type == "dada"){
DadaOutputStream sink(string_to_key(filename), log);
} else if (i.output_type == "profile") { effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, sink);
DadaInputStream<decltype(spectrometer)> istream(input_key, log, spectrometer);
istream.start();
} else if (output_type == "profile") {
NullSink sink; NullSink sink;
effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, input_level, output_level, sink); effelsberg::edd::FftSpectrometer<decltype(sink)> spectrometer(buffer_bytes, fft_length, naccumulate, nbits, sink);
std::vector<char> buffer(fft_length * naccumulate * nbits / 8); std::vector<char> buffer(fft_length * naccumulate * nbits / 8);
cudaHostRegister(buffer.data(), buffer.size(), cudaHostRegisterPortable); cudaHostRegister(buffer.data(), buffer.size(), cudaHostRegisterPortable);
RawBytes ib(buffer.data(), buffer.size(), buffer.size()); RawBytes ib(buffer.data(), buffer.size(), buffer.size());
...@@ -138,13 +144,10 @@ int main(int argc, char** argv) ...@@ -138,13 +144,10 @@ int main(int argc, char** argv)
spectrometer(ib); spectrometer(ib);
} }
DadaInputStream<decltype(spectrometer)> istream(input_key, log, spectrometer);
istream.start();
} }
DadaInputStream<decltype(spectrometer)> istream(input_key, log, spectrometer);
istream.start();
/** /**
* End of application code * End of application code
*/ */
......
...@@ -31,18 +31,18 @@ void FftSpectrometerTester::TearDown() ...@@ -31,18 +31,18 @@ void FftSpectrometerTester::TearDown()
} }
void FftSpectrometerTester::performance_test( void FftSpectrometerTester::performance_test(
std::size_t fft_length, std::size_t tscrunch, std::size_t fft_length, std::size_t tscrunch,
std::size_t nsamps_out, std::size_t nbits) std::size_t nsamps_out, std::size_t nbits)
{ {
std::size_t input_block_bytes = tscrunch * fft_length * nsamps_out * nbits/8; std::size_t input_block_bytes = tscrunch * fft_length * nsamps_out * nbits/8;
DoublePinnedHostBuffer<char> input_block; DoublePinnedHostBuffer<char> input_block;
input_block.resize(input_block_bytes); input_block.resize(input_block_bytes);
RawBytes input_raw_bytes(input_block.a_ptr(), input_block_bytes, input_block_bytes); RawBytes input_raw_bytes(input_block.a_ptr(), input_block_bytes, input_block_bytes);
std::vector<char> header_block(4096); std::vector<char> header_block(4096);
RawBytes header_raw_bytes(header_block.data(), 4096, 4096); RawBytes header_raw_bytes(header_block.data(), 4096, 4096);
NullSink null_sink; NullSink null_sink;
FftSpectrometer<NullSink> spectrometer(input_block_bytes, fft_length, tscrunch, nbits, 16.0f, 16.0f, null_sink); FftSpectrometer<NullSink> spectrometer(input_block_bytes, fft_length, tscrunch, nbits, null_sink);
spectrometer.init(header_raw_bytes); spectrometer.init(header_raw_bytes);
for (int ii = 0; ii < 100; ++ii) for (int ii = 0; ii < 100; ++ii)
{ {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment