Ticket #75: cps_threading_1.patch
File cps_threading_1.patch, 5.5 KB (added by , 15 years ago) |
---|
-
COMIX/Phasespace/PS_Channel.C
193 193 (const Current_Base *cur,const size_t &id) 194 194 { 195 195 if (cur!=NULL) { 196 CVegas_Map::const_iterator vit(m_pcmap.find(cur));197 if (vit!=m_pcmap.end()) return vit->second;198 196 #ifdef USING__Threading 199 197 pthread_mutex_lock(&m_vgs_mtx); 200 198 #endif 201 m_pcmap[cur]=GetVegas("P_"+cur->PSInfo()); 199 Vegas *vgs(NULL); 200 CVegas_Map::const_iterator vit(m_pcmap.find(cur)); 201 if (vit!=m_pcmap.end()) vgs=vit->second; 202 else vgs=m_pcmap[cur]=GetVegas("P_"+cur->PSInfo()); 202 203 #ifdef USING__Threading 203 204 pthread_mutex_unlock(&m_vgs_mtx); 204 205 #endif 205 return m_pcmap[cur];206 return vgs; 206 207 } 207 IVegas_Map::const_iterator vit(m_pimap.find(id));208 if (vit!=m_pimap.end()) return vit->second;209 208 #ifdef USING__Threading 210 209 pthread_mutex_lock(&m_vgs_mtx); 211 210 #endif 212 m_pimap[id]=GetVegas("P_"+GetPSId(id)); 211 Vegas *vgs(NULL); 212 IVegas_Map::const_iterator vit(m_pimap.find(id)); 213 if (vit!=m_pimap.end()) vgs=vit->second; 214 else vgs=m_pimap[id]=GetVegas("P_"+GetPSId(id)); 213 215 #ifdef USING__Threading 214 216 pthread_mutex_unlock(&m_vgs_mtx); 215 217 #endif 216 return m_pimap[id];218 return vgs; 217 219 } 218 220 219 221 PHASIC::Vegas *PS_Channel::GetCVegas(const size_t &id,const size_t &n) 220 222 { 221 IVegas_Map::const_iterator vit(m_cimap.find(id));222 if (vit!=m_cimap.end()) return vit->second;223 223 #ifdef USING__Threading 224 224 pthread_mutex_lock(&m_vgs_mtx); 225 225 #endif 226 m_cimap[id]=GetVegas("C_"+GetPSId(id)+"_"+ToString(n),n); 226 Vegas *vgs(NULL); 227 IVegas_Map::const_iterator vit(m_cimap.find(id)); 228 if (vit!=m_cimap.end()) vgs=vit->second; 229 else vgs=m_cimap[id]=GetVegas("C_"+GetPSId(id)+"_"+ToString(n),n); 227 230 #ifdef USING__Threading 228 231 pthread_mutex_unlock(&m_vgs_mtx); 229 232 #endif 230 return m_cimap[id];233 return vgs; 231 234 } 232 235 233 236 PHASIC::Vegas *PS_Channel::GetSVegas 234 237 (const size_t &id,const Current_Base *cur) 235 238 { 239 #ifdef USING__Threading 240 pthread_mutex_lock(&m_vgs_mtx); 241 #endif 242 Vegas *vgs(NULL); 236 243 ICVegas_Map::const_iterator vit(m_sicmap.find(id)); 237 244 if (vit!=m_sicmap.end()) { 238 245 CVegas_Map::const_iterator it(vit->second.find(cur)); 239 if (it!=vit->second.end()) returnit->second;246 if (it!=vit->second.end()) vgs=it->second; 240 247 } 241 #ifdef USING__Threading 242 pthread_mutex_lock(&m_vgs_mtx); 243 #endif 244 m_sicmap[id][cur]=GetVegas("S_"+GetPSId(id)+"_"+cur->PSInfo()); 248 if (vgs==NULL) vgs=m_sicmap[id][cur]= 249 GetVegas("S_"+GetPSId(id)+"_"+cur->PSInfo()); 245 250 #ifdef USING__Threading 246 251 pthread_mutex_unlock(&m_vgs_mtx); 247 252 #endif 248 return m_sicmap[id][cur];253 return vgs; 249 254 } 250 255 251 256 PHASIC::Vegas *PS_Channel::GetTVegas 252 257 (const size_t &id,const Current_Base *cur) 253 258 { 259 #ifdef USING__Threading 260 pthread_mutex_lock(&m_vgs_mtx); 261 #endif 262 Vegas *vgs(NULL); 254 263 ICVegas_Map::const_iterator vit(m_ticmap.find(id)); 255 264 if (vit!=m_ticmap.end()) { 256 265 CVegas_Map::const_iterator it(vit->second.find(cur)); 257 if (it!=vit->second.end()) returnit->second;266 if (it!=vit->second.end()) vgs=it->second; 258 267 } 259 #ifdef USING__Threading 260 pthread_mutex_lock(&m_vgs_mtx); 261 #endif 262 m_ticmap[id][cur]=GetVegas("T_"+GetPSId(id)+"_"+cur->PSInfo()); 268 if (vgs==NULL) vgs=m_ticmap[id][cur]= 269 GetVegas("T_"+GetPSId(id)+"_"+cur->PSInfo()); 263 270 #ifdef USING__Threading 264 271 pthread_mutex_unlock(&m_vgs_mtx); 265 272 #endif 266 return m_ticmap[id][cur];273 return vgs; 267 274 } 268 275 269 276 bool PS_Channel::Zero(Vertex_Base *const vtx) const -
PHASIC++/Channels/Vegas.C
167 167 return p_x; 168 168 } 169 169 170 double Vegas::GenerateWeight(const double* xy) 170 double Vegas::GenerateWeight(const double* xy) const 171 171 { 172 172 if (m_on==0) return 1.; 173 m_weight = m_nc;173 double weight = m_nc; 174 174 for (int i=0;i<m_dim;i++) { 175 175 size_t l(0), r(m_nd-1), c((l+r)/2); 176 176 double a(p_xi[i][c]); … … 184 184 int k(r); 185 185 p_ia[i] = k; 186 186 if (k==0) { 187 m_weight *= p_xi[i][k];187 weight *= p_xi[i][k]; 188 188 } 189 189 else { 190 m_weight *= p_xi[i][k]-p_xi[i][k-1];190 weight *= p_xi[i][k]-p_xi[i][k-1]; 191 191 } 192 192 } 193 return m_weight;193 return weight; 194 194 } 195 195 196 double Vegas::GenerateBinWeight(int* xy) 196 double Vegas::GenerateBinWeight(int* xy) const 197 197 { 198 198 if (m_on==0) return 1.; 199 m_weight = m_nc;199 double weight = m_nc; 200 200 for (int i=0;i<m_dim;i++) { 201 201 int k(xy[i]); 202 202 p_ia[i] = k; 203 203 if (k==0) { 204 m_weight *= p_xi[i][k];204 weight *= p_xi[i][k]; 205 205 } 206 206 else { 207 m_weight *= p_xi[i][k]-p_xi[i][k-1];207 weight *= p_xi[i][k]-p_xi[i][k-1]; 208 208 } 209 209 } 210 return m_weight;210 return weight; 211 211 } 212 212 213 213 double *Vegas::GetBinsMean(int *xy) const -
PHASIC++/Channels/Vegas.H
12 12 int m_nd; 13 13 unsigned long m_nevt,m_nopt,m_snevt,m_cevt; 14 14 double m_alpha; 15 double m_ weight,m_sum,m_sum2;15 double m_sum,m_sum2; 16 16 double m_nc; 17 17 double **p_xi; 18 18 double *p_x,*p_xin,*p_r,*p_cx,*p_bm; … … 28 28 Vegas(int dim,int ndx,const std::string &,int=1); 29 29 ~Vegas(); 30 30 double* GeneratePoint(const double * _ran); 31 double GenerateWeight(const double *) ;32 double GenerateBinWeight(int *) ;31 double GenerateWeight(const double *) const; 32 double GenerateBinWeight(int *) const; 33 33 void AddPoint(double,double *); 34 34 void AddBinPoint(double,int *); 35 35