Commits

Takeshi Nakazato authored 4788acc4216
CAS-13713 respect numThreads_

- no OpenMP parallelization if numThrads_ is 1 - adjusted condition for parallelization

casatools/src/code/mstransform/TVI/SDAtmosphereCorrectionTVI.cc

Modified
253 253 std::vector<Vector<Double> > const &correctionFactorList,
254 254 std::vector<Int> const &indexForCorrection,
255 255 Cube<T> &inout,
256 256 int const numThreads
257 257 ) {
258 258 IPosition const shape = inout.shape();
259 259 assert(shape[2] == static_cast<Int>(indexForCorrection.size()));
260 260 Bool b1;
261 261 T *p = inout.getStorage(b1);
262 262 // TODO: optimize condition for multi-threading
263 - #pragma omp parallel for num_threads(numThreads) if((shape[2] > 10 && shape[1] > 500))
263 + #pragma omp parallel for num_threads(numThreads) if(numThreads > 1 && shape[2] > 10 && shape[1] > 500)
264 264 for (ssize_t ir = 0; ir < shape[2]; ++ir) {
265 265 Int const index = indexForCorrection[ir];
266 266 if (index >= 0) {
267 267 Vector<Double> const &correctionFactor = correctionFactorList[index];
268 268 Bool b2;
269 269 Double const *cp = correctionFactor.getStorage(b2);
270 270 ssize_t const offset = shape[0] * shape[1] * ir;
271 271 for (ssize_t ic = 0; ic < shape[1]; ++ic) {
272 272 ssize_t idx = offset + shape[0] * ic;
273 273 for (ssize_t ip = 0; ip < shape[0]; ++ip) {
789 789 os << LogIO::DEBUGGING << "disabling thresholds end " << LogIO::POST;
790 790
791 791 std::map<SpwId, Vector<Double> > channelFreqsPerSpw;
792 792 std::map<SpwId, Vector<Double> > channelWidthsPerSpw;
793 793 for (auto i = processSpwList_.begin(); i != processSpwList_.end(); ++i) {
794 794 SpwId const spw = *i;
795 795 channelFreqsPerSpw[spw] = spectralWindowSubtablecols().chanFreq().get(spw);
796 796 channelWidthsPerSpw[spw] = spectralWindowSubtablecols().chanWidth().get(spw);
797 797 }
798 798
799 - #pragma omp parallel for num_threads(processSpwList_.size()) if(processSpwList_.size() > 1)
799 + int const numThreads = min(numThreads_, static_cast<int>(processSpwList_.size()));
800 + #pragma omp parallel for num_threads(numThreads) if(numThreads > 1)
800 801 for (unsigned int i = 0; i < processSpwList_.size(); ++i) {
801 802 SpwId const spw = processSpwList_[i];
802 803 #pragma omp critical (logging)
803 804 {
804 805 os << "creating SkyStatus for spw " << spw << LogIO::POST;
805 806 }
806 807 Vector<Double> cf = channelFreqsPerSpw[spw];
807 808 Vector<Double> cw = channelWidthsPerSpw[spw];
808 809 unsigned int nchan = cf.nelements();
809 810

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut