[med-svn] [SCM] aghermann branch, master, updated. 3b87b4f8039ed683022537a0599b7dea069974d2
Andrei Zavada
johnhommer at gmail.com
Sun Sep 30 22:40:48 UTC 2012
The following commit has been merged in the master branch:
commit c8061b5e13e1a96d54b151bd4755836cb702760a
Author: Andrei Zavada <johnhommer at gmail.com>
Date: Fri Sep 28 03:18:11 2012 +0300
make real use of omp; progress indication yet to sort out
diff --git a/configure.ac b/configure.ac
index cbb9605..2e6331a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
AC_COPYRIGHT([Copyright (c) 2008-12 Andrei Zavada <johnhommer at gmail.com>])
-AC_INIT([Aghermann], [0.7.1], [johnhommer at gmail.com])
+AC_INIT([Aghermann], [0.7.2], [johnhommer at gmail.com])
AC_CONFIG_SRCDIR([src/main.cc])
AC_CONFIG_MACRO_DIR([m4])
AC_PREREQ(2.61)
diff --git a/src/expdesign/Makefile.am b/src/expdesign/Makefile.am
index e3edb49..53a76c0 100644
--- a/src/expdesign/Makefile.am
+++ b/src/expdesign/Makefile.am
@@ -1,5 +1,6 @@
AM_CXXFLAGS = \
- -Wall -std=c++0x
+ -Wall -std=c++0x \
+ $(OPENMP_CXXFLAGS)
noinst_LIBRARIES = libexpdesign.a
diff --git a/src/expdesign/primaries-tree-scanner.cc b/src/expdesign/primaries-tree-scanner.cc
index 19365e5..28f4a28 100644
--- a/src/expdesign/primaries-tree-scanner.cc
+++ b/src/expdesign/primaries-tree-scanner.cc
@@ -305,8 +305,10 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
only_progress_fun = user_progress_fun;
__expdesign = this;
nftw( "./", edf_file_processor, 10, 0);
+ printf( "CExpDesign::scan_tree(): recordings collected\n");
- printf( "CExpDesign::scan_tree() completed\n");
+ compute_profiles(); // in an SMP fashion
+ printf( "CExpDesign::scan_tree() all computed\n");
// find any subjects with incomplete episode sets
list<string> complete_episode_set = enumerate_episodes();
@@ -342,4 +344,33 @@ scan_tree( TMsmtCollectProgressIndicatorFun user_progress_fun)
}
+void
+agh::CExpDesign::
+compute_profiles()
+{
+ vector<CRecording*> v;
+ for ( auto &G : groups )
+ for ( auto &J : G.second )
+ for ( auto &D : J.measurements )
+ for ( auto &E : D.second.episodes )
+ for ( auto &R : E.recordings )
+ if ( R.second.signal_type() == sigfile::SChannel::TType::eeg )
+ v.push_back( &R.second);
+ size_t global_i = 0;
+#pragma omp parallel for
+ for ( size_t i = 0; i < v.size(); ++i ) {
+#pragma omp critical
+ {
+ auto& R = *v[i];
+ only_progress_fun(
+ (string ("Compute ") + R.F().filename() + ":"+R.F().channel_by_id(R.h())).c_str(),
+ v.size(), ++global_i);
+ }
+
+ v[i]->CBinnedPower::compute();
+ v[i]->CBinnedMC::compute();
+ }
+}
+
+
// eof
diff --git a/src/expdesign/primaries.hh b/src/expdesign/primaries.hh
index d81d0d2..a0e068b 100644
--- a/src/expdesign/primaries.hh
+++ b/src/expdesign/primaries.hh
@@ -93,7 +93,7 @@ class CSubject {
TRecordingSet
recordings; // one per channel, naturally
- SEpisode( sigfile::CSource&& Fmc,
+ SEpisode (sigfile::CSource&& Fmc,
const sigfile::SFFTParamSet& fft_params,
const sigfile::SMCParamSet& ucont_params);
@@ -349,6 +349,7 @@ class CExpDesign {
// size_t now_processing)
static TMsmtCollectProgressIndicatorFun progress_fun_stdout;
void scan_tree( TMsmtCollectProgressIndicatorFun progress_fun = progress_fun_stdout);
+ void compute_profiles();
void sync();
// edf sources
diff --git a/src/expdesign/recording.cc b/src/expdesign/recording.cc
index 8f70bb7..bd6934b 100644
--- a/src/expdesign/recording.cc
+++ b/src/expdesign/recording.cc
@@ -28,16 +28,16 @@ CRecording (sigfile::CSource& F, int sig_no,
CBinnedMC (F, sig_no, mc_params,
fft_params.pagesize),
uc_params {NAN, NAN, NAN, NAN},
- _status (0),
+ _status (0), // not computed
_source (F), _sig_no (sig_no),
_cached_metric (sigfile::TMetricType::invalid),
_cached_freq_from (NAN),
_cached_freq_upto (NAN)
{
- if ( F.signal_type(sig_no) == sigfile::SChannel::TType::eeg ) {
- CBinnedPower::compute();
- CBinnedMC::compute();
- }
+ // if ( F.signal_type(sig_no) == sigfile::SChannel::TType::eeg ) {
+ // CBinnedPower::compute();
+ // CBinnedMC::compute();
+ // }
}
diff --git a/src/libsigfile/edf.hh b/src/libsigfile/edf.hh
index 8ad67fa..f802b5c 100644
--- a/src/libsigfile/edf.hh
+++ b/src/libsigfile/edf.hh
@@ -59,15 +59,15 @@ class CEDFFile
no_field_consistency_check = 1<<4
};
// open existing
- CEDFFile( const char *fname, int flags = 0);
+ CEDFFile (const char *fname, int flags = 0);
// create new
- CEDFFile( const char *fname, int flags,
+ CEDFFile (const char *fname, int flags,
const list<pair<string, size_t>>& channels,
size_t data_record_size = 1,
size_t n_data_records = 0);
- CEDFFile( CEDFFile&& rv);
+ CEDFFile (CEDFFile&& rv);
// dtor
- ~CEDFFile();
+ ~CEDFFile ();
// interface
// status
diff --git a/src/libsigfile/mc.cc b/src/libsigfile/mc.cc
index 6911a1b..f464f63 100644
--- a/src/libsigfile/mc.cc
+++ b/src/libsigfile/mc.cc
@@ -90,7 +90,7 @@ reset()
sigfile::CBinnedMC::
-CBinnedMC( const CSource& F, int sig_no,
+CBinnedMC (const CSource& F, int sig_no,
const SMCParamSet ¶ms,
size_t pagesize)
: CPageMetrics_base (F, sig_no,
diff --git a/src/libsigfile/page-metrics-base.hh b/src/libsigfile/page-metrics-base.hh
index 19ca2f6..cff0592 100644
--- a/src/libsigfile/page-metrics-base.hh
+++ b/src/libsigfile/page-metrics-base.hh
@@ -127,7 +127,10 @@ class CPageMetrics_base {
virtual string fname_base() const = 0;
protected:
- enum TFlags : int { computed = 1 };
+ enum TFlags : int {
+ computed = (1<<0),
+ computable = (1<<1)
+ };
int _status;
valarray<double> // arrays in a given bin extracted by slices
diff --git a/src/libsigfile/psd.cc b/src/libsigfile/psd.cc
index 1946000..a96d459 100644
--- a/src/libsigfile/psd.cc
+++ b/src/libsigfile/psd.cc
@@ -208,38 +208,34 @@ compute( const SFFTParamSet& req_params,
// 4. obtain power spectrum
// prepare
- static double
- *fft_Ti = nullptr,
- *fft_To = nullptr;
- static valarray<double> // buffer for PSD
- P;
+ double
+ *fft_Ti = (double*)fftw_malloc( sizeof(double) * spp * 2),
+ *fft_To = (double*)fftw_malloc( sizeof(double) * spp * 2);
+ valarray<double> // buffer for PSD
+ P (spp+2);
+
static fftw_plan fft_plan = NULL;
static size_t saved_spp = 0;
-
- if ( fft_plan == nullptr ) {
-#if defined(HAVE_LIBFFTW3_OMP) && defined(_OPENMP)
- int n_procs = omp_get_max_threads();
- fftw_init_threads();
- fftw_plan_with_nthreads( n_procs);
- printf( "Will use %d core(s)\n", n_procs);
-#endif
- }
- if ( fft_plan == nullptr || spp != saved_spp ) {
-
- printf( "Preparing fftw plan for %zu samples...", spp);
- saved_spp = spp;
-
- fftw_free( fft_Ti);
- fftw_free( fft_To);
-
- fft_Ti = (double*) fftw_malloc( sizeof(double) * spp * 2);
- fft_To = (double*) fftw_malloc( sizeof(double) * spp * 2);
- P.resize( spp+2);
- // and let them lie spare
-
- memcpy( fft_Ti, &S[0], spp * sizeof(double)); // not necessary?
- fft_plan = fftw_plan_dft_r2c_1d( spp, fft_Ti, (fftw_complex*)fft_To, 0 /* FFTW_PATIENT */);
- printf( "done\n");
+#pragma omp single
+ {
+// if ( fft_plan == nullptr ) {
+//#if defined(HAVE_LIBFFTW3_OMP) && defined(_OPENMP)
+// int n_procs = omp_get_max_threads();
+// fftw_init_threads();
+// fftw_plan_with_nthreads( n_procs);
+// fftw_plan();
+// printf( "Will use %d core(s)\n", n_procs);
+//#endif
+// }
+ if ( fft_plan == nullptr || spp != saved_spp ) {
+
+ 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( spp, fft_Ti, (fftw_complex*)fft_To, 0 /* FFTW_PATIENT */);
+ printf( "done\n");
+ }
}
// go
@@ -291,6 +287,9 @@ compute( const SFFTParamSet& req_params,
if ( _mirror_enable( new_mirror_fname) ) {}
+ fftw_free( fft_Ti);
+ fftw_free( fft_To);
+
_status |= TFlags::computed;
return 0;
}
diff --git a/src/ui/expdesign.cc b/src/ui/expdesign.cc
index 6a2042c..b50ca6b 100644
--- a/src/ui/expdesign.cc
+++ b/src/ui/expdesign.cc
@@ -191,8 +191,8 @@ SExpDesignUI (aghui::SSessionChooser *parent,
" Whatever the reason, this is really too bad: I can't fix it for you.");
}
ED = new agh::CExpDesign (dir,
- {bind( &SExpDesignUI::sb_main_progress_indicator, this,
- placeholders::_1, placeholders::_2, placeholders::_3)});
+ bind( &SExpDesignUI::sb_main_progress_indicator, this,
+ placeholders::_1, placeholders::_2, placeholders::_3));
nodestroy_by_cb = false;
fft_params_welch_window_type_saved = ED->fft_params.welch_window_type;
@@ -413,8 +413,8 @@ do_rescan_tree( bool ensure)
depopulate( false);
ED -> sync();
if ( ensure )
- ED -> scan_tree( {bind (&SExpDesignUI::sb_main_progress_indicator, this,
- placeholders::_1, placeholders::_2, placeholders::_3)});
+ ED -> scan_tree( bind (&SExpDesignUI::sb_main_progress_indicator, this,
+ placeholders::_1, placeholders::_2, placeholders::_3));
else
ED -> scan_tree();
populate( false);
@@ -984,12 +984,10 @@ try_download()
void
aghui::SExpDesignUI::
-buf_on_main_status_bar( bool ensure)
+buf_on_main_status_bar()
{
gtk_statusbar_pop( sbMainStatusBar, sbMainContextIdGeneral);
gtk_statusbar_push( sbMainStatusBar, sbMainContextIdGeneral, __buf__);
- if ( ensure )
- aghui::gtk_flush();
}
void
@@ -997,7 +995,8 @@ aghui::SExpDesignUI::
sb_main_progress_indicator( const char* current, size_t n, size_t i)
{
snprintf_buf( "(%zu of %zu) %s", i, n, current);
- buf_on_main_status_bar( true);
+ buf_on_main_status_bar();
+ gtk_flush();
}
diff --git a/src/ui/expdesign.hh b/src/ui/expdesign.hh
index 551bc62..f6de102 100644
--- a/src/ui/expdesign.hh
+++ b/src/ui/expdesign.hh
@@ -160,7 +160,7 @@ class SExpDesignUI {
void populate_1(); // measurements
void populate_2(); // simulations
void cleanup_2();
- void do_rescan_tree( bool ensure = true); // with while ... gtk_main_iteration ...
+ void do_rescan_tree( bool with_progress_bar = true);
void do_purge_computed();
void do_detect_ultradian_cycle( agh::CRecording&);
@@ -286,7 +286,7 @@ class SExpDesignUI {
// status bar bits
void sb_main_progress_indicator( const char*, size_t n, size_t i);
- void buf_on_main_status_bar( bool ensure = true);
+ void buf_on_main_status_bar();
guint sbMainContextIdGeneral;
// dnd
diff --git a/src/ui/expdesign_cb.cc b/src/ui/expdesign_cb.cc
index 7b2e619..d19652e 100644
--- a/src/ui/expdesign_cb.cc
+++ b/src/ui/expdesign_cb.cc
@@ -96,7 +96,7 @@ void
iExpRefresh_activate_cb( GtkMenuItem*, gpointer userdata)
{
auto& ED = *(SExpDesignUI*)userdata;
- ED.do_rescan_tree( false);
+ ED.do_rescan_tree( false); // no progress bar
}
void
@@ -141,7 +141,7 @@ iExpBasicSADetectUltradianCycles_activate_cb( GtkMenuItem*, gpointer userdata)
snprintf_buf(
"(%zu of %zu) %s/%s/%s", ++i, n,
G.first.c_str(), J.name(), E.name());
- ED.buf_on_main_status_bar( true);
+ ED.buf_on_main_status_bar();
gtk_widget_queue_draw( (GtkWidget*)ED.cMeasurements);
}
}
--
Sleep experiment manager
More information about the debian-med-commit
mailing list