Commit 3533fd55 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

fix non-OpenMP mode

parent bf42bc10
...@@ -739,6 +739,9 @@ class Lock ...@@ -739,6 +739,9 @@ class Lock
void lock() { omp_set_lock(&lck); } void lock() { omp_set_lock(&lck); }
void unlock() { omp_unset_lock(&lck); } void unlock() { omp_unset_lock(&lck); }
}; };
int my_max_threads() { return omp_get_max_threads(); }
int my_num_threads() { return omp_get_num_threads(); }
int my_thread_num() { return omp_get_thread_num(); }
#else #else
class Lock class Lock
{ {
...@@ -746,8 +749,11 @@ class Lock ...@@ -746,8 +749,11 @@ class Lock
Lock() {} Lock() {}
~Lock() {} ~Lock() {}
void lock() {} void lock() {}
void unlock {} void unlock() {}
}; };
int my_max_threads() { return 1; }
int my_num_threads() { return 1; }
int my_thread_num() { return 0; }
#endif #endif
template<typename T, typename T2=complex<T>> class Helper template<typename T, typename T2=complex<T>> class Helper
...@@ -1315,7 +1321,11 @@ template<typename Serv> void wstack_common( ...@@ -1315,7 +1321,11 @@ template<typename Serv> void wstack_common(
double wmax; double wmax;
wminmax(gconf, srv, wmin, wmax); wminmax(gconf, srv, wmin, wmax);
#ifdef _OPENMP
if (verbosity>0) cout << "Using " << nthreads << " threads" << endl; if (verbosity>0) cout << "Using " << nthreads << " threads" << endl;
#else
if (verbosity>0) cout << "Using single-threaded mode" << endl;
#endif
if (verbosity>0) cout << "W range: " << wmin << " to " << wmax << endl; if (verbosity>0) cout << "W range: " << wmin << " to " << wmax << endl;
double x0 = -0.5*gconf.Nxdirty()*gconf.Pixsize_x(), double x0 = -0.5*gconf.Nxdirty()*gconf.Pixsize_x(),
y0 = -0.5*gconf.Nydirty()*gconf.Pixsize_y(); y0 = -0.5*gconf.Nydirty()*gconf.Pixsize_y();
...@@ -1333,12 +1343,12 @@ template<typename Serv> void wstack_common( ...@@ -1333,12 +1343,12 @@ template<typename Serv> void wstack_common(
nvis_plane.resize(nplanes,0); nvis_plane.resize(nplanes,0);
minplane.resize(nplanes); minplane.resize(nplanes);
vector<size_t> tcnt(omp_get_max_threads()*nplanes,0); vector<size_t> tcnt(my_max_threads()*nplanes,0);
#pragma omp parallel num_threads(nthreads) #pragma omp parallel num_threads(nthreads)
{ {
vector<size_t> mytcnt(nplanes,0); vector<size_t> mytcnt(nplanes,0);
vector<size_t> nvp(nplanes,0); vector<size_t> nvp(nplanes,0);
auto mythread = omp_get_thread_num(); auto mythread = my_thread_num();
#pragma omp for schedule(static) #pragma omp for schedule(static)
for (size_t ipart=0; ipart<nvis; ++ipart) for (size_t ipart=0; ipart<nvis; ++ipart)
{ {
...@@ -1359,7 +1369,7 @@ template<typename Serv> void wstack_common( ...@@ -1359,7 +1369,7 @@ template<typename Serv> void wstack_common(
for (size_t j=0; j<nplanes; ++j) for (size_t j=0; j<nplanes; ++j)
{ {
size_t l=0; size_t l=0;
for (size_t i=0; i<nthreads; ++i) for (size_t i=0; i<my_num_threads(); ++i)
l+=tcnt[i*nplanes+j]; l+=tcnt[i*nplanes+j];
minplane[j].resize(l); minplane[j].resize(l);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment