Commits

Takeshi Nakazato authored 34fe6e9c2c2
CAS-13713 more fix on omp parallelization

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

Modified
1077 1077 Int const atmTimeIndex = iter->first;
1078 1078 std::vector<unsigned int> timeIndexList = iter->second;
1079 1079 Bool const isSkyStatusUpdated = updateSkyStatus(skyStatus, atmTimeIndex);
1080 1080 if (isSkyStatusUpdated) {
1081 1081 os << "Initializing ATM profile. SPW " << currentSpwId_
1082 1082 << " Data timestamp " << timeToString(timeListForCorrection[timeIndexList[0]])
1083 1083 << " weather data timestamp " << timeToString(atmTime_[atmTimeIndex])
1084 1084 << LogIO::POST;
1085 1085 }
1086 1086 atm::SkyStatus ss(skyStatus);
1087 - #pragma omp parallel for firstprivate(ss) num_threads(numThreads_) if(timeIndexList.size() > 1)
1087 + int const numThreads = min(numThreads_, static_cast<int>(timeIndexList.size()));
1088 + #pragma omp parallel for firstprivate(ss) num_threads(numThreads) if(numThreads > 1)
1088 1089 for (unsigned int i = 0; i < timeIndexList.size(); ++i) {
1089 1090 Double const t = timeListForCorrection[timeIndexList[i]];
1090 1091 Vector<Double> correctionFactor = updateCorrectionFactor(ss, t);
1091 1092 correctionFactorList_[timeIndexList[i]].assign(correctionFactor);
1092 1093 // #pragma omp critical (logging)
1093 1094 // {
1094 1095 // os << "THREAD " << omp_get_thread_num() << ": ";
1095 1096 // os.output() << std::setprecision(16);
1096 1097 // os << "time " << t << " index " << i
1097 1098 // << " correctionFactor[0] " << correctionFactor[0] << LogIO::POST;

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

Add shortcut