[med-svn] [SCM] aghermann branch, master, updated. c0bd21ca8eb529ade7e0c7aad22951a308a8dc8f
Andrei Zavada
johnhommer at gmail.com
Wed May 1 00:09:28 UTC 2013
The following commit has been merged in the master branch:
commit 4ebefa7399094351022ce647b1e3a284b18c4d19
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Tue Apr 23 18:32:11 2013 +0300
fix OMP-assisted crash when taking FFT on channels wth variable samplerates
diff --git a/ChangeLog b/ChangeLog
index 776304a..3f57c94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,8 @@ v.0.9 (2013-xx-xx)
* Make all timestamps in sidecar files (a) relative to recording
start, (b) expressed in seconds, to be consistent with embedded
annotations.
+ * Fix crash when getting PSD on montage having channels with
+ variable sample rate, on OMP-enabled hosts.
v.0.8.2 (2013-04-07)
* Fix GtkScrolledWindow issue in Annotations dialog.
diff --git a/src/metrics/psd.cc b/src/metrics/psd.cc
index dbb7faf..50cc355 100644
--- a/src/metrics/psd.cc
+++ b/src/metrics/psd.cc
@@ -161,8 +161,7 @@ go_compute()
valarray<double> // buffer for PSD
P (spp+2);
- static fftw_plan fft_plan = NULL;
- static size_t saved_spp = 0;
+ static map<size_t, fftw_plan> plannen;
#ifdef _OPENMP
#pragma omp critical
#endif
@@ -177,13 +176,12 @@ go_compute()
//#endif
// }
// use single-threaded fftw; SMP active at a higher level
- if ( fft_plan == nullptr || spp != saved_spp ) {
+ if ( plannen.find( spp) == plannen.end() ) {
printf( "Preparing fftw plan for %zu samples...", spp);
- saved_spp = spp;
- memcpy( fft_Ti, &S[0], spp * sizeof(double)); // not necessary?
- fft_plan = fftw_plan_dft_r2c_1d(
+ //memcpy( fft_Ti, &S[0], spp * sizeof(double)); // not necessary?
+ plannen[spp] = fftw_plan_dft_r2c_1d(
spp, fft_Ti, (fftw_complex*)fft_To,
plan_flags(Pp.plan_type));
printf( "done\n");
@@ -214,7 +212,7 @@ go_compute()
for ( size_t s = 0; s < spp; ++s )
fft_Ti[s] *= W[s];
- fftw_execute_dft_r2c( fft_plan, fft_Ti, (fftw_complex*)fft_To);
+ fftw_execute_dft_r2c( plannen[spp], fft_Ti, (fftw_complex*)fft_To);
// thanks http://www.fftw.org/fftw2_doc/fftw_2.html
P[0] = fft_To[0] * fft_To[0]; /* DC component */
--
Sleep experiment manager
More information about the debian-med-commit
mailing list