From a58553be1c8dc15aa218d14e54dc753b64b1dfd8 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 24 Jan 2024 01:23:29 +0000 Subject: [PATCH 1/3] add low power hold down support to pretune (so can output correlated I/Q and power). --- docker/Dockerfile.base | 2 +- gamutrf/grscan.py | 96 ++++++++++++++++++++++-------------------- 2 files changed, 51 insertions(+), 47 deletions(-) diff --git a/docker/Dockerfile.base b/docker/Dockerfile.base index 4fd667ff..12f80ced 100644 --- a/docker/Dockerfile.base +++ b/docker/Dockerfile.base @@ -28,7 +28,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libvulkan-dev \ python3-numpy WORKDIR /root -RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.75 +RUN git clone https://github.com/iqtlabs/gr-iqtlabs -b 1.0.76 COPY --from=iqtlabs/gamutrf-vkfft:latest /root /root/gr-iqtlabs WORKDIR /root/gr-iqtlabs/build COPY --from=sigmf-builder /usr/local /usr/local diff --git a/gamutrf/grscan.py b/gamutrf/grscan.py index b53ccdcf..29f1d187 100644 --- a/gamutrf/grscan.py +++ b/gamutrf/grscan.py @@ -110,30 +110,6 @@ def __init__( ################################################## logging.info(f"will scan from {freq_start} to {freq_end}") - - self.samples_blocks = [] - if write_samples: - Path(sample_dir).mkdir(parents=True, exist_ok=True) - self.samples_blocks.extend( - [ - blocks.complex_to_interleaved_short(False, 32767), - blocks.stream_to_vector(gr.sizeof_short, nfft * 2), - self.iqtlabs.write_freq_samples( - "rx_freq", - gr.sizeof_short, - "_".join(("ci16", endianstr())), - nfft * 2, - sample_dir, - "samples", - write_samples, - skip_tune_step, - int(samp_rate), - rotate_secs, - igain, - sigmf, - ), - ] - ) freq_range = freq_end - freq_start fft_rate = int(samp_rate / nfft) @@ -168,26 +144,53 @@ def __init__( sdrargs=sdrargs, ) + fft_batch_size, self.fft_blocks = self.get_fft_blocks( + vkfft, + fft_batch_size, + nfft, + freq_start, + freq_end, + tune_step_hz, + tune_step_fft, + skip_tune_step, + tuning_ranges, + pretune, + fft_processor_affinity, + low_power_hold_down, + ) self.fft_blocks = ( self.get_dc_blocks(dc_block_len, dc_block_long) - + self.get_fft_blocks( - vkfft, - fft_batch_size, - nfft, - freq_start, - freq_end, - tune_step_hz, - tune_step_fft, - skip_tune_step, - tuning_ranges, - pretune, - fft_processor_affinity, - ) + + self.fft_blocks + self.get_db_blocks(nfft, samp_rate, scaling) ) - fft_dir = sample_dir - if not write_samples: - fft_dir = "" + fft_dir = "" + self.samples_blocks = [] + if write_samples: + fft_dir = sample_dir + Path(sample_dir).mkdir(parents=True, exist_ok=True) + self.samples_blocks.extend( + [ + # blocks.vector_to_stream( + # gr.sizeof_gr_complex, fft_batch_size * nfft + # ), + # blocks.complex_to_interleaved_short(False, 32767), + # blocks.stream_to_vector(gr.sizeof_short, nfft * 2), + self.iqtlabs.write_freq_samples( + "rx_freq", + gr.sizeof_gr_complex, + "_".join(("cf32", endianstr())), + fft_batch_size * nfft, + sample_dir, + "samples", + write_samples, + skip_tune_step, + int(samp_rate), + rotate_secs, + igain, + sigmf, + ), + ] + ) retune_fft = self.iqtlabs.retune_fft( "rx_freq", nfft, @@ -284,11 +287,8 @@ def __init__( else: self.connect((retune_fft, 1), (blocks.null_sink(gr.sizeof_float * nfft))) - for pipeline_blocks in ( - self.fft_blocks, - self.samples_blocks, - ): - self.connect_blocks(self.sources[-1], pipeline_blocks) + self.connect_blocks(self.sources[-1], self.fft_blocks) + self.connect_blocks(self.retune_pre_fft, self.samples_blocks) def connect_blocks(self, source, other_blocks, last_block_port=0): last_block = source @@ -323,6 +323,7 @@ def get_pretune_block( skip_tune_step, tuning_ranges, pretune, + low_power_hold_down, ): # if pretuning, the pretune block will also do the batching. if pretune: @@ -337,6 +338,7 @@ def get_pretune_block( skip_tune_step, tuning_ranges, self.tag_now, + low_power_hold_down, ) else: # otherwise, the pretuning block will just do batching. @@ -400,6 +402,7 @@ def get_fft_blocks( tuning_ranges, pretune, fft_processor_affinity, + low_power_hold_down, ): fft_batch_size, fft_blocks = self.get_offload_fft_blocks( vkfft, @@ -417,8 +420,9 @@ def get_fft_blocks( skip_tune_step, tuning_ranges, pretune, + low_power_hold_down, ) - return [self.retune_pre_fft] + fft_blocks + return (fft_batch_size, [self.retune_pre_fft] + fft_blocks) def start(self): super().start() From 6756ddf5651e9e5fc21daa4f8cc89244c3800a63 Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 24 Jan 2024 01:44:40 +0000 Subject: [PATCH 2/3] batch 16 --- tests/test_grscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_grscan.py b/tests/test_grscan.py index 85589540..28494985 100644 --- a/tests/test_grscan.py +++ b/tests/test_grscan.py @@ -139,7 +139,7 @@ def run_grscan_smoke(self, pretune, wavelearner, write_samples, test_file): rotate_secs=900, db_clamp_floor=-1e6, pretune=pretune, - fft_batch_size=256, + fft_batch_size=16, inference_output_dir=str(tempdir), ) tb.start() From 424a8b82f03a8196b014970f1de8233eaf9f7f3e Mon Sep 17 00:00:00 2001 From: Josh Bailey Date: Wed, 24 Jan 2024 01:53:31 +0000 Subject: [PATCH 3/3] batch. --- tests/test_grscan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_grscan.py b/tests/test_grscan.py index 28494985..01110454 100644 --- a/tests/test_grscan.py +++ b/tests/test_grscan.py @@ -139,7 +139,7 @@ def run_grscan_smoke(self, pretune, wavelearner, write_samples, test_file): rotate_secs=900, db_clamp_floor=-1e6, pretune=pretune, - fft_batch_size=16, + fft_batch_size=4, inference_output_dir=str(tempdir), ) tb.start()