import bifrost.pipeline as bfp from bifrost.blocks import BinaryFileReadBlock, BinaryFileWriteBlock, FftBlock from bifrost.blocks import CopyBlock from scipy.fftpack import fft as scipy_fft if __name__ == "__main__": # FFT Parameters window_len = 2**18 n_window = 32 # Setup pipeline filenames = sorted(glob.glob('testdata/noisy_data*.bin')) b_read = BinaryFileReadBlock(filenames, window_len, 1, 'cf32', core=0) b_copy = CopyBlock(b_read, space='cuda', core=1, gpu=0) b_fft = FftBlock(b_copy, axes=1, core=2, gpu=0) b_out = CopyBlock(b_fft, space='system', core=3) b_write = BinaryFileWriteBlock(b_out, core=4) # Run pipeline pipeline = bfp.get_default_pipeline() print(pipeline.dot_graph()) pipeline.run() # Check the output files match the input files for filename in filenames: try: print(filename) # Load the input data, do a windowed FFT
import os import numpy as np import bifrost.pipeline as bfp from bifrost.blocks import BinaryFileReadBlock, BinaryFileWriteBlock, FftBlock, CopyBlock, print_header from bifrost.blocks import detect, reduce from bifrost.views import split_axis import glob import time if __name__ == "__main__": filenames = sorted(glob.glob('../data/*.bin')) Nsamp = 1024 * 1024 b_read = BinaryFileReadBlock(filenames, 1024, 1024, 'f32') b_read_rs = split_axis(b_read, axis=1, n=1024, label='time') b_copy = CopyBlock(b_read_rs, space='cuda', core=0, gpu=0) with bfp.block_scope(core=1, gpu=0, fuse=True): b_fft = FftBlock(b_copy, axes=1, core=1, gpu=0) b_fft = detect(b_fft, 'scalar') b_acc = reduce(b_fft, axis=2, op='mean') b_out = CopyBlock(b_acc, space='system', core=2) b_write = BinaryFileWriteBlock(b_out, core=3) print_header(b_read) #print_header(b_read_rs) print_header(b_copy) print_header(b_fft) print_header(b_acc) print_header(b_out) #print_header(b_write) #t0 = time.time() pipeline = bfp.get_default_pipeline()