From d567ceb9306f8250a28e0b68cc4ca9d196deef75 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 13 Sep 2014 20:51:22 +0200 Subject: Add some Buffer comments --- src/Buffer.cpp | 17 ++++------------- src/Buffer.h | 53 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 7cbbe57..dff2623 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -73,8 +73,10 @@ void Buffer::setLength(size_t len) /* Align to 32-byte boundary for AVX. */ data = memalign(32, len); - memcpy(data, tmp, this->len); - free(tmp); + if (tmp != NULL) { + memcpy(data, tmp, this->len); + free(tmp); + } size = len; } this->len = len; @@ -97,14 +99,3 @@ void Buffer::appendData(const void *data, size_t len) } } - -size_t Buffer::getLength() -{ - return len; -} - - -void *Buffer::getData() -{ - return data; -} diff --git a/src/Buffer.h b/src/Buffer.h index b1a5d93..4bb157b 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -29,28 +29,47 @@ #include - +/* Buffer is a container for a byte array, that is memcpy'ed + * on assignment and by the copy-constructor. + * + * The allocation/freeing of the data is handled internally. + */ class Buffer { -protected: - size_t len; - size_t size; - void *data; + protected: + /* Current length of the data in the Buffer */ + size_t len; -public: - Buffer(const Buffer& copy); - Buffer(size_t len = 0, const void *data = NULL); - ~Buffer(); + /* Allocated size of the Buffer */ + size_t size; - Buffer &operator=(const Buffer ©); - Buffer &operator+=(const Buffer ©); + /* Pointer to the data. Memory allocation is entirely + * handled by setLength. + */ + void *data; - void setLength(size_t len); - void setData(const void *data, size_t len); - void appendData(const void *data, size_t len); + public: + Buffer(const Buffer& copy); + Buffer(size_t len = 0, const void *data = NULL); + ~Buffer(); - size_t getLength(); - void *getData(); -}; + /* Resize the buffer, reallocate memory if needed */ + void setLength(size_t len); + + /* Replace the data in the Buffer by the new data given. + * Reallocates memory if needed. + */ + void setData(const void *data, size_t len); + Buffer &operator=(const Buffer ©); + /* Concatenate the current data with the new data given. + * Reallocates memory if needed. + */ + void appendData(const void *data, size_t len); + Buffer &operator+=(const Buffer ©); + + size_t getLength() const { return len; } + void *getData() const { return data; } +}; #endif // BUFFER_H + -- cgit v1.2.3 From 0b7bc4a405ea4d6f24fade9420e9919420c64d8e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 14 Sep 2014 00:05:51 +0200 Subject: Add little check for zeromq url syntax --- src/DabMod.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 14c7c4b..7ee65dc 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -667,7 +667,13 @@ int main(int argc, char* argv[]) ret = -1; goto END_MAIN; #else - inputZeroMQReader.Open(inputName.substr(4)); + // The URL might start with zmq+tcp:// + if (inputName.substr(0, 4) == "zmq+") { + inputZeroMQReader.Open(inputName.substr(4)); + } + else { + inputZeroMQReader.Open(inputName); + } inputReader = &inputZeroMQReader; #endif } -- cgit v1.2.3 From 685095418bc8fd27dcd0b1d73ad1741114aeda6a Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 14 Sep 2014 00:08:53 +0200 Subject: SFN: carry FCT along with timestamps This is the first step to fix issue #6. The goal is to enable the OutputUHD to check for FCT consistency. Once it can do that, it will also be able to reset the UHD streamer if necessary. --- src/EtiReader.cpp | 19 +++++++--------- src/EtiReader.h | 9 ++++---- src/InputZeroMQReader.cpp | 4 +++- src/OutputUHD.cpp | 56 ++++++++++++++++++++++++++++++++++++++--------- src/OutputUHD.h | 14 ++++++++---- src/TimestampDecoder.cpp | 16 ++++++++++---- src/TimestampDecoder.h | 22 ++++++++++++++----- 7 files changed, 100 insertions(+), 40 deletions(-) diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index b61481c..f7376cc 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -2,8 +2,10 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Includes modifications for which no copyright is claimed - 2012, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -269,18 +271,17 @@ int EtiReader::process(Buffer* dataIn) } break; default: - // throw std::runtime_error("Invalid state!"); + // throw std::runtime_error("Invalid state!"); PDEBUG("Invalid state (%i)!", state); input_size = 0; } } - + // Update timestamps myTimestampDecoder.updateTimestampEti(eti_fc.FP & 0x3, - eti_eoh.MNSC, - getPPSOffset()); + eti_eoh.MNSC, getPPSOffset(), eti_fc.FCT); - if (getFCT() % 125 == 0) //every 3 seconds is fine enough + if (eti_fc.FCT % 125 == 0) //every 3 seconds is fine enough { myTimestampDecoder.updateModulatorOffset(); } @@ -306,7 +307,3 @@ double EtiReader::getPPSOffset() return pps; } -uint32_t EtiReader::getFCT() -{ - return eti_fc.FCT; -} diff --git a/src/EtiReader.h b/src/EtiReader.h index be12075..209b208 100644 --- a/src/EtiReader.h +++ b/src/EtiReader.h @@ -2,8 +2,10 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Includes modifications for which no copyright is claimed - 2012, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -60,9 +62,6 @@ public: myTimestampDecoder.calculateTimestamp(ts); } - /* Return the frame counter */ - uint32_t getFCT(); - /* Returns true if we have valid time stamps in the ETI*/ bool sourceContainsTimestamp(); diff --git a/src/InputZeroMQReader.cpp b/src/InputZeroMQReader.cpp index cf3f7aa..cfb56b2 100644 --- a/src/InputZeroMQReader.cpp +++ b/src/InputZeroMQReader.cpp @@ -3,8 +3,10 @@ Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Copyrigth (C) 2013, 2014 + Copyright (C) 2013, 2014 Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index b44cd3f..927d2e6 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -58,6 +58,9 @@ OutputUHD::OutputUHD( { myMuting = 0; // is remote-controllable +#if FAKE_UHD + MDEBUG("OutputUHD:Using fake UHD output"); +#else std::stringstream device; device << myConf.device; @@ -198,6 +201,7 @@ OutputUHD::OutputUHD( // preparing output thread worker data uwd.myUsrp = myUsrp; +#endif uwd.frame0.ts.timestamp_valid = false; uwd.frame1.ts.timestamp_valid = false; @@ -257,7 +261,15 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) myEtiReader->calculateTimestamp(ts); uwd.frame0.ts = ts; - uwd.frame0.fct = myEtiReader->getFCT(); + + switch (myEtiReader->getMode()) { + case 1: uwd.fct_increment = 4; break; + case 2: + case 3: uwd.fct_increment = 1; break; + case 4: uwd.fct_increment = 2; break; + default: break; + } + activebuffer = 1; @@ -287,13 +299,11 @@ int OutputUHD::process(Buffer* dataIn, Buffer* dataOut) memcpy(uwd.frame0.buf, dataIn->getData(), uwd.bufsize); uwd.frame0.ts = ts; - uwd.frame0.fct = myEtiReader->getFCT(); } else if (activebuffer == 1) { memcpy(uwd.frame1.buf, dataIn->getData(), uwd.bufsize); uwd.frame1.ts = ts; - uwd.frame1.fct = myEtiReader->getFCT(); } activebuffer = (activebuffer + 1) % 2; @@ -322,9 +332,13 @@ void UHDWorker::process() // Transmit timeout const double timeout = 0.2; +#if FAKE_UHD == 0 uhd::stream_args_t stream_args("fc32"); //complex floats uhd::tx_streamer::sptr myTxStream = uwd->myUsrp->get_tx_stream(stream_args); size_t usrp_max_num_samps = myTxStream->get_max_num_samps(); +#else + size_t usrp_max_num_samps = 2048; // arbitrarily chosen +#endif const complexf* in; @@ -362,6 +376,19 @@ void UHDWorker::process() sizeIn = uwd->bufsize / sizeof(complexf); +#if FAKE_UHD + if (expected_next_fct != -1) { + if (expected_next_fct != frame->ts.fct) { + uwd->logger->level(warn) << + "OutputUHD: Incorrect expect fct " << frame->ts.fct; + + // TODO here we should disrupt the UHD streamer so that + // it resyncs to the correct timestamps + } + } + + expected_next_fct = (frame->ts.fct + uwd->fct_increment) % 250; +#else // Check for ref_lock if (uwd->check_refclk_loss) { @@ -392,7 +419,7 @@ void UHDWorker::process() * MNSC. We sleep through the frame. */ uwd->logger->level(info) << - "OutputUHD: Throwing sample " << frame->fct << + "OutputUHD: Throwing sample " << frame->ts.fct << " away: incomplete timestamp " << tx_second << " + " << pps_offset; usleep(20000); //TODO should this be TM-dependant ? @@ -408,7 +435,7 @@ void UHDWorker::process() "OutputUHD: Timestamp in the past! offset: " << md.time_spec.get_real_secs() - usrp_time << " (" << usrp_time << ")" - " frame " << frame->fct << + " frame " << frame->ts.fct << ", tx_second " << tx_second << ", pps " << pps_offset; goto loopend; //skip the frame @@ -433,7 +460,7 @@ void UHDWorker::process() "OutputUHD (usrp time: %f): frame %d;" " tx_second %zu; pps %.9f\n", usrp_time, - frame->fct, tx_second, pps_offset); + frame->ts.fct, tx_second, pps_offset); } } @@ -444,20 +471,21 @@ void UHDWorker::process() if (uwd->muting) { uwd->logger->log(info, "OutputUHD: Muting sample %d requested\n", - frame->fct); + frame->ts.fct); } else { uwd->logger->log(info, "OutputUHD: Muting sample %d : no timestamp\n", - frame->fct); + frame->ts.fct); } usleep(20000); goto loopend; } } +#endif PDEBUG("UHDWorker::process:max_num_samps: %zu.\n", - myTxStream->get_max_num_samps()); + usrp_max_num_samps); while (running && !uwd->muting && (num_acc_samps < sizeIn)) { size_t samps_to_send = std::min(sizeIn - num_acc_samps, usrp_max_num_samps); @@ -467,10 +495,16 @@ void UHDWorker::process() md.end_of_burst = (frame->ts.timestamp_refresh && (samps_to_send <= usrp_max_num_samps)); +#if FAKE_UHD + // This is probably very approximate + usleep( (1000000 / uwd->sampleRate) * samps_to_send); + size_t num_tx_samps = samps_to_send; +#else //send a single packet size_t num_tx_samps = myTxStream->send( &in[num_acc_samps], samps_to_send, md, timeout); +#endif num_acc_samps += num_tx_samps; @@ -515,6 +549,7 @@ void UHDWorker::process() #endif } +#if FAKE_UHD == 0 uhd::async_metadata_t async_md; if (uwd->myUsrp->get_device()->recv_async_msg(async_md, 0)) { const char* uhd_async_message = ""; @@ -545,11 +580,12 @@ void UHDWorker::process() if (failure) { uwd->logger->level(alert) << "Near frame " << - frame->fct << ": Received Async UHD Message '" << + frame->ts.fct << ": Received Async UHD Message '" << uhd_async_message << "'"; } } +#endif /* bool got_async_burst_ack = false; diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 69e5b20..3a047bf 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -36,6 +36,8 @@ DESCRIPTION: #ifndef OUTPUT_UHD_H #define OUTPUT_UHD_H +#define FAKE_UHD 0 + #ifdef HAVE_CONFIG_H # include #endif @@ -77,15 +79,14 @@ struct UHDWorkerFrameData { // Full timestamp struct frame_timestamp ts; - - // Frame counter - uint32_t fct; }; enum refclk_lock_loss_behaviour_t { CRASH, IGNORE }; struct UHDWorkerData { +#if FAKE_UHD == 0 uhd::usrp::multi_usrp::sptr myUsrp; +#endif unsigned sampleRate; // Double buffering between the two threads @@ -117,7 +118,12 @@ struct UHDWorkerData { // The common logger Logger* logger; -}; + + // What transmission mode we're using defines by how + // much the FCT should increment for each + // transmission frame. + int fct_increment; +}; class UHDWorker { diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp index d6c627f..1bb4dd2 100644 --- a/src/TimestampDecoder.cpp +++ b/src/TimestampDecoder.cpp @@ -2,8 +2,10 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Includes modifications for which no copyright is claimed - 2012, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -45,6 +47,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) ts_queued->timestamp_valid = full_timestamp_received_mnsc; ts_queued->timestamp_sec = time_secs; ts_queued->timestamp_pps_offset = time_pps; + ts_queued->fct = latestFCT; ts_queued->timestamp_refresh = offset_changed; offset_changed = false; @@ -65,6 +68,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) ts.timestamp_sec = 0; ts.timestamp_pps_offset = 0; ts.timestamp_refresh = false; + ts.fct = 0; } else { //fprintf(stderr, ". %zu ", queue_timestamps.size()); @@ -179,13 +183,17 @@ void TimestampDecoder::updateTimestampPPS(double pps) } time_pps = pps; - } -void TimestampDecoder::updateTimestampEti(int framephase, uint16_t mnsc, double pps) +void TimestampDecoder::updateTimestampEti( + int framephase, + uint16_t mnsc, + double pps, + uint32_t fct) { updateTimestampPPS(pps); pushMNSCData(framephase, mnsc); + latestFCT = fct; } diff --git a/src/TimestampDecoder.h b/src/TimestampDecoder.h index 52290ac..0c393e4 100644 --- a/src/TimestampDecoder.h +++ b/src/TimestampDecoder.h @@ -2,8 +2,10 @@ Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) - Includes modifications for which no copyright is claimed - 2012, Matthias P. Braendli, matthias.braendli@mpb.li + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -52,6 +54,9 @@ struct modulator_offset_config struct frame_timestamp { + // Which frame count does this timestamp apply to + uint32_t fct; + uint32_t timestamp_sec; double timestamp_pps_offset; bool timestamp_valid; @@ -64,6 +69,7 @@ struct frame_timestamp this->timestamp_pps_offset = rhs.timestamp_pps_offset; this->timestamp_valid = rhs.timestamp_valid; this->timestamp_refresh = rhs.timestamp_refresh; + this->fct = rhs.fct; } return *this; @@ -104,7 +110,7 @@ struct frame_timestamp /* This module decodes MNSC time information */ class TimestampDecoder { - public: + public: TimestampDecoder( struct modulator_offset_config& config, Logger& logger): @@ -113,6 +119,7 @@ class TimestampDecoder inhibit_second_update = 0; time_pps = 0.0; time_secs = 0; + latestFCT = 0; enableDecode = false; full_timestamp_received_mnsc = false; gmtime_r(0, &temp_time); @@ -129,7 +136,11 @@ class TimestampDecoder void calculateTimestamp(struct frame_timestamp& ts); /* Update timestamp data from data in ETI */ - void updateTimestampEti(int framephase, uint16_t mnsc, double pps); + void updateTimestampEti( + int framephase, + uint16_t mnsc, + double pps, + uint32_t fct); /* Update the modulator timestamp offset according to the modconf */ @@ -147,7 +158,7 @@ class TimestampDecoder * the timestamp */ void updateTimestampPPS(double pps); - + /* Update the timestamp when a full set of MNSC data is * known. This function can be called at most every four * frames when the data is transferred using the MNSC. @@ -156,6 +167,7 @@ class TimestampDecoder struct tm temp_time; uint32_t time_secs; + uint32_t latestFCT; double time_pps; double timestamp_offset; int inhibit_second_update; -- cgit v1.2.3 From 11295eabfdb514b43918b8ac45945d36f81f4bd7 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 26 Sep 2014 11:23:53 +0200 Subject: Interrupt UHD when FCT value is not contiguous --- src/EtiReader.cpp | 6 ++++-- src/OutputUHD.cpp | 35 ++++++++++++++++------------------- src/TimestampDecoder.cpp | 20 ++++++++++++++------ 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/EtiReader.cpp b/src/EtiReader.cpp index f7376cc..fe54f55 100644 --- a/src/EtiReader.cpp +++ b/src/EtiReader.cpp @@ -297,11 +297,13 @@ bool EtiReader::sourceContainsTimestamp() double EtiReader::getPPSOffset() { - if (!sourceContainsTimestamp()) + if (!sourceContainsTimestamp()) { + //fprintf(stderr, "****** SOURCE NO TS\n"); return 0.0; + } uint32_t timestamp = ntohl(eti_tist.TIST) & 0xFFFFFF; - //fprintf(stderr, "TIST 0x%x\n", timestamp); + //fprintf(stderr, "****** TIST 0x%x\n", timestamp); double pps = timestamp / 16384000.0; // seconds return pps; diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 927d2e6..3d8eea6 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -346,7 +346,10 @@ void UHDWorker::process() md.start_of_burst = false; md.end_of_burst = false; + int expected_next_fct = -1; + while (running) { + bool fct_discontinuity = false; md.has_time_spec = false; md.time_spec = uhd::time_spec_t(0.0); num_acc_samps = 0; @@ -376,19 +379,20 @@ void UHDWorker::process() sizeIn = uwd->bufsize / sizeof(complexf); -#if FAKE_UHD + /* Verify that the FCT value is correct. If we miss one transmission + * frame we must interrupt UHD and resync to the timestamps + */ if (expected_next_fct != -1) { - if (expected_next_fct != frame->ts.fct) { + if (expected_next_fct != (int)frame->ts.fct) { uwd->logger->level(warn) << "OutputUHD: Incorrect expect fct " << frame->ts.fct; - // TODO here we should disrupt the UHD streamer so that - // it resyncs to the correct timestamps + fct_discontinuity = true; } } expected_next_fct = (frame->ts.fct + uwd->fct_increment) % 250; -#else + // Check for ref_lock if (uwd->check_refclk_loss) { @@ -482,7 +486,6 @@ void UHDWorker::process() goto loopend; } } -#endif PDEBUG("UHDWorker::process:max_num_samps: %zu.\n", usrp_max_num_samps); @@ -492,8 +495,13 @@ void UHDWorker::process() //ensure the the last packet has EOB set if the timestamps has been //refreshed and need to be reconsidered. - md.end_of_burst = (frame->ts.timestamp_refresh && - (samps_to_send <= usrp_max_num_samps)); + //Also, if we saw that the FCT did not increment as expected, which + //could be due to a lost incoming packet. + md.end_of_burst = ( + uwd->sourceContainsTimestamp && + (frame->ts.timestamp_refresh || fct_discontinuity) && + samps_to_send <= usrp_max_num_samps ); + #if FAKE_UHD // This is probably very approximate @@ -586,17 +594,6 @@ void UHDWorker::process() } } #endif - - /* - bool got_async_burst_ack = false; - //loop through all messages for the ACK packet (may have underflow messages in queue) - while (not got_async_burst_ack and uwd->myUsrp->get_device()->recv_async_msg(async_md, 0.2)){ - got_async_burst_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK); - } - //std::cerr << (got_async_burst_ack? "success" : "fail") << std::endl; - // */ - - } last_pps = pps_offset; diff --git a/src/TimestampDecoder.cpp b/src/TimestampDecoder.cpp index 1bb4dd2..96c84c0 100644 --- a/src/TimestampDecoder.cpp +++ b/src/TimestampDecoder.cpp @@ -35,7 +35,7 @@ #include "Eti.h" #include "Log.h" -//#define MDEBUG(fmt, args...) fprintf (LOG, fmt , ## args) +//#define MDEBUG(fmt, args...) fprintf (LOG, "*****" fmt , ## args) #define MDEBUG(fmt, args...) PDEBUG(fmt, ## args) @@ -52,6 +52,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) ts_queued->timestamp_refresh = offset_changed; offset_changed = false; + MDEBUG("time_secs=%d, time_pps=%f\n", time_secs, time_pps); *ts_queued += timestamp_offset; queue_timestamps.push(ts_queued); @@ -90,7 +91,7 @@ void TimestampDecoder::calculateTimestamp(struct frame_timestamp& ts) delete ts_queued; } - PDEBUG("Timestamp queue size %zu, delay_calc %u\n", + MDEBUG("Timestamp queue size %zu, delay_calc %u\n", queue_timestamps.size(), modconfig.delay_calculation_pipeline_stages); @@ -157,13 +158,14 @@ void TimestampDecoder::pushMNSCData(int framephase, uint16_t mnsc) void TimestampDecoder::updateTimestampSeconds(uint32_t secs) { - MDEBUG("TimestampDecoder::updateTimestampSeconds(%d)\n", secs); if (inhibit_second_update > 0) { + MDEBUG("TimestampDecoder::updateTimestampSeconds(%d) inhibit\n", secs); inhibit_second_update--; } else { + MDEBUG("TimestampDecoder::updateTimestampSeconds(%d) apply\n", secs); time_secs = secs; } } @@ -229,13 +231,16 @@ bool TimestampDecoder::updateModulatorOffset() } catch (bad_lexical_cast& e) { - myLogger.level(error) << "Error parsing timestamp offset from file '" << modconfig.offset_filename << "'"; + myLogger.level(error) << + "Error parsing timestamp offset from file '" << + modconfig.offset_filename << "'"; r = false; } } else { - myLogger.level(error) << "Error reading from timestamp offset file: eof reached\n"; + myLogger.level(error) << + "Error reading from timestamp offset file: eof reached\n"; r = false; } filestream.close(); @@ -252,7 +257,9 @@ bool TimestampDecoder::updateModulatorOffset() if (timestamp_offset != newoffset) { timestamp_offset = newoffset; - myLogger.level(info) << "TimestampDecoder::updateTimestampOffset: new offset is " << timestamp_offset; + myLogger.level(info) << + "TimestampDecoder::updateTimestampOffset: new offset is " << + timestamp_offset; offset_changed = true; } @@ -264,3 +271,4 @@ bool TimestampDecoder::updateModulatorOffset() return false; } } + -- cgit v1.2.3 From 398081ba13003b963f9ac9abc5c8df9b4968d3e9 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 26 Sep 2014 12:06:05 +0200 Subject: Prepare v0.4.5 --- ChangeLog | 7 +++++++ README | 2 +- configure.ac | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0d6a15c..28a9f04 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,13 @@ This file contains information about the changes done to the ODR-DabMod in this repository +2014-09-26: Matthias P. Braendli + (v0.4.5) + * odr-dabmod: + Change UHD normalisation to reduce risk of nonlinearities. + Add digital gain setting to RC. + Fix handling of timestamps when using ZMQ input, for the SFN + scenario. 2014-05-20: Matthias P. Braendli (v0.4.4) * odr-dabmod: diff --git a/README b/README index cf0039f..05290d9 100644 --- a/README +++ b/README @@ -14,7 +14,7 @@ In addition to the features of CRC-DabMod, this fork contains: - Timestamping support required for SFN - A FIR filter (previously done in GNURadio by crc-dwap.py) - Improvements in logging (log to file, to syslog) -- ETI sources: file (Raw, Framed and Streamed) and ZeroMQ (one frame per message) +- ETI sources: file (Raw, Framed and Streamed) and ZeroMQ - A Telnet remote-control that can be used to change some parameters during runtime diff --git a/configure.ac b/configure.ac index a6f9ac3..9b8bcb7 100644 --- a/configure.ac +++ b/configure.ac @@ -19,7 +19,7 @@ # along with ODR-DabMod. If not, see . AC_PREREQ(2.59) -AC_INIT([ODR-DabMod], [0.4.4], [matthias.braendli@mpb.li]) +AC_INIT([ODR-DabMod], [0.4.5], [matthias.braendli@mpb.li]) AC_CONFIG_AUX_DIR([build-aux]) AC_CANONICAL_SYSTEM AM_INIT_AUTOMAKE([-Wall]) -- cgit v1.2.3 From 3ae264aa4cf28ac8c860ad3f74fdc1c68b1a854e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 10 Oct 2014 14:06:51 +0200 Subject: Fix Non-SSE QpskSymbolMapper --- src/QpskSymbolMapper.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/QpskSymbolMapper.cpp b/src/QpskSymbolMapper.cpp index 2a8ebe9..05d847c 100644 --- a/src/QpskSymbolMapper.cpp +++ b/src/QpskSymbolMapper.cpp @@ -109,7 +109,6 @@ int QpskSymbolMapper::process(Buffer* const dataIn, Buffer* dataOut) inOffset += d_carriers / 8; } #else // !__SSE__ -#error "Code section not verified" const unsigned char* in = reinterpret_cast(dataIn->getData()); float* out = reinterpret_cast(dataOut->getData()); if (dataIn->getLength() % (d_carriers / 4) != 0) { @@ -142,7 +141,6 @@ int QpskSymbolMapper::process(Buffer* const dataIn, Buffer* dataOut) size_t inOffset = 0; size_t outOffset = 0; unsigned char tmp; - fprintf(stderr, "TODO: Validate QpskSymbolMapper::process without SSE\n"); for (size_t i = 0; i < dataIn->getLength(); i += d_carriers / 4) { for (size_t j = 0; j < d_carriers / 8; ++j) { tmp = (in[inOffset] & 0xc0) >> 4; @@ -150,15 +148,15 @@ int QpskSymbolMapper::process(Buffer* const dataIn, Buffer* dataOut) memcpy(&out[outOffset], symbols[tmp], sizeof(float) * 4); tmp = (in[inOffset] & 0x30) >> 2; tmp |= (in[inOffset + (d_carriers / 8)] & 0x30) >> 4; - memcpy(&out[outOffset + 1], symbols[tmp], sizeof(float) * 4); + memcpy(&out[outOffset + 4], symbols[tmp], sizeof(float) * 4); tmp = (in[inOffset] & 0x0c); tmp |= (in[inOffset + (d_carriers / 8)] & 0x0c) >> 2; - memcpy(&out[outOffset + 2], symbols[tmp], sizeof(float) * 4); + memcpy(&out[outOffset + 8], symbols[tmp], sizeof(float) * 4); tmp = (in[inOffset] & 0x03) << 2; tmp |= (in[inOffset + (d_carriers / 8)] & 0x03); - memcpy(&out[outOffset + 3], symbols[tmp], sizeof(float) * 4); + memcpy(&out[outOffset + 12], symbols[tmp], sizeof(float) * 4); ++inOffset; - outOffset += 4; + outOffset += 4*4; } inOffset += d_carriers / 8; } @@ -166,3 +164,4 @@ int QpskSymbolMapper::process(Buffer* const dataIn, Buffer* dataOut) return 1; } + -- cgit v1.2.3 From ea6f1557a0dd686fd74020509bdaadf689dd1c76 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 10 Oct 2014 12:11:31 +0000 Subject: Get compilation working on ARM --- configure.ac | 20 ++++++++++++++++++++ src/Buffer.cpp | 2 +- src/DabMod.cpp | 4 ++-- src/Flowgraph.cpp | 6 +++--- src/Makefile.am | 8 +++++++- src/Resampler.cpp | 6 +++--- 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 9b8bcb7..07d6195 100644 --- a/configure.ac +++ b/configure.ac @@ -133,6 +133,26 @@ AC_COMPILE_IFELSE( [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_DEFINE([M_PIl], [M_PI], [Replacing define])]) AC_LANG_POP([C++]) +# Check for SSE +AC_MSG_CHECKING(for SSE in current arch/CFLAGS) +AC_LINK_IFELSE([ +AC_LANG_PROGRAM([[ +#include +__m128 testfunc(float *a, float *b) { + return _mm_add_ps(_mm_loadu_ps(a), _mm_loadu_ps(b)); +} +]])], +[ +has_sse=yes +], +[ +has_sse=no +] +) +AC_MSG_RESULT($has_sse) + +AM_CONDITIONAL([HAVE_SSE], [test "x$has_sse" = "xyes"]) + AM_CONDITIONAL([IS_GIT_REPO], [test -d '.git']) AC_TYPE_SIGNAL diff --git a/src/Buffer.cpp b/src/Buffer.cpp index dff2623..aa0ef4c 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -26,7 +26,7 @@ #include #include #include -#ifdef HAVE_DECL__MM_MALLOC +#if HAVE_DECL__MM_MALLOC # include #else # define memalign(a, b) malloc(b) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 7ee65dc..67ad12d 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -56,11 +56,11 @@ #include #include -#ifdef HAVE_NETINET_IN_H +#if HAVE_NETINET_IN_H # include #endif -#ifdef HAVE_DECL__MM_MALLOC +#if HAVE_DECL__MM_MALLOC # include #else # define memalign(a, b) malloc(b) diff --git a/src/Flowgraph.cpp b/src/Flowgraph.cpp index 4e44f28..dd9c68b 100644 --- a/src/Flowgraph.cpp +++ b/src/Flowgraph.cpp @@ -23,10 +23,10 @@ #include "PcDebug.h" -#ifdef __ppc__ -# define memalign(a, b) malloc(b) -#else // !__ppc__ +#if HAVE_DECL__MM_MALLOC # include +#else +# define memalign(a, b) malloc(b) #endif #include #include diff --git a/src/Makefile.am b/src/Makefile.am index 3e851c4..f6102e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,12 @@ else UHD_SOURCES = endif +if HAVE_SSE +SIMD_CFLAGS = -msse -msse2 +else +SIMD_CFLAGS = +endif + FFT_DIR=$(top_builddir)/lib/kiss_fft129 FFT_INC=-I$(FFT_DIR) -I$(FFT_DIR)/tools FFT_SRC=$(FFT_DIR)/kiss_fft.c $(FFT_DIR)/kiss_fft.h $(FFT_DIR)/tools/kiss_fftr.c $(FFT_DIR)/tools/kiss_fftr.h kiss_fftsimd.c kiss_fftsimd.h @@ -52,7 +58,7 @@ $(FFT_DIR): tar xzf $(top_srcdir)/lib/kiss_fft129.tar.gz -C $(top_builddir)/lib; \ fi -odr_dabmod_CPPFLAGS = -Wall $(FFT_INC) $(FFT_FLG) -msse -msse2 $(GITVERSION_FLAGS) +odr_dabmod_CPPFLAGS = -Wall $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS) odr_dabmod_LDADD = $(ZMQ_LIBS) odr_dabmod_SOURCES = DabMod.cpp \ PcDebug.h \ diff --git a/src/Resampler.cpp b/src/Resampler.cpp index 773b9cc..334be99 100644 --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -23,10 +23,10 @@ #include "PcDebug.h" -#ifdef __ppc__ -# define memalign(a, b) malloc(b) -#else // !__ppc__ +#if HAVE_DECL__MM_MALLOC # include +#else +# define memalign(a, b) malloc(b) #endif #include #include -- cgit v1.2.3 From de6eb96c71873fb23f0847424dca724b933ee399 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 10 Oct 2014 18:17:18 +0200 Subject: Correct non-SSE VAR GainMode --- src/GainControl.cpp | 112 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 96 insertions(+), 16 deletions(-) diff --git a/src/GainControl.cpp b/src/GainControl.cpp index 6304de3..a34dcf2 100644 --- a/src/GainControl.cpp +++ b/src/GainControl.cpp @@ -224,13 +224,26 @@ __m128 GainControl::computeGainVar(const __m128* in, size_t sizeIn) __m128 i128 = _mm_set1_ps(sample + 1); __m128 q128 = _mm_div_ps(delta128, i128); mean128.m = _mm_add_ps(mean128.m, q128); + + /* + tmp128.m = in[sample]; + printf("S %zu, %.2f+%.2fj\t", + sample, + tmp128.f[0], tmp128.f[1]); + printf(": %.2f+%.2fj\n", mean128.f[0], mean128.f[1]); + + printf("S %zu, %.2f+%.2fj\t", + sample, + tmp128.f[2], tmp128.f[3]); + printf(": %.2f+%.2fj\n", mean128.f[2], mean128.f[3]); + */ } // Merging average tmp128.m = _mm_shuffle_ps(mean128.m, mean128.m, _MM_SHUFFLE(1, 0, 3, 2)); mean128.m = _mm_add_ps(mean128.m, tmp128.m); mean128.m = _mm_mul_ps(mean128.m, _mm_set1_ps(0.5f)); - PDEBUG("********** Mean: %10f, %10f, %10f, %10f **********\n", + PDEBUG("********** Mean: %10f + %10fj %10f + %10fj **********\n", mean128.f[0], mean128.f[1], mean128.f[2], mean128.f[3]); //////////////////////////////////////////////////////////////////////// @@ -243,16 +256,32 @@ __m128 GainControl::computeGainVar(const __m128* in, size_t sizeIn) __m128 i128 = _mm_set1_ps(sample + 1); __m128 q128 = _mm_div_ps(delta128, i128); var128.m = _mm_add_ps(var128.m, q128); + + /* + __u128 udiff128; udiff128.m = diff128; + __u128 udelta128; udelta128.m = delta128; + for (int off=0; off<4; off+=2) { + printf("S %zu, %.2f+%.2fj\t", + sample, + udiff128.f[off], udiff128.f[1+off]); + printf(": %.2f+%.2fj\t", udelta128.f[off], udelta128.f[1+off]); + printf(": %.2f+%.2fj\n", var128.f[off], var128.f[1+off]); + } + */ + } - // Merging average + PDEBUG("********** Vars: %10f + %10fj, %10f + %10fj **********\n", + var128.f[0], var128.f[1], var128.f[2], var128.f[3]); + + // Merging standard deviations tmp128.m = _mm_shuffle_ps(var128.m, var128.m, _MM_SHUFFLE(1, 0, 3, 2)); var128.m = _mm_add_ps(var128.m, tmp128.m); var128.m = _mm_mul_ps(var128.m, _mm_set1_ps(0.5f)); var128.m = _mm_sqrt_ps(var128.m); - PDEBUG("********** Var: %10f, %10f, %10f, %10f **********\n", + PDEBUG("********** Var: %10f + %10fj, %10f + %10fj **********\n", var128.f[0], var128.f[1], var128.f[2], var128.f[3]); var128.m = _mm_mul_ps(var128.m, _mm_set1_ps(4.0f)); - PDEBUG("********** 4*Var: %10f, %10f, %10f, %10f **********\n", + PDEBUG("********** 4*Var: %10f + %10fj, %10f + %10fj **********\n", var128.f[0], var128.f[1], var128.f[2], var128.f[3]); //////////////////////////////////////////////////////////////////////////// @@ -333,7 +362,17 @@ float GainControl::computeGainVar(const complexf* in, size_t sizeIn) { float gain; complexf mean; - complexf var; + + /* The variance calculation is a bit strange, because we + * emulate the exact same functionality as the SSE code, + * which is the most used one. + * + * TODO: verify that this actually corresponds to the + * gain mode suggested in EN 300 798 Clause 5.3 Numerical Range. + */ + complexf var1; + complexf var2; + static const float factor = 0x7fff; mean = complexf(0.0f, 0.0f); @@ -343,25 +382,66 @@ float GainControl::computeGainVar(const complexf* in, size_t sizeIn) float i = sample + 1; complexf q = delta / i; mean = mean + q; + + /* + printf("F %zu, %.2f+%.2fj\t", + sample, + in[sample].real(), in[sample].imag()); + + printf(": %.2f+%.2fj\n", mean.real(), mean.imag()); + */ } - PDEBUG("********** Mean: %10f, %10f **********\n", mean.real(), mean.imag()); + PDEBUG("********** Mean: %10f + %10fj **********\n", mean.real(), mean.imag()); //////////////////////////////////////////////////////////////////////// // Computing standard deviation //////////////////////////////////////////////////////////////////////// - var = complexf(0.0f, 0.0f); + var1 = complexf(0.0f, 0.0f); + var2 = complexf(0.0f, 0.0f); for (size_t sample = 0; sample < sizeIn; ++sample) { complexf diff = in[sample] - mean; - complexf delta = complexf(diff.real() * diff.real(), - diff.imag() * diff.imag()) - var; - float i = sample + 1; - complexf q = delta / i; - var = var + q; + complexf delta; + complexf q; + + float i = (sample/2) + 1; + if (sample % 2 == 0) { + delta = complexf(diff.real() * diff.real(), + diff.imag() * diff.imag()) - var1; + q = delta / i; + + var1 += q; + } + else { + delta = complexf(diff.real() * diff.real(), + diff.imag() * diff.imag()) - var2; + q = delta / i; + + var2 += q; + } + + /* + printf("F %zu, %.2f+%.2fj\t", + sample, + diff.real(), diff.imag()); + + printf(": %.2f+%.2fj\t", delta.real(), delta.imag()); + printf(": %.2f+%.2fj\t", var1.real(), var1.imag()); + printf(": %.2f+%.2fj\n", var2.real(), var2.imag()); + */ } - PDEBUG("********** Var: %10f, %10f **********\n", var.real(), var.imag()); + + PDEBUG("********** Vars: %10f + %10fj, %10f + %10fj **********\n", + var1.real(), var1.imag(), + var2.real(), var2.imag()); + + // Merge standard deviations in the same way the SSE version does it + complexf tmpvar = (var1 + var2) * 0.5f; + complexf var(sqrt(tmpvar.real()), sqrt(tmpvar.imag())); + PDEBUG("********** Var: %10f + %10fj **********\n", var.real(), var.imag()); + var = var * 4.0f; - PDEBUG("********** 4*Var: %10f, %10f **********\n", var.real(), var.imag()); + PDEBUG("********** 4*Var: %10f + %10fj **********\n", var.real(), var.imag()); //////////////////////////////////////////////////////////////////////////// // Computing gain @@ -372,10 +452,10 @@ float GainControl::computeGainVar(const complexf* in, size_t sizeIn) } // Detect NULL if ((int)var.real() == 0) { - gain = factor / var.real(); + gain = 1.0f; } else { - gain = 1.0f; + gain = factor / var.real(); } return gain; -- cgit v1.2.3 From fc199a7284c5f3a5a84631583ea704748d50b28e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 24 Oct 2014 16:20:20 +0200 Subject: Add possibility to use FFTW for OfdmGenerator --- configure.ac | 48 ++++++++++++++++++++++++++++- src/Makefile.am | 13 ++++++-- src/OfdmGenerator.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++++++---- src/OfdmGenerator.h | 20 ++++++++++-- 4 files changed, 153 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index 07d6195..9a1816a 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,9 @@ AC_ARG_ENABLE([trace], AC_ARG_ENABLE([fft_simd], [AS_HELP_STRING([--enable-fft-simd], [Enable SIMD instructions for kiss-fft (unstable)])], [], [enable_fft_simd=no]) +AC_ARG_ENABLE([fftw], + [AS_HELP_STRING([--enable-fftw], [Use FFTW3 instead of Kiss FFT])], + [], [enable_fftw=no]) # ZeroMQ message queue input AC_ARG_ENABLE([input_zeromq], AS_HELP_STRING([--enable-input-zeromq], [Enable ZeroMQ input])) @@ -83,6 +86,10 @@ AS_IF([test "x$enable_trace" != "xno"], [EXTRA="$EXTRA -DDEBUG"]) AS_IF([test "x$enable_fft_simd" != "xno"], [EXTRA="$EXTRA -DUSE_SIMD"]) +AS_IF([test "x$enable_fftw" != "xno"], + [EXTRA="$EXTRA -DUSE_FFTW"]) + +AM_CONDITIONAL([USE_KISS_FFT], [test "x$enable_fftw" = "xno"]) AM_CONDITIONAL([HAVE_INPUT_ZEROMQ_TEST], [test "x$enable_input_zeromq" = "xyes"]) @@ -90,6 +97,7 @@ AM_CONDITIONAL([HAVE_INPUT_ZEROMQ_TEST], [test "x$enable_input_zeromq" = "xyes"] AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA"]) AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA"]) +# Checks for libraries. AS_IF([test "x$enable_output_uhd" = "xyes"], [AC_DEFINE(HAVE_OUTPUT_UHD, [1], [Define if UHD output is enabled]) , AC_CHECK_LIB([uhd], [main], [], [AC_MSG_ERROR([library uhd is missing])])]) @@ -102,7 +110,11 @@ AC_CHECK_LIB([boost_thread], [main], [], [AC_MSG_ERROR([library boost_thread is AC_CHECK_LIB([rt], [clock_gettime], [], [AC_MSG_ERROR([library rt is missing])]) -# Checks for libraries. +AS_IF([test "x$enable_fftw" != "xno"], + [AC_CHECK_LIB([fftw3f], [fftw_execute], + AC_MSG_NOTICE([Found FFTW3]), + AC_MSG_NOTICE([Failed to find FFTW3]) )] ) + AS_IF([test "x$enable_debug" != "xno"], [AS_IF([test "x$with_debug_malloc" != "xno"], [AS_IF([test "x$with_debug_malloc" = "xyes"], @@ -162,3 +174,37 @@ AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile]) AC_OUTPUT + +echo +echo "***********************************************" +echo +enabled="" +disabled="" +for feat in debug prof trace fftw fft_simd output_uhd input_zeromq +do + eval var=\$enable_$feat + AS_IF([test "x$var" = "xyes"], + [enabled="$enabled $feat"], + [disabled="$disabled $feat"]) +done +echo " Features" +echo " Enabled: $enabled" +echo " Disabled: $disabled" +echo +echo +enabled="" +disabled="" +for feat in with_debug_malloc has_sse +do + eval var=\$$feat + AS_IF([test "x$var" = "xyes"], + [enabled="$enabled $feat"], + [disabled="$disabled $feat"]) +done +echo " Options" +echo " Active: $enabled" +echo " Disabled: $disabled" + +echo +echo "***********************************************" +echo diff --git a/src/Makefile.am b/src/Makefile.am index f6102e9..b7095c8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,6 +40,8 @@ else SIMD_CFLAGS = endif +bin_PROGRAMS = odr-dabmod + FFT_DIR=$(top_builddir)/lib/kiss_fft129 FFT_INC=-I$(FFT_DIR) -I$(FFT_DIR)/tools FFT_SRC=$(FFT_DIR)/kiss_fft.c $(FFT_DIR)/kiss_fft.h $(FFT_DIR)/tools/kiss_fftr.c $(FFT_DIR)/tools/kiss_fftr.h kiss_fftsimd.c kiss_fftsimd.h @@ -47,19 +49,23 @@ FFT_FLG=-ffast-math .PHONY: kiss_fft129 reed-solomon-4.0 -bin_PROGRAMS = odr-dabmod - DabModulator.cpp: $(FFT_DIR) BUILT_SOURCES: $(FFT_DIR) +if USE_KISS_FFT +FFT_LDADD= +else +FFT_LDADD=-lfftw3f -lm +endif + $(FFT_DIR): if [ ! -e $(FFT_DIR) ]; then \ tar xzf $(top_srcdir)/lib/kiss_fft129.tar.gz -C $(top_builddir)/lib; \ fi odr_dabmod_CPPFLAGS = -Wall $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS) -odr_dabmod_LDADD = $(ZMQ_LIBS) +odr_dabmod_LDADD = $(ZMQ_LIBS) $(FFT_LDADD) odr_dabmod_SOURCES = DabMod.cpp \ PcDebug.h \ porting.c porting.h \ @@ -114,3 +120,4 @@ EXTRA_DIST =kiss_fftsimd.c kiss_fftsimd.h clean-local: rm -rf $(FFT_DIR) + diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp index c7e8ebf..90527d4 100644 --- a/src/OfdmGenerator.cpp +++ b/src/OfdmGenerator.cpp @@ -1,6 +1,11 @@ /* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -21,9 +26,15 @@ #include "OfdmGenerator.h" #include "PcDebug.h" -#include "kiss_fftsimd.h" +#if USE_FFTW +# include "fftw3.h" +# define FFT_TYPE fftwf_complex +#else +# include "kiss_fftsimd.h" +#endif #include +#include #include #include #include @@ -37,7 +48,11 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols, ModCodec(ModFormat(nbSymbols * nbCarriers * sizeof(FFT_TYPE)), ModFormat(nbSymbols * spacing * sizeof(FFT_TYPE))), myFftPlan(NULL), +#if USE_FFTW + myFftIn(NULL), myFftOut(NULL), +#else myFftBuffer(NULL), +#endif myNbSymbols(nbSymbols), myNbCarriers(nbCarriers), mySpacing(spacing) @@ -57,7 +72,8 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols, myNegDst = spacing - (nbCarriers / 2); myNegSrc = (nbCarriers + 1) / 2; myNegSize = nbCarriers / 2; - } else { + } + else { myPosDst = (nbCarriers & 1 ? 0 : 1); myPosSrc = nbCarriers / 2; myPosSize = (nbCarriers + 1) / 2; @@ -77,8 +93,25 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols, PDEBUG(" myZeroDst: %u\n", myZeroDst); PDEBUG(" myZeroSize: %u\n", myZeroSize); +#if USE_FFTW + const int N = mySpacing; // The size of the FFT + myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N); + myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * N); + myFftPlan = fftwf_plan_dft_1d(N, + myFftIn, myFftOut, + FFTW_BACKWARD, FFTW_MEASURE); + + if (sizeof(complexf) != sizeof(FFT_TYPE)) { + printf("sizeof(complexf) %d\n", sizeof(complexf)); + printf("sizeof(FFT_TYPE) %d\n", sizeof(FFT_TYPE)); + throw std::runtime_error( + "OfdmGenerator::process complexf size is not FFT_TYPE size!"); + } +#else myFftPlan = kiss_fft_alloc(mySpacing, 1, NULL, NULL); myFftBuffer = (FFT_TYPE*)memalign(16, mySpacing * sizeof(FFT_TYPE)); +#endif + } @@ -86,16 +119,32 @@ OfdmGenerator::~OfdmGenerator() { PDEBUG("OfdmGenerator::~OfdmGenerator() @ %p\n", this); +#if USE_FFTW + if (myFftIn) { + fftwf_free(myFftIn); + } + + if (myFftOut) { + fftwf_free(myFftOut); + } + + if (myFftPlan) { + fftwf_destroy_plan(myFftPlan); + } + +#else if (myFftPlan != NULL) { kiss_fft_free(myFftPlan); } + if (myFftBuffer != NULL) { free(myFftBuffer); } + kiss_fft_cleanup(); +#endif } - int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) { PDEBUG("OfdmGenerator::process(dataIn: %p, dataOut: %p)\n", @@ -105,6 +154,7 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) FFT_TYPE* in = reinterpret_cast(dataIn->getData()); FFT_TYPE* out = reinterpret_cast(dataOut->getData()); + size_t sizeIn = dataIn->getLength() / sizeof(complexf); size_t sizeOut = dataOut->getLength() / sizeof(complexf); @@ -125,7 +175,27 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) "OfdmGenerator::process output size not valid!"); } -#ifdef USE_SIMD +#if USE_FFTW + // No SIMD/no-SIMD distinction, it's too early to optimize anything + for (size_t i = 0; i < myNbSymbols; ++i) { + myFftIn[0][0] = 0; + myFftIn[0][1] = 0; + + bzero(&myFftIn[myZeroDst], myZeroSize * sizeof(FFT_TYPE)); + memcpy(&myFftIn[myPosDst], &in[myPosSrc], + myPosSize * sizeof(FFT_TYPE)); + memcpy(&myFftIn[myNegDst], &in[myNegSrc], + myNegSize * sizeof(FFT_TYPE)); + + fftwf_execute(myFftPlan); + + memcpy(out, myFftOut, mySpacing * sizeof(FFT_TYPE)); + + in += myNbCarriers; + out += mySpacing; + } +#else +# ifdef USE_SIMD for (size_t i = 0, j = 0; i < sizeIn; ) { // Pack 4 fft operations typedef struct { @@ -154,7 +224,8 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) dataBuffer[myNegDst + l].i[k] = cplxIn[i + myNegSrc + l].imag(); } i += myNbCarriers; - } else { + } + else { for (size_t l = 0; l < myNbCarriers; ++l) { dataBuffer[l].r[k] = 0.0f; dataBuffer[l].i[k] = 0.0f; @@ -174,7 +245,7 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) } } } -#else +# else for (size_t i = 0; i < myNbSymbols; ++i) { FFT_REAL(myFftBuffer[0]) = 0; FFT_IMAG(myFftBuffer[0]) = 0; @@ -189,7 +260,9 @@ int OfdmGenerator::process(Buffer* const dataIn, Buffer* dataOut) in += myNbCarriers; out += mySpacing; } +# endif #endif return sizeOut; } + diff --git a/src/OfdmGenerator.h b/src/OfdmGenerator.h index 5be2d03..ec9f14a 100644 --- a/src/OfdmGenerator.h +++ b/src/OfdmGenerator.h @@ -1,6 +1,11 @@ /* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -28,10 +33,14 @@ #include "porting.h" #include "ModCodec.h" -#include "kiss_fftsimd.h" +#if USE_FFTW +# include "fftw3.h" +#else +# include "kiss_fftsimd.h" +# include +#endif -#include #include @@ -48,8 +57,13 @@ public: const char* name() { return "OfdmGenerator"; } protected: +#if USE_FFTW + fftwf_plan myFftPlan; + fftwf_complex *myFftIn, *myFftOut; +#else FFT_PLAN myFftPlan; FFT_TYPE *myFftBuffer; +#endif size_t myNbSymbols; size_t myNbCarriers; size_t mySpacing; @@ -63,5 +77,5 @@ protected: unsigned myZeroSize; }; - #endif // OFDM_GENERATOR_H + -- cgit v1.2.3 From dd429ea2a7d98ba3a6b5806734db347a1bed1924 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 24 Oct 2014 17:10:52 +0200 Subject: Make KISS entirely optional The Resampler block can also use fftw, and the Makefile only does the kiss fft compilation when --enable-fftw is not given. --- src/GainControl.cpp | 10 ++++- src/Makefile.am | 9 ++++- src/OfdmGenerator.cpp | 4 +- src/Resampler.cpp | 102 +++++++++++++++++++++++++++++++++----------------- src/Resampler.h | 22 ++++++++--- src/kiss_fftsimd.h | 8 ---- 6 files changed, 103 insertions(+), 52 deletions(-) diff --git a/src/GainControl.cpp b/src/GainControl.cpp index a34dcf2..03d8aa6 100644 --- a/src/GainControl.cpp +++ b/src/GainControl.cpp @@ -27,12 +27,20 @@ #include "GainControl.h" #include "PcDebug.h" -#include "kiss_fftsimd.h" #include #include #include +#ifdef __SSE__ +# include +union __u128 { + __m128 m; + float f[4]; +}; +#endif + + using namespace std; diff --git a/src/Makefile.am b/src/Makefile.am index b7095c8..3d1eefc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -42,6 +42,7 @@ endif bin_PROGRAMS = odr-dabmod +if USE_KISS_FFT FFT_DIR=$(top_builddir)/lib/kiss_fft129 FFT_INC=-I$(FFT_DIR) -I$(FFT_DIR)/tools FFT_SRC=$(FFT_DIR)/kiss_fft.c $(FFT_DIR)/kiss_fft.h $(FFT_DIR)/tools/kiss_fftr.c $(FFT_DIR)/tools/kiss_fftr.h kiss_fftsimd.c kiss_fftsimd.h @@ -53,10 +54,13 @@ DabModulator.cpp: $(FFT_DIR) BUILT_SOURCES: $(FFT_DIR) -if USE_KISS_FFT FFT_LDADD= else FFT_LDADD=-lfftw3f -lm +FFT_DIR= +FFT_INC= +FFT_SRC= +FFT_FLG= endif $(FFT_DIR): @@ -116,8 +120,11 @@ nodist_odr_dabmod_SOURCES =$(FFT_SRC) dist_bin_SCRIPTS =crc-dwap.py +if USE_KISS_FFT EXTRA_DIST =kiss_fftsimd.c kiss_fftsimd.h clean-local: rm -rf $(FFT_DIR) +endif + diff --git a/src/OfdmGenerator.cpp b/src/OfdmGenerator.cpp index 90527d4..7044249 100644 --- a/src/OfdmGenerator.cpp +++ b/src/OfdmGenerator.cpp @@ -102,8 +102,8 @@ OfdmGenerator::OfdmGenerator(size_t nbSymbols, FFTW_BACKWARD, FFTW_MEASURE); if (sizeof(complexf) != sizeof(FFT_TYPE)) { - printf("sizeof(complexf) %d\n", sizeof(complexf)); - printf("sizeof(FFT_TYPE) %d\n", sizeof(FFT_TYPE)); + printf("sizeof(complexf) %zu\n", sizeof(complexf)); + printf("sizeof(FFT_TYPE) %zu\n", sizeof(FFT_TYPE)); throw std::runtime_error( "OfdmGenerator::process complexf size is not FFT_TYPE size!"); } diff --git a/src/Resampler.cpp b/src/Resampler.cpp index 334be99..cda4ff4 100644 --- a/src/Resampler.cpp +++ b/src/Resampler.cpp @@ -1,6 +1,11 @@ /* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -22,17 +27,16 @@ #include "Resampler.h" #include "PcDebug.h" - -#if HAVE_DECL__MM_MALLOC -# include -#else -# define memalign(a, b) malloc(b) -#endif +#include #include #include #include #include +#if USE_FFTW +# define FFT_REAL(x) x[0] +# define FFT_IMAG(x) x[1] +#endif unsigned gcd(unsigned a, unsigned b) { @@ -59,6 +63,9 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : { PDEBUG("Resampler::Resampler(%zu, %zu) @ %p\n", inputRate, outputRate, this); +#if USE_FFTW + fprintf(stderr, "This software uses the FFTW library.\n\n"); +#else fprintf(stderr, "This software uses KISS FFT.\n\n"); fprintf(stderr, "Copyright (c) 2003-2004 Mark Borgerding\n" "\n" @@ -92,6 +99,7 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : "OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY " "OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE " "POSSIBILITY OF SUCH DAMAGE.\n"); +#endif size_t divisor = gcd(inputRate, outputRate); L = outputRate / divisor; @@ -119,6 +127,22 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : PDEBUG("Window[%zu] = %f\n", i, myWindow[i]); } +#if USE_FFTW + myFftIn = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn); + myFront = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn); + myFftPlan1 = fftwf_plan_dft_1d(myFftSizeIn, + myFftIn, myFront, + FFTW_FORWARD, FFTW_MEASURE); + + myBack = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut); + myFftOut = (FFT_TYPE*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut); + myFftPlan2 = fftwf_plan_dft_1d(myFftSizeOut, + myBack, myFftOut, + FFTW_BACKWARD, FFTW_MEASURE); + + myBufferIn = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeIn / 2); + myBufferOut = (complexf*)fftwf_malloc(sizeof(FFT_TYPE) * myFftSizeOut / 2); +#else myFftIn = (FFT_TYPE*)memalign(16, myFftSizeIn * sizeof(FFT_TYPE)); myFftOut = (FFT_TYPE*)memalign(16, myFftSizeOut * sizeof(FFT_TYPE)); myBufferIn = (complexf*)memalign(16, myFftSizeIn / 2 * sizeof(FFT_TYPE)); @@ -127,6 +151,7 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) : myBack = (FFT_TYPE*)memalign(16, myFftSizeOut * sizeof(FFT_TYPE)); myFftPlan1 = kiss_fft_alloc(myFftSizeIn, 0, NULL, NULL); myFftPlan2 = kiss_fft_alloc(myFftSizeOut, 1, NULL, NULL); +#endif memset(myBufferIn, 0, myFftSizeIn / 2 * sizeof(FFT_TYPE)); memset(myBufferOut, 0, myFftSizeOut / 2 * sizeof(FFT_TYPE)); @@ -137,34 +162,30 @@ Resampler::~Resampler() { PDEBUG("Resampler::~Resampler() @ %p\n", this); - if (myFftPlan1 != NULL) { - free(myFftPlan1); - } - if (myFftPlan2 != NULL) { - free(myFftPlan2); - } - if (myFftIn != NULL) { - free(myFftIn); - } - if (myFftOut != NULL) { - free(myFftOut); - } - if (myBufferIn != NULL) { - free(myBufferIn); - } - if (myBufferOut != NULL) { - free(myBufferOut); - } - if (myFront != NULL) { - free(myFront); - } - if (myBack != NULL) { - free(myBack); - } - if (myWindow != NULL) { - free(myWindow); - } +#if USE_FFTW + if (myFftPlan1 != NULL) { fftwf_free(myFftPlan1); } + if (myFftPlan2 != NULL) { fftwf_free(myFftPlan2); } + if (myFftIn != NULL) { fftwf_free(myFftIn); } + if (myFftOut != NULL) { fftwf_free(myFftOut); } + if (myBufferIn != NULL) { fftwf_free(myBufferIn); } + if (myBufferOut != NULL) { fftwf_free(myBufferOut); } + if (myFront != NULL) { fftwf_free(myFront); } + if (myBack != NULL) { fftwf_free(myBack); } + if (myWindow != NULL) { fftwf_free(myWindow); } + fftwf_destroy_plan(myFftPlan1); + fftwf_destroy_plan(myFftPlan2); +#else + if (myFftPlan1 != NULL) { free(myFftPlan1); } + if (myFftPlan2 != NULL) { free(myFftPlan2); } + if (myFftIn != NULL) { free(myFftIn); } + if (myFftOut != NULL) { free(myFftOut); } + if (myBufferIn != NULL) { free(myBufferIn); } + if (myBufferOut != NULL) { free(myBufferOut); } + if (myFront != NULL) { free(myFront); } + if (myBack != NULL) { free(myBack); } + if (myWindow != NULL) { free(myWindow); } kiss_fft_cleanup(); +#endif } @@ -179,7 +200,7 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut) FFT_TYPE* out = reinterpret_cast(dataOut->getData()); size_t sizeIn = dataIn->getLength() / sizeof(complexf); -#ifdef USE_SIMD +#if defined(USE_SIMD) && !USE_FFTW size_t sizeOut = dataOut->getLength() / sizeof(complexf); typedef struct { @@ -263,7 +284,9 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut) j += myFftSizeOut / 2; } } -#else +#endif + +#if USE_FFTW || (!defined(USE_SIMD)) for (size_t i = 0, j = 0; i < sizeIn; i += myFftSizeIn / 2, j += myFftSizeOut / 2) { memcpy(myFftIn, myBufferIn, myFftSizeIn / 2 * sizeof(FFT_TYPE)); memcpy(myFftIn + (myFftSizeIn / 2), in + i, myFftSizeIn / 2 * sizeof(FFT_TYPE)); @@ -273,7 +296,11 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut) FFT_IMAG(myFftIn[k]) *= myWindow[k]; } +#if USE_FFTW + fftwf_execute(myFftPlan1); +#else kiss_fft(myFftPlan1, myFftIn, myFront); +#endif if (myFftSizeOut > myFftSizeIn) { memset(myBack, 0, myFftSizeOut * sizeof(FFT_TYPE)); @@ -304,7 +331,11 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut) FFT_IMAG(myBack[k]) *= myFactor; } +#if USE_FFTW + fftwf_execute(myFftPlan2); +#else kiss_fft(myFftPlan2, myBack, myFftOut); +#endif for (size_t k = 0; k < myFftSizeOut / 2; ++k) { FFT_REAL(out[j + k]) = myBufferOut[k].real() + FFT_REAL(myFftOut[k]); @@ -316,3 +347,4 @@ int Resampler::process(Buffer* const dataIn, Buffer* dataOut) return 1; } + diff --git a/src/Resampler.h b/src/Resampler.h index a19b14e..392d0a6 100644 --- a/src/Resampler.h +++ b/src/Resampler.h @@ -1,6 +1,11 @@ /* Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org */ /* This file is part of ODR-DabMod. @@ -28,12 +33,19 @@ #include "porting.h" #include "ModCodec.h" -#include "kiss_fftsimd.h" +#if USE_FFTW +# include +# include +# define FFT_TYPE fftwf_complex +# define FFT_PLAN fftwf_plan -#include -#include -#include +#else +# include "kiss_fftsimd.h" +# include +# include +# include +#endif #include typedef std::complex complexf; @@ -68,5 +80,5 @@ protected: float myFactor; }; - #endif // RESAMPLER_H + diff --git a/src/kiss_fftsimd.h b/src/kiss_fftsimd.h index 6d38dc7..90ee435 100644 --- a/src/kiss_fftsimd.h +++ b/src/kiss_fftsimd.h @@ -36,14 +36,6 @@ #define FFT_IMAG(a) (a).i -#ifdef __SSE__ -#include -union __u128 { - __m128 m; - float f[4]; -}; -#endif - #ifdef USE_SIMD -- cgit v1.2.3 From dbff069499ba0832b780eabd1271902569f4e27b Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 24 Oct 2014 22:45:12 +0200 Subject: Update INSTALL and mention FFTW --- INSTALL | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/INSTALL b/INSTALL index f591f02..d717e97 100644 --- a/INSTALL +++ b/INSTALL @@ -4,6 +4,8 @@ Required dependencies: * Boost 1.41 or later * Optional ZeroMQ http://www.zeromq.org Use --disable-input-zeromq if you don't have it + * Optional FFTW 3.x (KISS FFT is default) + Enable with --enable-fftw Simple install procedure: ========================= @@ -16,22 +18,40 @@ Simple install procedure: [ as root ] % make install # Install ODR-DabMod +Configure options +================= +The configure script can be launch with a variety of options: + + --enable-input-zeromq Enable ZeroMQ input (to be used with ODR-DabMux) + --enable-output-uhd Includes the binding to the UHD driver for USRPs + +You have the choice between two FFT libraries: KISS FFT and FFTW. KISS FFT is a +proven library, but it's performance is worse than with the new FFTW. With the +default KISS FFT, you have the choice between using the normal version, or the +SIMD accelerated version, which is a bit faster. The corresponding options are: + + --enable-fftw Use FFTW3 instead of KISS FFT (experimental, better performance) + --enable-fft-simd Enable SIMD instructions for KISS FFT + +Debugging options: You should disable debug to improve ODR-DabMod performance. +By default, debug is enabled. + --disable-debug Do not compile with debugging, and enable optimisations + --enable-trace Create debugging files for each DSP block for data analysis + +For more information, call: + + % ./configure --help + Nearly as simple install procedure using repository: ==================================================== * Download and install fec as above * Clone the git repository * Bootstrap autotools: + % ./bootstrap.sh + In case this fails, try one of the following: % aclocal && automake --gnu --add-missing && autoconf or % autoreconf - whichever works best * Then use ./configure as above - -Advanced install procedure: -=========================== - -The configure script can be launch with a variety of options, launch the -following command for a complete list: - % ./configure --help -- cgit v1.2.3 From a44fd411b55c773f6b251c54b96a8f8d9de4fc75 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 27 Oct 2014 20:08:04 +0100 Subject: Refactor autoconf, make FFTW default --- INSTALL | 25 ++++++------- configure.ac | 68 +++++++++++++++++++++------------- src/Makefile.am | 113 ++++++++++++++++++++++++++++++-------------------------- 3 files changed, 113 insertions(+), 93 deletions(-) diff --git a/INSTALL b/INSTALL index d717e97..55385ba 100644 --- a/INSTALL +++ b/INSTALL @@ -4,15 +4,14 @@ Required dependencies: * Boost 1.41 or later * Optional ZeroMQ http://www.zeromq.org Use --disable-input-zeromq if you don't have it - * Optional FFTW 3.x (KISS FFT is default) - Enable with --enable-fftw + * Optional FFTW 3.x (included KISS FFT is used as fallback) Simple install procedure: ========================= % tar xjf odr-dabmod-X.Y.Z.tar.bz2 # Unpack the source % cd odr-dabmod-X.Y.Z # Change to the source directory - % ./configure --disable-debug --with-debug-malloc=yes --enable-fft-simd + % ./configure --disable-debug --with-debug-malloc=yes # Run the configure script % make # Build ODR-DabMod [ as root ] @@ -26,16 +25,16 @@ The configure script can be launch with a variety of options: --enable-output-uhd Includes the binding to the UHD driver for USRPs You have the choice between two FFT libraries: KISS FFT and FFTW. KISS FFT is a -proven library, but it's performance is worse than with the new FFTW. With the -default KISS FFT, you have the choice between using the normal version, or the -SIMD accelerated version, which is a bit faster. The corresponding options are: +proven library, but it's performance is worse than with the new FFTW. With KISS +FFT, you have the choice between using the normal version, or the SIMD +accelerated version, which is a bit faster. The corresponding options are: - --enable-fftw Use FFTW3 instead of KISS FFT (experimental, better performance) + --enable-kiss-fft Prefer KISS FFT over FFTW --enable-fft-simd Enable SIMD instructions for KISS FFT -Debugging options: You should disable debug to improve ODR-DabMod performance. -By default, debug is enabled. - --disable-debug Do not compile with debugging, and enable optimisations +Debugging options: You should not enable debug if you need good performance. +By default, debug is disabled. + --enable-debug Do not compile with debugging, and enable optimisations --enable-trace Create debugging files for each DSP block for data analysis For more information, call: @@ -45,13 +44,11 @@ For more information, call: Nearly as simple install procedure using repository: ==================================================== - * Download and install fec as above + * Download and install dependencies as above * Clone the git repository * Bootstrap autotools: % ./bootstrap.sh - In case this fails, try one of the following: + In case this fails, try: % aclocal && automake --gnu --add-missing && autoconf - or - % autoreconf * Then use ./configure as above diff --git a/configure.ac b/configure.ac index 9a1816a..9826a91 100644 --- a/configure.ac +++ b/configure.ac @@ -48,56 +48,74 @@ AC_PROG_MKDIR_P EXTRA="" AC_ARG_ENABLE([debug], - [AS_HELP_STRING([--disable-debug], [Disable debugger symbols])], - [], [enable_debug=yes]) + [AS_HELP_STRING([--enable-debug], [Enable debugger symbols])], + [], [enable_debug=no]) AC_ARG_ENABLE([prof], [AS_HELP_STRING([--enable-prof], [Enable profiling])], [], [enable_prof=no]) AC_ARG_WITH([debug-malloc], - [AS_HELP_STRING([--with-debug-malloc[=yes|no|duma|efence|...]], + [AS_HELP_STRING([--with-debug-malloc[=no|yes|duma|efence|...]], [Add malloc debugger support])], - [], [with_debug_malloc=yes]) + [], [with_debug_malloc=no]) AC_ARG_ENABLE([trace], [AS_HELP_STRING([--enable-trace], [Enable trace output])], [], [enable_trace=no]) + +# Which FFT library to use AC_ARG_ENABLE([fft_simd], - [AS_HELP_STRING([--enable-fft-simd], [Enable SIMD instructions for kiss-fft (unstable)])], + [AS_HELP_STRING([--enable-fft-simd], + [Enable SIMD instructions for kiss-fft (unstable)])], [], [enable_fft_simd=no]) -AC_ARG_ENABLE([fftw], - [AS_HELP_STRING([--enable-fftw], [Use FFTW3 instead of Kiss FFT])], - [], [enable_fftw=no]) +AC_ARG_ENABLE([kiss_fft], + [AS_HELP_STRING([--enable-kiss-fft], [Prefer KISS FFT over FFTW3])], + [], [enable_kiss=no]) + # ZeroMQ message queue input AC_ARG_ENABLE([input_zeromq], AS_HELP_STRING([--enable-input-zeromq], [Enable ZeroMQ input])) + # UHD support control AC_ARG_ENABLE([output_uhd], [AS_HELP_STRING([--enable-output-uhd], [Enable UHD output])], [], [enable_output_uhd=yes]) +AS_IF([test "x$enable_kiss" = "xno"], + [PKG_CHECK_MODULES([FFTW], [fftw3f], enable_fftw=yes, enable_fftw=no)], + [enable_fftw=no]) + +AS_IF([test "x$enable_fftw" = "xyes"], + AC_MSG_NOTICE([Found FFTW3]), + AC_MSG_NOTICE([Using Kiss FFT]) ) + +echo "Checking input zeromq" + AS_IF([test "x$enable_input_zeromq" = "xyes"], [AC_DEFINE(HAVE_INPUT_ZEROMQ, [1], [Define if ZeroMQ input is enabled]) , AC_CHECK_LIB(zmq, zmq_init, ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) AS_IF([test "x$enable_debug" = "xno"], [OPTIM="-O2" DEBUG="" EXTRA="$EXTRA -DNDEBUG"], - [OPTIM="-O0" DEBUG="-ggdb" EXTRA="$EXTRA -Wall"]) + [OPTIM="-O0" DEBUG="-ggdb" EXTRA="$EXTRA"]) AS_IF([test "x$enable_prof" != "xno"], [EXTRA="$EXTRA -pg"]) -AS_IF([test "x$enable_trace" != "xno"], - [EXTRA="$EXTRA -DDEBUG"]) -AS_IF([test "x$enable_fft_simd" != "xno"], - [EXTRA="$EXTRA -DUSE_SIMD"]) -AS_IF([test "x$enable_fftw" != "xno"], - [EXTRA="$EXTRA -DUSE_FFTW"]) +# Define conditionals for Makefile.am AM_CONDITIONAL([USE_KISS_FFT], [test "x$enable_fftw" = "xno"]) - +AM_CONDITIONAL([DEBUG], [test "x$enable_trace" = "xyes"]) AM_CONDITIONAL([HAVE_INPUT_ZEROMQ_TEST], [test "x$enable_input_zeromq" = "xyes"]) +AM_CONDITIONAL([IS_GIT_REPO], [test -d '.git']) +# Defines for config.h +AS_IF([test "x$enable_fft_simd" = "xyes"], + [AC_DEFINE(USE_SIMD, [1], [Define to enable KISS FFT SIMD])]) +AS_IF([test "x$enable_fftw" = "xno"], + [AC_DEFINE(USE_KISS_FFT, [1], [Define to enable KISS])]) +AS_IF([test "x$enable_fftw" = "xyes"], + [AC_DEFINE(USE_FFTW, [1], [Define to enable FFTW])]) -AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA"]) -AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA"]) +AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS"]) +AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_LIBS"]) -# Checks for libraries. +# Checks for UHD. AS_IF([test "x$enable_output_uhd" = "xyes"], [AC_DEFINE(HAVE_OUTPUT_UHD, [1], [Define if UHD output is enabled]) , AC_CHECK_LIB([uhd], [main], [], [AC_MSG_ERROR([library uhd is missing])])]) @@ -110,11 +128,8 @@ AC_CHECK_LIB([boost_thread], [main], [], [AC_MSG_ERROR([library boost_thread is AC_CHECK_LIB([rt], [clock_gettime], [], [AC_MSG_ERROR([library rt is missing])]) -AS_IF([test "x$enable_fftw" != "xno"], - [AC_CHECK_LIB([fftw3f], [fftw_execute], - AC_MSG_NOTICE([Found FFTW3]), - AC_MSG_NOTICE([Failed to find FFTW3]) )] ) - +# Tests for different memory allocation debuggers. +# Valgrind doesn't need any. AS_IF([test "x$enable_debug" != "xno"], [AS_IF([test "x$with_debug_malloc" != "xno"], [AS_IF([test "x$with_debug_malloc" = "xyes"], @@ -145,6 +160,7 @@ AC_COMPILE_IFELSE( [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_DEFINE([M_PIl], [M_PI], [Replacing define])]) AC_LANG_POP([C++]) + # Check for SSE AC_MSG_CHECKING(for SSE in current arch/CFLAGS) AC_LINK_IFELSE([ @@ -165,7 +181,7 @@ AC_MSG_RESULT($has_sse) AM_CONDITIONAL([HAVE_SSE], [test "x$has_sse" = "xyes"]) -AM_CONDITIONAL([IS_GIT_REPO], [test -d '.git']) +# TODO: Check for NEON AC_TYPE_SIGNAL AC_CHECK_FUNCS([bzero floor ftime gettimeofday memset sqrt strchr strerror strtol]) @@ -197,7 +213,7 @@ disabled="" for feat in with_debug_malloc has_sse do eval var=\$$feat - AS_IF([test "x$var" = "xyes"], + AS_IF([test "x$var" != "xno"], [enabled="$enabled $feat"], [disabled="$disabled $feat"]) done diff --git a/src/Makefile.am b/src/Makefile.am index 3d1eefc..6c83cb1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,13 +23,13 @@ GITVERSION_FLAGS = endif if HAVE_INPUT_ZEROMQ_TEST -ZMQ_LIBS =-lzmq +ZMQ_LIBS = -lzmq else ZMQ_LIBS = endif if HAVE_OUTPUT_UHD_TEST -UHD_SOURCES =OutputUHD.cpp OutputUHD.h +UHD_SOURCES = OutputUHD.cpp OutputUHD.h else UHD_SOURCES = endif @@ -40,88 +40,95 @@ else SIMD_CFLAGS = endif -bin_PROGRAMS = odr-dabmod +bin_PROGRAMS = odr-dabmod if USE_KISS_FFT FFT_DIR=$(top_builddir)/lib/kiss_fft129 FFT_INC=-I$(FFT_DIR) -I$(FFT_DIR)/tools -FFT_SRC=$(FFT_DIR)/kiss_fft.c $(FFT_DIR)/kiss_fft.h $(FFT_DIR)/tools/kiss_fftr.c $(FFT_DIR)/tools/kiss_fftr.h kiss_fftsimd.c kiss_fftsimd.h +FFT_SRC=$(FFT_DIR)/kiss_fft.c \ + $(FFT_DIR)/kiss_fft.h \ + $(FFT_DIR)/tools/kiss_fftr.c \ + $(FFT_DIR)/tools/kiss_fftr.h \ + kiss_fftsimd.c \ + kiss_fftsimd.h FFT_FLG=-ffast-math .PHONY: kiss_fft129 reed-solomon-4.0 -DabModulator.cpp: $(FFT_DIR) +DabModulator.cpp: $(FFT_DIR) -BUILT_SOURCES: $(FFT_DIR) +BUILT_SOURCES: $(FFT_DIR) FFT_LDADD= + +$(FFT_DIR): + if [ ! -e $(FFT_DIR) ]; then \ + tar xzf $(top_srcdir)/lib/kiss_fft129.tar.gz -C $(top_builddir)/lib; \ + fi + else -FFT_LDADD=-lfftw3f -lm +FFT_LDADD= FFT_DIR= FFT_INC= FFT_SRC= FFT_FLG= endif -$(FFT_DIR): - if [ ! -e $(FFT_DIR) ]; then \ - tar xzf $(top_srcdir)/lib/kiss_fft129.tar.gz -C $(top_builddir)/lib; \ - fi - -odr_dabmod_CPPFLAGS = -Wall $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS) +odr_dabmod_CPPFLAGS = -Wall \ + $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS) odr_dabmod_LDADD = $(ZMQ_LIBS) $(FFT_LDADD) odr_dabmod_SOURCES = DabMod.cpp \ - PcDebug.h \ - porting.c porting.h \ - DabModulator.cpp DabModulator.h \ - Buffer.cpp Buffer.h \ - ModCodec.cpp ModCodec.h \ - ModPlugin.cpp ModPlugin.h \ - ModFormat.cpp ModFormat.h \ - EtiReader.cpp EtiReader.h \ - Eti.cpp Eti.h \ - FicSource.cpp FicSource.h \ + PcDebug.h \ + porting.c porting.h \ + DabModulator.cpp DabModulator.h \ + Buffer.cpp Buffer.h \ + ModCodec.cpp ModCodec.h \ + ModPlugin.cpp ModPlugin.h \ + ModFormat.cpp ModFormat.h \ + EtiReader.cpp EtiReader.h \ + Eti.cpp Eti.h \ + FicSource.cpp FicSource.h \ FIRFilter.cpp FIRFilter.h \ - ModInput.cpp ModInput.h \ - PuncturingRule.cpp PuncturingRule.h \ - PuncturingEncoder.cpp PuncturingEncoder.h \ - SubchannelSource.cpp SubchannelSource.h \ - Flowgraph.cpp Flowgraph.h \ - GainControl.cpp GainControl.h \ - OutputMemory.cpp OutputMemory.h \ + ModInput.cpp ModInput.h \ + PuncturingRule.cpp PuncturingRule.h \ + PuncturingEncoder.cpp PuncturingEncoder.h \ + SubchannelSource.cpp SubchannelSource.h \ + Flowgraph.cpp Flowgraph.h \ + GainControl.cpp GainControl.h \ + OutputMemory.cpp OutputMemory.h \ TimestampDecoder.h TimestampDecoder.cpp \ - $(UHD_SOURCES) \ - ModOutput.cpp ModOutput.h \ - InputMemory.cpp InputMemory.h \ + $(UHD_SOURCES) \ + ModOutput.cpp ModOutput.h \ + InputMemory.cpp InputMemory.h \ InputFileReader.cpp InputZeroMQReader.cpp InputReader.h \ - OutputFile.cpp OutputFile.h \ - FrameMultiplexer.cpp FrameMultiplexer.h \ - ModMux.cpp ModMux.h \ - PrbsGenerator.cpp PrbsGenerator.h \ - BlockPartitioner.cpp BlockPartitioner.h \ - QpskSymbolMapper.cpp QpskSymbolMapper.h \ - FrequencyInterleaver.cpp FrequencyInterleaver.h \ - PhaseReference.cpp PhaseReference.h \ - DifferentialModulator.cpp DifferentialModulator.h \ - NullSymbol.cpp NullSymbol.h \ - SignalMultiplexer.cpp SignalMultiplexer.h \ - CicEqualizer.cpp CicEqualizer.h \ - OfdmGenerator.cpp OfdmGenerator.h \ - GuardIntervalInserter.cpp GuardIntervalInserter.h \ - Resampler.cpp Resampler.h \ - ConvEncoder.cpp ConvEncoder.h \ - TimeInterleaver.cpp TimeInterleaver.h \ + OutputFile.cpp OutputFile.h \ + FrameMultiplexer.cpp FrameMultiplexer.h \ + ModMux.cpp ModMux.h \ + PrbsGenerator.cpp PrbsGenerator.h \ + BlockPartitioner.cpp BlockPartitioner.h \ + QpskSymbolMapper.cpp QpskSymbolMapper.h \ + FrequencyInterleaver.cpp FrequencyInterleaver.h \ + PhaseReference.cpp PhaseReference.h \ + DifferentialModulator.cpp DifferentialModulator.h \ + NullSymbol.cpp NullSymbol.h \ + SignalMultiplexer.cpp SignalMultiplexer.h \ + CicEqualizer.cpp CicEqualizer.h \ + OfdmGenerator.cpp OfdmGenerator.h \ + GuardIntervalInserter.cpp GuardIntervalInserter.h \ + Resampler.cpp Resampler.h \ + ConvEncoder.cpp ConvEncoder.h \ + TimeInterleaver.cpp TimeInterleaver.h \ ThreadsafeQueue.h \ Log.cpp Log.h \ RemoteControl.cpp RemoteControl.h \ zmq.hpp -nodist_odr_dabmod_SOURCES =$(FFT_SRC) +nodist_odr_dabmod_SOURCES = $(FFT_SRC) -dist_bin_SCRIPTS =crc-dwap.py +dist_bin_SCRIPTS = crc-dwap.py if USE_KISS_FFT -EXTRA_DIST =kiss_fftsimd.c kiss_fftsimd.h +EXTRA_DIST = kiss_fftsimd.c kiss_fftsimd.h clean-local: rm -rf $(FFT_DIR) -- cgit v1.2.3 From 05d4fc159a45d3b5d83cdb6f8df3bdce50ea8022 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Nov 2014 09:50:39 +0100 Subject: Correct autoconf for FFTW --- configure.ac | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9826a91..d15885e 100644 --- a/configure.ac +++ b/configure.ac @@ -113,7 +113,8 @@ AS_IF([test "x$enable_fftw" = "xyes"], [AC_DEFINE(USE_FFTW, [1], [Define to enable FFTW])]) AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS"]) -AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_LIBS"]) +AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS"]) +AC_SUBST([LIBS], ["$FFTW_LIBS"]) # Checks for UHD. AS_IF([test "x$enable_output_uhd" = "xyes"], -- cgit v1.2.3 From 76e7347f63a09c4e0b860798cd8abaecdff1d302 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Nov 2014 09:57:36 +0100 Subject: Add autoconf check for pthread --- configure.ac | 8 +- m4/ax_pthread.m4 | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 337 insertions(+), 3 deletions(-) create mode 100644 m4/ax_pthread.m4 diff --git a/configure.ac b/configure.ac index d15885e..2053c9c 100644 --- a/configure.ac +++ b/configure.ac @@ -112,9 +112,11 @@ AS_IF([test "x$enable_fftw" = "xno"], AS_IF([test "x$enable_fftw" = "xyes"], [AC_DEFINE(USE_FFTW, [1], [Define to enable FFTW])]) -AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS"]) -AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS"]) -AC_SUBST([LIBS], ["$FFTW_LIBS"]) +AX_PTHREAD([], AC_MSG_ERROR([requires pthread])) + +AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) +AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) +AC_SUBST([LIBS], ["$FFTW_LIBS $PTHREAD_LIBS"]) # Checks for UHD. AS_IF([test "x$enable_output_uhd" = "xyes"], diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 new file mode 100644 index 0000000..d383ad5 --- /dev/null +++ b/m4/ax_pthread.m4 @@ -0,0 +1,332 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also link it with them as well. e.g. you should link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threads programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to that name +# (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2011 Daniel Richard G. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 21 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on True64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) + AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) + if test x"$ax_pthread_ok" = xno; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) +# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads) +# -pthreads: Solaris/gcc +# -mthreads: Mingw32/gcc, Lynx/gcc +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads too; +# also defines -D_REENTRANT) +# ... -mt is also the pthreads flag for HP/aCC +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case ${host_os} in + solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (We need to link with -pthreads/-mt/ + # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather + # a function called by this macro, so we could check for that, but + # who knows whether they'll stub that too in a future libc.) So, + # we'll just look for -pthreads and -lpthread first: + + ax_pthread_flags="-pthreads pthread -mt -pthread $ax_pthread_flags" + ;; + + darwin*) + ax_pthread_flags="-pthread $ax_pthread_flags" + ;; +esac + +# Clang doesn't consider unrecognized options an error unless we specify +# -Werror. We throw in some extra Clang-specific options to ensure that +# this doesn't happen for GCC, which also accepts -Werror. + +AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) +save_CFLAGS="$CFLAGS" +ax_pthread_extra_flags="-Werror" +CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], + [AC_MSG_RESULT([yes])], + [ax_pthread_extra_flags= + AC_MSG_RESULT([no])]) +CFLAGS="$save_CFLAGS" + +if test x"$ax_pthread_ok" = xno; then +for flag in $ax_pthread_flags; do + + case $flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $flag]) + PTHREAD_CFLAGS="$flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + if test x"$ax_pthread_config" = xno; then continue; fi + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$flag]) + PTHREAD_LIBS="-l$flag" + ;; + esac + + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include + static void routine(void *a) { a = 0; } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + AC_MSG_RESULT([$ax_pthread_ok]) + if test "x$ax_pthread_ok" = xyes; then + break; + fi + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = xyes; then + save_LIBS="$LIBS" + LIBS="$PTHREAD_LIBS $LIBS" + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_MSG_CHECKING([for joinable pthread attribute]) + attr_name=unknown + for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [int attr = $attr; return attr /* ; */])], + [attr_name=$attr; break], + []) + done + AC_MSG_RESULT([$attr_name]) + if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then + AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + fi + + AC_MSG_CHECKING([if more special flags are required for pthreads]) + flag=no + case ${host_os} in + aix* | freebsd* | darwin*) flag="-D_THREAD_SAFE";; + osf* | hpux*) flag="-D_REENTRANT";; + solaris*) + if test "$GCC" = "yes"; then + flag="-D_REENTRANT" + else + # TODO: What about Clang on Solaris? + flag="-mt -D_REENTRANT" + fi + ;; + esac + AC_MSG_RESULT([$flag]) + if test "x$flag" != xno; then + PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" + fi + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + [ax_cv_PTHREAD_PRIO_INHERIT], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) + + LIBS="$save_LIBS" + CFLAGS="$save_CFLAGS" + + # More AIX lossage: compile with *_r variant + if test "x$GCC" != xyes; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + ;; + esac + fi +fi + +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_CC]) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test x"$ax_pthread_ok" = xyes; then + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD -- cgit v1.2.3 From 7f5faf87e6373d27ae6709a1185154ca8e98276b Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Nov 2014 13:45:25 +0100 Subject: Add new ZeroMQ IQ output --- configure.ac | 14 +++++++---- src/DabMod.cpp | 33 ++++++++++++++++++++------ src/Makefile.am | 9 ++----- src/OutputZeroMQ.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/OutputZeroMQ.h | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 18 deletions(-) create mode 100644 src/OutputZeroMQ.cpp create mode 100644 src/OutputZeroMQ.h diff --git a/configure.ac b/configure.ac index 2053c9c..7f7ad0a 100644 --- a/configure.ac +++ b/configure.ac @@ -74,6 +74,10 @@ AC_ARG_ENABLE([kiss_fft], AC_ARG_ENABLE([input_zeromq], AS_HELP_STRING([--enable-input-zeromq], [Enable ZeroMQ input])) +# ZeroMQ message IQ output +AC_ARG_ENABLE([output_zeromq], + AS_HELP_STRING([--enable-output-zeromq], [Enable ZeroMQ output])) + # UHD support control AC_ARG_ENABLE([output_uhd], [AS_HELP_STRING([--enable-output-uhd], [Enable UHD output])], @@ -91,7 +95,10 @@ echo "Checking input zeromq" AS_IF([test "x$enable_input_zeromq" = "xyes"], [AC_DEFINE(HAVE_INPUT_ZEROMQ, [1], [Define if ZeroMQ input is enabled]) , - AC_CHECK_LIB(zmq, zmq_init, ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) + AC_CHECK_LIB(zmq, zmq_init, ZMQ_LIBS="-lzmq" ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) +AS_IF([test "x$enable_output_zeromq" = "xyes"], + [AC_DEFINE(HAVE_OUTPUT_ZEROMQ, [1], [Define if ZeroMQ output is enabled]) , + AC_CHECK_LIB(zmq, zmq_init, ZMQ_LIBS="-lzmq" ,[AC_MSG_ERROR([ZeroMQ libzmq is required])])]) AS_IF([test "x$enable_debug" = "xno"], [OPTIM="-O2" DEBUG="" EXTRA="$EXTRA -DNDEBUG"], [OPTIM="-O0" DEBUG="-ggdb" EXTRA="$EXTRA"]) @@ -101,7 +108,6 @@ AS_IF([test "x$enable_prof" != "xno"], # Define conditionals for Makefile.am AM_CONDITIONAL([USE_KISS_FFT], [test "x$enable_fftw" = "xno"]) AM_CONDITIONAL([DEBUG], [test "x$enable_trace" = "xyes"]) -AM_CONDITIONAL([HAVE_INPUT_ZEROMQ_TEST], [test "x$enable_input_zeromq" = "xyes"]) AM_CONDITIONAL([IS_GIT_REPO], [test -d '.git']) # Defines for config.h @@ -116,7 +122,7 @@ AX_PTHREAD([], AC_MSG_ERROR([requires pthread])) AC_SUBST([CFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) AC_SUBST([CXXFLAGS], ["$OPTIM $DEBUG $EXTRA $FFTW_CFLAGS $PTHREAD_CFLAGS"]) -AC_SUBST([LIBS], ["$FFTW_LIBS $PTHREAD_LIBS"]) +AC_SUBST([LIBS], ["$FFTW_LIBS $PTHREAD_LIBS $ZMQ_LIBS"]) # Checks for UHD. AS_IF([test "x$enable_output_uhd" = "xyes"], @@ -199,7 +205,7 @@ echo "***********************************************" echo enabled="" disabled="" -for feat in debug prof trace fftw fft_simd output_uhd input_zeromq +for feat in debug prof trace fftw fft_simd output_uhd input_zeromq output_zeromq do eval var=\$enable_$feat AS_IF([test "x$var" = "xyes"], diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 67ad12d..f27d720 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -38,6 +38,7 @@ #if defined(HAVE_OUTPUT_UHD) # include "OutputUHD.h" #endif +#include "OutputZeroMQ.h" #include "InputReader.h" #include "PcDebug.h" #include "TimestampDecoder.h" @@ -166,6 +167,7 @@ int main(int argc, char* argv[]) std::string inputTransport = "file"; std::string outputName; + int useZeroMQOutput = 0; int useFileOutput = 0; int useUHDOutput = 0; @@ -399,7 +401,7 @@ int main(int argc, char* argv[]) clockRate = pt.get("modulator.dac_clk_rate", (size_t)0); digitalgain = pt.get("modulator.digital_gain", digitalgain); outputRate = pt.get("modulator.rate", outputRate); - + // FIR Filter parameters: if (pt.get("firfilter.enabled", 0) == 1) { try { @@ -530,6 +532,12 @@ int main(int argc, char* argv[]) useUHDOutput = 1; } +#endif +#if defined(HAVE_OUTPUT_ZEROMQ) + else if (output_selected == "zmq") { + outputName = pt.get("zmqoutput.listen"); + useZeroMQOutput = 1; + } #endif else { std::cerr << "Error: Invalid output defined.\n"; @@ -612,7 +620,7 @@ int main(int argc, char* argv[]) goto END_MAIN; } - if (!useFileOutput && !useUHDOutput) { + if (!useFileOutput && !useUHDOutput && !useZeroMQOutput) { logger.level(error) << "Output not specified"; fprintf(stderr, "Must specify output !"); goto END_MAIN; @@ -623,8 +631,12 @@ int main(int argc, char* argv[]) fprintf(stderr, " Type: %s\n", inputTransport.c_str()); fprintf(stderr, " Source: %s\n", inputName.c_str()); fprintf(stderr, "Output\n"); + + if (useFileOutput) { + fprintf(stderr, " Name: %s\n", outputName.c_str()); + } #if defined(HAVE_OUTPUT_UHD) - if (useUHDOutput) { + else if (useUHDOutput) { fprintf(stderr, " UHD\n" " Device: %s\n" " Type: %s\n" @@ -633,12 +645,13 @@ int main(int argc, char* argv[]) outputuhd_conf.usrpType.c_str(), outputuhd_conf.masterClockRate); } - else if (useFileOutput) { -#else - if (useFileOutput) { #endif - fprintf(stderr, " Name: %s\n", outputName.c_str()); + else if (useZeroMQOutput) { + fprintf(stderr, " ZeroMQ\n" + " Listening on: %s\n", + outputName.c_str()); } + fprintf(stderr, " Sampling rate: "); if (outputRate > 1000) { if (outputRate > 1000000) { @@ -713,6 +726,12 @@ int main(int argc, char* argv[]) } } #endif + else if (useZeroMQOutput) { + /* We normalise the same way as for the UHD output */ + normalise = 1.0f/50000.0f; + + output = new OutputZeroMQ(outputName); + } flowgraph = new Flowgraph(); data.setLength(6144); diff --git a/src/Makefile.am b/src/Makefile.am index 6c83cb1..635a3d8 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,12 +22,6 @@ else GITVERSION_FLAGS = endif -if HAVE_INPUT_ZEROMQ_TEST -ZMQ_LIBS = -lzmq -else -ZMQ_LIBS = -endif - if HAVE_OUTPUT_UHD_TEST UHD_SOURCES = OutputUHD.cpp OutputUHD.h else @@ -76,7 +70,7 @@ endif odr_dabmod_CPPFLAGS = -Wall \ $(FFT_INC) $(FFT_FLG) $(SIMD_CFLAGS) $(GITVERSION_FLAGS) -odr_dabmod_LDADD = $(ZMQ_LIBS) $(FFT_LDADD) +odr_dabmod_LDADD = $(FFT_LDADD) odr_dabmod_SOURCES = DabMod.cpp \ PcDebug.h \ porting.c porting.h \ @@ -96,6 +90,7 @@ odr_dabmod_SOURCES = DabMod.cpp \ Flowgraph.cpp Flowgraph.h \ GainControl.cpp GainControl.h \ OutputMemory.cpp OutputMemory.h \ + OutputZeroMQ.cpp OutputZeroMQ.h \ TimestampDecoder.h TimestampDecoder.cpp \ $(UHD_SOURCES) \ ModOutput.cpp ModOutput.h \ diff --git a/src/OutputZeroMQ.cpp b/src/OutputZeroMQ.cpp new file mode 100644 index 0000000..0e759dd --- /dev/null +++ b/src/OutputZeroMQ.cpp @@ -0,0 +1,67 @@ +/* + Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in + Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org + */ +/* + This file is part of ODR-DabMod. + + ODR-DabMod is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + ODR-DabMod is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ODR-DabMod. If not, see . + */ + +#include "OutputZeroMQ.h" +#include "PcDebug.h" +#include +#include +#include + +#if defined(HAVE_OUTPUT_ZEROMQ) + +OutputZeroMQ::OutputZeroMQ(std::string endpoint, Buffer* dataOut) + : ModOutput(ModFormat(1), ModFormat(0)), + m_zmq_context(1), + m_zmq_pub_sock(m_zmq_context, ZMQ_PUB), + m_endpoint(endpoint) +{ + PDEBUG("OutputZeroMQ::OutputZeroMQ(%p) @ %p\n", dataOut, this); + + std::stringstream ss; + ss << "OutputZeroMQ(" << m_endpoint << ")"; + m_name = ss.str(); + + m_zmq_pub_sock.bind(m_endpoint.c_str()); +} + +OutputZeroMQ::~OutputZeroMQ() +{ + PDEBUG("OutputZeroMQ::~OutputZeroMQ() @ %p\n", this); +} + +int OutputZeroMQ::process(Buffer* dataIn, Buffer* dataOut) +{ + PDEBUG("OutputZeroMQ::process" + "(dataIn: %p, dataOut: %p)\n", + dataIn, dataOut); + + m_zmq_pub_sock.send(dataIn->getData(), dataIn->getLength()); + + return dataIn->getLength(); +} + +#endif // HAVE_OUTPUT_ZEROMQ_H + diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h new file mode 100644 index 0000000..a3ac060 --- /dev/null +++ b/src/OutputZeroMQ.h @@ -0,0 +1,62 @@ +/* + Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in + Right of Canada (Communications Research Center Canada) + + Copyright (C) 2014 + Matthias P. Braendli, matthias.braendli@mpb.li + + http://opendigitalradio.org + */ +/* + This file is part of ODR-DabMod. + + ODR-DabMod is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + ODR-DabMod is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with ODR-DabMod. If not, see . + */ + +#ifndef OUTPUT_ZEROMQ_H +#define OUTPUT_ZEROMQ_H + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#if defined(HAVE_OUTPUT_ZEROMQ) + +#include "ModOutput.h" +#include "zmq.hpp" + +class OutputZeroMQ : public ModOutput +{ + public: + OutputZeroMQ(std::string endpoint, Buffer* dataOut = NULL); + virtual ~OutputZeroMQ(); + virtual int process(Buffer* dataIn, Buffer* dataOut); + const char* name() { return m_name.c_str(); } + + protected: + zmq::context_t m_zmq_context; // handle for the zmq context + zmq::socket_t m_zmq_pub_sock; // handle for the zmq publisher socket + + std::string m_endpoint; // On which port to listen: e.g. + // tcp://*:58300 + + std::string m_name; + + Buffer* m_data_out; +}; + +#endif // HAVE_OUTPUT_ZEROMQ_H + +#endif // OUTPUT_ZEROMQ_H + -- cgit v1.2.3 From 014e35d73f80cef14895bc9c0dad5d35213e8aab Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sat, 1 Nov 2014 16:48:13 +0100 Subject: Fix compilation without zmq output --- src/DabMod.cpp | 2 ++ src/OutputZeroMQ.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index f27d720..a4ef228 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -726,12 +726,14 @@ int main(int argc, char* argv[]) } } #endif +#if defined(HAVE_OUTPUT_ZEROMQ) else if (useZeroMQOutput) { /* We normalise the same way as for the UHD output */ normalise = 1.0f/50000.0f; output = new OutputZeroMQ(outputName); } +#endif flowgraph = new Flowgraph(); data.setLength(6144); diff --git a/src/OutputZeroMQ.h b/src/OutputZeroMQ.h index a3ac060..1c48fe7 100644 --- a/src/OutputZeroMQ.h +++ b/src/OutputZeroMQ.h @@ -52,8 +52,6 @@ class OutputZeroMQ : public ModOutput // tcp://*:58300 std::string m_name; - - Buffer* m_data_out; }; #endif // HAVE_OUTPUT_ZEROMQ_H -- cgit v1.2.3 From cf46de6e9faa6628650217f53bae72059475c63e Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Sun, 2 Nov 2014 21:07:08 +0100 Subject: Change UHD txgain to double --- doc/example.ini | 2 +- src/DabMod.cpp | 4 ++-- src/OutputUHD.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/example.ini b/doc/example.ini index 9cdfe03..38a856c 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -107,7 +107,7 @@ filename=/dev/stdout ; ; Settings for a USRP B100: device=master_clock_rate=32768000,type=b100 -txgain=2 +txgain=2.0 ; Try first with small gain values ; Also set rate to 2048000 diff --git a/src/DabMod.cpp b/src/DabMod.cpp index a4ef228..b0a7a2c 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -259,7 +259,7 @@ int main(int argc, char* argv[]) break; case 'G': #if defined(HAVE_OUTPUT_UHD) - outputuhd_conf.txgain = (int)strtol(optarg, NULL, 10); + outputuhd_conf.txgain = strtod(optarg, NULL); #endif break; case 'l': @@ -453,7 +453,7 @@ int main(int argc, char* argv[]) "setting type in [uhd] device is deprecated !\n"; } - outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0); + outputuhd_conf.txgain = pt.get("uhdoutput.txgain", 0.0); outputuhd_conf.frequency = pt.get("uhdoutput.frequency", 0); std::string chan = pt.get("uhdoutput.channel", ""); diff --git a/src/OutputUHD.h b/src/OutputUHD.h index 3a047bf..ef9740d 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -166,7 +166,7 @@ struct OutputUHDConfig { long masterClockRate; unsigned sampleRate; double frequency; - int txgain; + double txgain; bool enableSync; bool muteNoTimestamps; -- cgit v1.2.3 From 2ba0bcee8b4b3c0ace3d70bae07d8d5d3152da95 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 14 Nov 2014 14:44:09 +0100 Subject: Remove Makefile.am UHD check --- configure.ac | 2 -- src/Makefile.am | 8 +------- src/OutputUHD.cpp | 4 ++++ src/OutputUHD.h | 3 +++ 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 7f7ad0a..005b1fc 100644 --- a/configure.ac +++ b/configure.ac @@ -129,8 +129,6 @@ AS_IF([test "x$enable_output_uhd" = "xyes"], [AC_DEFINE(HAVE_OUTPUT_UHD, [1], [Define if UHD output is enabled]) , AC_CHECK_LIB([uhd], [main], [], [AC_MSG_ERROR([library uhd is missing])])]) -AM_CONDITIONAL([HAVE_OUTPUT_UHD_TEST], [test "x$enable_output_uhd" = "xyes"]) - AX_BOOST_BASE([1.41.0], [], AC_MSG_ERROR([BOOST 1.41 or later is required])) AC_CHECK_LIB([boost_system], [main], [], [AC_MSG_ERROR([library boost_system is missing])]) AC_CHECK_LIB([boost_thread], [main], [], [AC_MSG_ERROR([library boost_thread is missing])]) diff --git a/src/Makefile.am b/src/Makefile.am index 635a3d8..922ce52 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,12 +22,6 @@ else GITVERSION_FLAGS = endif -if HAVE_OUTPUT_UHD_TEST -UHD_SOURCES = OutputUHD.cpp OutputUHD.h -else -UHD_SOURCES = -endif - if HAVE_SSE SIMD_CFLAGS = -msse -msse2 else @@ -92,7 +86,7 @@ odr_dabmod_SOURCES = DabMod.cpp \ OutputMemory.cpp OutputMemory.h \ OutputZeroMQ.cpp OutputZeroMQ.h \ TimestampDecoder.h TimestampDecoder.cpp \ - $(UHD_SOURCES) \ + OutputUHD.cpp OutputUHD.h \ ModOutput.cpp ModOutput.h \ InputMemory.cpp InputMemory.h \ InputFileReader.cpp InputZeroMQReader.cpp InputReader.h \ diff --git a/src/OutputUHD.cpp b/src/OutputUHD.cpp index 3d8eea6..8063e75 100644 --- a/src/OutputUHD.cpp +++ b/src/OutputUHD.cpp @@ -25,6 +25,9 @@ */ #include "OutputUHD.h" + +#ifdef HAVE_OUTPUT_UHD + #include "PcDebug.h" #include "Log.h" #include "RemoteControl.h" @@ -652,3 +655,4 @@ const string OutputUHD::get_parameter(const string& parameter) const return ss.str(); } +#endif // HAVE_OUTPUT_UHD diff --git a/src/OutputUHD.h b/src/OutputUHD.h index ef9740d..a2ffb7d 100644 --- a/src/OutputUHD.h +++ b/src/OutputUHD.h @@ -42,6 +42,8 @@ DESCRIPTION: # include #endif +#ifdef HAVE_OUTPUT_UHD + #include #include #include @@ -230,6 +232,7 @@ class OutputUHD: public ModOutput, public RemoteControllable { size_t lastLen; }; +#endif // HAVE_OUTPUT_UHD #endif // OUTPUT_UHD_H -- cgit v1.2.3 From fc2acbcf9f64a722ccd160388f5a9a1dcdc4f4f3 Mon Sep 17 00:00:00 2001 From: Matthias Braendli Date: Tue, 2 Dec 2014 16:32:32 +0100 Subject: Update configuration example --- doc/example.ini | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/example.ini b/doc/example.ini index 38a856c..e1ce252 100644 --- a/doc/example.ini +++ b/doc/example.ini @@ -106,7 +106,10 @@ filename=/dev/stdout ; or even a higher factor. ; ; Settings for a USRP B100: -device=master_clock_rate=32768000,type=b100 +device= +; you can put additional UHD device settings here +master_clock_rate=32768000 +type=b100 txgain=2.0 ; Try first with small gain values ; Also set rate to 2048000 @@ -116,7 +119,9 @@ txgain=2.0 ; http://opendigitalradio.org/index.php/USRP_B200_Measurements ; ; Settings: -;device=master_clock_rate=20480000,type=b200 +;device= +;master_clock_rate=20480000 +;type=b200 ;txgain=40 ; The B200 needs larger gains (up to 89dB) but, ; "Gain settings are application specific, but it is recommended that users @@ -127,7 +132,8 @@ txgain=2.0 ; For the USRP1 -;device=type=usrp1 +;device= +;type=usrp1 ; the usrp1 can have two daughterboards, the subdevice parameter allows you ; to choose which one to use ;subdevice=A:0 -- cgit v1.2.3 From 8ba7e406e1d71460865c0eb493956520e2f35ae1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 14 Nov 2014 23:42:52 +0100 Subject: Update -V output --- src/DabMod.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index b0a7a2c..df7e2a1 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -138,8 +138,13 @@ void printVersion(FILE *out = stderr) { fprintf(out, "Welcome to %s %s, compiled at %s, %s\n\n", PACKAGE, VERSION, __DATE__, __TIME__); - fprintf(out, "ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n" - " 2009, 2010, 2011, 2012 Communications Research Centre (CRC).\n" + fprintf(out, + " ODR-DabMod is copyright (C) Her Majesty the Queen in Right of Canada,\n" + " 2009, 2010, 2011, 2012 Communications Research Centre (CRC),\n" + " and\n" + " Copyright (C) 2014 Matthias P. Braendli, matthias.braendli@mpb.li\n" + "\n" + " http://opendigitalradio.org\n" "\n" " This program is available free of charge and is licensed to you on a\n" " non-exclusive basis; you may not redistribute it.\n" @@ -152,8 +157,10 @@ void printVersion(FILE *out = stderr) " In no event shall CRC be LIABLE for any LOSS, DAMAGE or COST that may be\n" " incurred in connection with the use of this software.\n" "\n" +#if USE_KISS_FFT "ODR-DabMod makes use of the following open source packages:\n" " Kiss FFT v1.2.9 (Revised BSD) - http://kissfft.sourceforge.net/\n" +#endif ); } -- cgit v1.2.3 From ae4bed0f8ef4b7b318befe49336902deee983614 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 14 Nov 2014 23:54:46 +0100 Subject: Print compile-time settings on startup --- src/DabMod.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index df7e2a1..1afdfb5 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -339,6 +339,30 @@ int main(int argc, char* argv[]) #endif << std::endl; + std::cerr << "Using FFT library " << +#if defined(USE_FFTW) + "FFTW" << +#endif +#if defined(USE_KISS_FFT) + "Kiss FFT" << +#endif +#if defined(USE_SIMD) + " (with fft_simd)" << +#endif + "\n"; + + std::cerr << "Compiled with features: " << +#if defined(HAVE_INPUT_ZEROMQ) + "input_zeromq " << +#endif +#if defined(HAVE_OUTPUT_UHD) + "output_uhd " << +#endif +#if defined(HAVE_OUTPUT_ZEROMQ) + "output_zeromq " << +#endif + "\n"; + if (use_configuration_file && use_configuration_cmdline) { fprintf(stderr, "Warning: configuration file and command line parameters are defined:\n\t" "Command line parameters override settings in the configuration file !\n"); @@ -578,6 +602,7 @@ int main(int argc, char* argv[]) outputuhd_conf.muteNoTimestamps = (pt.get("delaymanagement.mutenotimestamps", 0) == 1); #endif } + if (!rc) { logger.level(warn) << "No Remote-Control started"; rc = new RemoteControllerDummy(); -- cgit v1.2.3 From e2d7cfa4ed5d8bfd4a4798b5f653d0bc222d5bce Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 14 Nov 2014 23:55:19 +0100 Subject: Interpret a single cmdline option as ini file name --- src/DabMod.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/DabMod.cpp b/src/DabMod.cpp index 1afdfb5..91c0b9d 100644 --- a/src/DabMod.cpp +++ b/src/DabMod.cpp @@ -92,11 +92,11 @@ void printUsage(char* progName, FILE* out = stderr) #endif __DATE__, __TIME__); fprintf(out, "Usage with configuration file:\n"); - fprintf(out, "\t%s -C config_file.ini\n\n", progName); + fprintf(out, "\t%s [-C] config_file.ini\n\n", progName); fprintf(out, "Usage with command line options:\n"); fprintf(out, "\t%s" - " [input]" + " input" " (-f filename | -u uhddevice -F frequency) " " [-G txgain]" " [-o offset]" @@ -368,6 +368,18 @@ int main(int argc, char* argv[]) "Command line parameters override settings in the configuration file !\n"); } + // No argument given ? You can't be serious ! Show usage. + if (argc == 1) { + printUsage(argv[0]); + goto END_MAIN; + } + + // If only one argument is given, interpret as configuration file name + if (argc == 2) { + use_configuration_file = true; + configuration_file = argv[1]; + } + if (use_configuration_file) { // First read parameters from the file using boost::property_tree::ptree; @@ -624,7 +636,7 @@ int main(int argc, char* argv[]) } // Setting ETI input filename - if (inputName == "") { + if (use_configuration_cmdline && inputName == "") { if (optind < argc) { inputName = argv[optind++]; @@ -640,7 +652,7 @@ int main(int argc, char* argv[]) } // Checking unused arguments - if (optind != argc) { + if (use_configuration_cmdline && optind != argc) { fprintf(stderr, "Invalid arguments:"); while (optind != argc) { fprintf(stderr, " %s", argv[optind++]); -- cgit v1.2.3 From 66eb4a62eb4c781f427e1938a7d42e2facf8194c Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 9 Dec 2014 23:04:42 +0100 Subject: Markdownise README --- README | 44 -------------------------------------------- README.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 44 deletions(-) delete mode 100644 README create mode 100644 README.md diff --git a/README b/README deleted file mode 100644 index 05290d9..0000000 --- a/README +++ /dev/null @@ -1,44 +0,0 @@ -OVERVIEW -======== -ODR-DabMod is a fork of CRC-DabMod, which was developed by the Communications -Research Center Canada. It has been forked by the Opendigitalradio project. - -ODR-DabMod is a DAB (Digital Audio Broadcasting) modulator compliant -to ETSI EN 300 401. - -In addition to the features of CRC-DabMod, this fork contains: -- Configuration file support, see doc/example.ini -- Integrated UHD output for USRP devices, bypassing gnuradio - - Tested for USRP1, B100, USRP2 - - B200 support in development -- Timestamping support required for SFN -- A FIR filter (previously done in GNURadio by crc-dwap.py) -- Improvements in logging (log to file, to syslog) -- ETI sources: file (Raw, Framed and Streamed) and ZeroMQ -- A Telnet remote-control that can be used to change some parameters during - runtime - -The src/ directory contains the source code of ODR-DabMod. - -The doc/ directory contains the ODR-DabMod documentation, and an example -configuration file. - -The lib/ directory contains source code of libraries needed to build -ODR-DabMod. - -INSTALL -======= -See the INSTALL file for installation instructions. - -LICENCE -======= -See the files LICENCE and COPYING - -CONTACT -======= -Matthias P. Braendli -Pascal Charest - -http://opendigitalradio.org/ -http://mmbtools.crc.ca/ -http://mpb.li/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ea87c9 --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +OVERVIEW +======== +ODR-DabMod is a fork of CRC-DabMod, which was developed by the Communications +Research Center Canada. It has been forked by the Opendigitalradio project. + +ODR-DabMod is a DAB (Digital Audio Broadcasting) modulator compliant +to ETSI EN 300 401. + +In addition to the features of CRC-DabMod, this fork contains: + +- Configuration file support, see doc/example.ini +- Integrated UHD output for USRP devices + - Tested for B200, B100, USRP2, USRP1 + - With WBX daughterboard (where appropriate) +- Timestamping support required for SFN +- A FIR filter (previously done in GNURadio by crc-dwap.py) +- Improvements in logging (log to file, to syslog) +- ETI sources: file (Raw, Framed and Streamed) and ZeroMQ +- A Telnet remote-control that can be used to change some parameters during + runtime + +The src/ directory contains the source code of ODR-DabMod. + +The doc/ directory contains the ODR-DabMod documentation, and an example +configuration file. + +The lib/ directory contains source code of libraries needed to build +ODR-DabMod. + +INSTALL +======= +See the INSTALL file for installation instructions. + +LICENCE +======= +See the files LICENCE and COPYING + +CONTACT +======= +Matthias P. Braendli +Pascal Charest + +http://opendigitalradio.org/ +http://mmbtools.crc.ca/ +http://mpb.li/ -- cgit v1.2.3 From 94c1f63b6fd07d74f3325274dd19fd6beaf53965 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Tue, 9 Dec 2014 23:04:54 +0100 Subject: Prepare v0.5.0 --- ChangeLog | 8 ++++++++ Makefile.am | 6 ++++-- configure.ac | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 28a9f04..e005721 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,14 @@ This file contains information about the changes done to the ODR-DabMod in this repository +2014-12-09: Matthias P. Braendli + (v0.5.0) + * odr-dabmod: + Add support for ARM processors. + Use FFTW instead of KISS FFT by default. + Add a ZeroMQ I/Q output. + Support more fine-grained UHD TX gain. + Make the -C flag optional to simplify the usage. 2014-09-26: Matthias P. Braendli (v0.4.5) * odr-dabmod: diff --git a/Makefile.am b/Makefile.am index f599871..c0b3024 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,7 @@ # Copyright (C) 2007, 2008, 2009, 2010 Her Majesty the Queen in Right # of Canada (Communications Research Center Canada) +# +# Copyright (C) 2014 Matthias P. Braendli, http://mpb.li # This file is part of ODR-DabMod. # @@ -16,8 +18,8 @@ # You should have received a copy of the GNU General Public License # along with ODR-DabMod. If not, see . -SUBDIRS =src lib +SUBDIRS = src lib ACLOCAL_AMFLAGS = -I m4 -EXTRA_DIST =COPYING NEWS README AUTHORS ChangeLog TODO doc +EXTRA_DIST = COPYING NEWS README.md AUTHORS ChangeLog TODO doc diff --git a/configure.ac b/configure.ac index 005b1fc..615bf6d 100644 --- a/configure.ac +++ b/configure.ac @@ -19,10 +19,10 @@ # along with ODR-DabMod. If not, see . AC_PREREQ(2.59) -AC_INIT([ODR-DabMod], [0.4.5], [matthias.braendli@mpb.li]) +AC_INIT([ODR-DabMod], [0.5.0], [matthias.braendli@mpb.li]) AC_CONFIG_AUX_DIR([build-aux]) AC_CANONICAL_SYSTEM -AM_INIT_AUTOMAKE([-Wall]) +AM_INIT_AUTOMAKE([-Wall foreign]) AC_CONFIG_SRCDIR([src/DabMod.cpp]) AM_CONFIG_HEADER([config.h]) AM_SILENT_RULES([yes]) -- cgit v1.2.3