Skip to content

Commit

Permalink
Allocate buffers for downsampling and FFA with smallest possible size
Browse files Browse the repository at this point in the history
  • Loading branch information
v-morello committed May 3, 2020
1 parent 8799850 commit 6d134ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 0.1.4 - UNRELEASED
## 0.1.4 - 2020-05-03

This version reduces RAM usage significantly. Trial periods are now stored as double precision floats.

### Fixed
- Trial periods are now stored as double precision floats (`double` in C, `float` in python). When searching very long time series (several hours) and short trial periods, single precision floats were inaccurate enough that small groups of consecutive period trials erroneously ended up having the exact same value. Incorrect detection periods would propagate down the pipeline, and `Candidate` objects could end up being folded with a period slightly offset from the true value.
- Trial periods are now stored as *double* precision floats (`double` in C, `float` in python). When searching very long time series (several hours) and short trial periods, single precision floats were inaccurate enough that small groups of consecutive period trials erroneously ended up having the exact same value. Incorrect detection periods would propagate down the pipeline, and `Candidate` objects could end up being folded with a period slightly offset from the true value.

### Changed
- The pipeline worker sub-processes now get passed a *file path* to a time series as an input, rather than a full `TimeSeries` object, which saves the cost of communicating a lot of data between processes.
- The pipeline worker sub-processes now get passed a *file path* to a time series as an input, rather than a full `TimeSeries` object, which saves the cost of communicating a lot of data between processes
- The buffers used for downsampling and FFA transforming the data when calculating periodograms are now given the smallest possible size. They only need to hold `N / f` data points, where `N` is the number of samples in the raw time series, and `f` the first downsampling factor in the search plan. Buffers were previously given a size of `N` which was often wasteful.

### Added
- Added option to save pipeline logs to file
Expand Down
9 changes: 5 additions & 4 deletions riptide/c_src/libffa.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,17 @@ void py_periodogram(
size_t nsteps, // number of plan steps
const long int* restrict widths, // sequence of pulse width trials, in number of bins
size_t nw, // number of width trials
double* restrict periods, // period trials (output)
double* restrict periods, // period trials (output)
float* restrict snr // S/N (output)
)
{
// Allocate buffer for downsampled time series
float* in = (float*)malloc(nsamp * sizeof(float));
size_t bytesize = floor(nsamp / dsfactor[0]) * sizeof(float);
float* in = (float*)malloc(bytesize);

// Allocate FFA buffers
float* out = (float*)malloc(nsamp * sizeof(float));
float* buf = (float*)malloc(nsamp * sizeof(float));
float* out = (float*)malloc(bytesize);
float* buf = (float*)malloc(bytesize);

// MAIN LOOP
for (size_t istep=0; istep<nsteps; ++istep)
Expand Down

0 comments on commit 6d134ba

Please sign in to comment.