Bug Summary

File:libraries/DANA/DApplication.cc
Location:line 108, column 9
Description:Value stored to 'sse4_1' is never read

Annotated Source Code

1// $Id$
2//
3// File: DApplication.cc
4// Created: Mon Jul 3 21:46:01 EDT 2006
5// Creator: davidl (on Darwin Harriet.local 8.6.0 powerpc)
6//
7
8#include <string>
9using std::string;
10#include <JANA/JVersion.h>
11
12#include <pthread.h>
13
14#include "DApplication.h"
15#include <HDDM/DEventSourceHDDMGenerator.h>
16#include <HDDM/DEventSourceRESTGenerator.h>
17#include <HDGEOMETRY/DMagneticFieldMapCalibDB.h>
18#include <HDGEOMETRY/DMagneticFieldMapFineMesh.h>
19#include <HDGEOMETRY/DMagneticFieldMapConst.h>
20#include <HDGEOMETRY/DMagneticFieldMapSpoiled.h>
21#include <HDGEOMETRY/DMagneticFieldMapParameterized.h>
22#include <HDGEOMETRY/DLorentzMapCalibDB.h>
23//#include "HDGEOMETRY/DMaterialMapCalibDB.h"
24#include <HDGEOMETRY/DRootGeom.h>
25#include "DFactoryGenerator.h"
26
27#include "DANARootErrorHandler.h"
28
29
30//---------------------------------
31// DApplication (Constructor)
32//---------------------------------
33DApplication::DApplication(int narg, char* argv[]):JApplication(narg, argv)
34{
35 pthread_mutex_init(&mutex, NULL__null);
36
37 /// Add DEventSourceHDDMGenerator and
38 /// DFactoryGenerator, which adds the default
39 /// list of Hall-D factories
40 event_source_generator = new DEventSourceHDDMGenerator();
41 factory_generator = new DFactoryGenerator();
42 AddEventSourceGenerator(event_source_generator);
43 AddEventSourceGenerator(new DEventSourceRESTGenerator());
44 AddFactoryGenerator(factory_generator);
45
46 // Add plugin paths to Hall-D specific binary directories
47 const char *bms = getenv("BMS_OSNAME");
48 string sbms(bms==NULL__null ? "":bms);
49
50 if(const char *ptr = getenv("DANA_PLUGIN_PATH")){
51 AddPluginPath(string(ptr));
52 }
53 if(const char *ptr = getenv("HALLD_MY")){
54 AddPluginPath(string(ptr) + "/lib/" + sbms);
55 }
56 if(const char *ptr = getenv("HALLD_HOME")){
57 AddPluginPath(string(ptr) + "/lib/" + sbms);
58 }
59
60 // Initialize pointers to NULL. Objects will be instantiated as needed
61 bfield = NULL__null;
62 lorentz_def = NULL__null;
63 RootGeom = NULL__null;
64
65 // Since we defer reading in some tables until they are requested
66 // (likely while processing the first event) that time gets counted
67 // against the thread as being non-reponsive. The default timeout
68 // of 8 seconds is therefore too small. Change it to 30 here,
69 // unless the user has set it explicitly on the command line.
70 map<string,string> parmap;
71 JParameterManager *pm = GetJParameterManager();
72 pm->GetParameters(parmap, "THREAD_TIMEOUT");
73 if (parmap.empty()) {
74 pm->SetParameter("THREAD_TIMEOUT", "30 seconds");
75 }
76 if(JVersion::minor<5)Init();
77}
78
79//---------------------------------
80// Init
81//---------------------------------
82jerror_t DApplication::Init(void)
83{
84 this->JApplication::Init();
85
86 // Install our own error handler for ROOT message
87 int ROOT_ERROR_LEVEL_SUPRESS = 10000;
88 GetJParameterManager()->SetDefaultParameter("ROOT_ERROR_LEVEL_SUPRESS", ROOT_ERROR_LEVEL_SUPRESS);
89 InitDANARootErrorHandler(ROOT_ERROR_LEVEL_SUPRESS);
90
91 // Check if running on a cpu that supports the instruction set
92 // extensions that were assumed when this application was built
93 unsigned int cpeinfo;
94 unsigned int cpsse3;
95 unsigned int amdinfo;
96 asm("mov $0x01, %%eax\ncpuid\n"
97 : "=d" (cpeinfo), "=c" (cpsse3)
98 );
99 asm("mov $0x80000001, %%eax\ncpuid\n"
100 : "=d" (amdinfo)
101 );
102 int mmx,sse,sse2,sse3,ssse3,sse4_1,sse4_2,sse4a;
103 mmx = ((cpeinfo >> 23) & 0x1 );
104 sse = ((cpeinfo >> 25) & 0x1 );
105 sse2 = ((cpeinfo >> 26) & 0x1 );
106 sse3 = ((cpsse3 ) & 0x1 );
107 ssse3 = ((cpsse3 >> 9) & 0x1 );
108 sse4_1 = ((cpsse3 >> 19) & 0x1 );
Value stored to 'sse4_1' is never read
109 sse4_2 = ((cpsse3 >> 20) & 0x1 );
110 sse4a = ((amdinfo >> 6) & 0x1 );
111
112#if USE_SIMD
113 if (sse == 0) {
114 jerr<<"DApplication::Init error - application was built"
115 <<" to run only on machines" << endl
116 <<"supporting the SSE processor extensions."
117 <<" Please run on a processor that" << endl
118 <<"supports SSE, or rebuild with DISABLE_SIMD=yes."
119 << endl;
120 return UNRECOVERABLE_ERROR;
121 }
122#endif
123
124#if USE_SSE2
125 if (sse2 == 0) {
126 jerr<<"DApplication::Init error - application was built"
127 <<" to run only on machines" << endl
128 <<"supporting the SSE2 processor extensions."
129 <<" Please run on a processor that" << endl
130 <<"supports SSE2, or rebuild with DISABLE_SSE2=yes."
131 << endl;
132 return UNRECOVERABLE_ERROR;
133 }
134#endif
135
136#if USE_SSE3
137 if (sse3 == 0) {
138 jerr<<"DApplication::Init error - application was built"
139 <<" to run only on machines" << endl
140 <<"supporting the SSE3 processor extensions."
141 <<" Please run on a processor that" << endl
142 <<"supports SSE3, or rebuild with DISABLE_SSE3=yes."
143 << endl;
144 return UNRECOVERABLE_ERROR;
145 }
146#endif
147
148 return NOERROR;
149}
150
151//---------------------------------
152// ~DApplication (Destructor)
153//---------------------------------
154DApplication::~DApplication()
155{
156 if(bfield) delete bfield;
157 if(lorentz_def) delete lorentz_def;
158
159 // As of JANA 0.6.3 and later, the following are
160 // automatically deleted when ~JApplication is called.
161 // Freeing them a second time causes seg. faults. so
162 // we disable that here. 2/14/2011 DL
163 //if(event_source_generator) delete event_source_generator;
164 //if(factory_generator) delete factory_generator;
165 //if(RootGeom) delete RootGeom;
166 //for(unsigned int i=0; i<geometries.size(); i++) delete geometries[i];
167}
168
169//---------------------------------
170// GetDGeometry
171//---------------------------------
172DGeometry* DApplication::GetDGeometry(unsigned int run_number)
173{
174 /// Get the DGeometry object for the specified run number.
175 /// The DGeometry class is Hall-D specific. It uses the
176 /// JGeometry class from JANA to access values in the HDDS
177 /// XML files. However, it supplies some useful and more
178 /// user friendly methods for getting at some of the values.
179 ///
180 /// This will first look for the DGeometry object in a list
181 /// kept internal to DApplication and return a pointer to the
182 /// object if found there. If it is not found there, then
183 /// a new DGeometry object will be created and added to the
184 /// internal list before returning a pointer to it.
185 ///
186 /// Note that since this method can change internal data
187 /// members, a mutex is locked to ensure integrity. This
188 /// means that it is <b>NOT</b> efficient to call this
189 /// method for every event. The pointer should be obtained
190 /// in a brun() method and kept in a local variable if
191 /// needed outside of brun().
192
193 // At this point in time, only simulation exists with geometry coming
194 // from a JGeometryXML object. The run range for these objects is
195 // always set to include only the run number requested so if multiple
196 // places in the code ask for different run numbers (as happens) a
197 // second DGeometry object is created unecessarily. Here, we look to
198 // see if a sole DGeometry object already exists and if so, if it is
199 // built on a JGeometryFile object. If so, simply return it under the
200 // assumption we are still doing development with simulated data and
201 // a single set of geometry files.
202 Lock();
203 if(geometries.size()==1 && string("JGeometryXML")==geometries[0]->GetJGeometry()->className()){
204 Unlock();
205 return geometries[0];
206 }
207 Unlock();
208
209 // First, get the JGeometry object using our JApplication
210 // base class. Then, use that to find the correct DGeometry
211 // object if it exists.
212 JGeometry *jgeom = GetJGeometry(run_number);
213 if(!jgeom){
214 _DBG_std::cerr<<"DApplication.cc"<<":"<<214<<
" "
<<"ERROR: Unable get geometry for run "<<run_number<<"!"<<endl;
215 _DBG_std::cerr<<"DApplication.cc"<<":"<<215<<
" "
<<"Make sure you JANA_GEOMETRY_URL environment variable is set."<<endl;
216 _DBG_std::cerr<<"DApplication.cc"<<":"<<216<<
" "
<<"It should be set to something like:"<<endl;
217 _DBG_std::cerr<<"DApplication.cc"<<":"<<217<<
" "
<<endl;
218 _DBG_std::cerr<<"DApplication.cc"<<":"<<218<<
" "
<<" xmlfile://${HALLD_HOME}/src/programs/Simulation/hdds/main_HDDS.xml"<<endl;
219 _DBG_std::cerr<<"DApplication.cc"<<":"<<219<<
" "
<<endl;
220 _DBG_std::cerr<<"DApplication.cc"<<":"<<220<<
" "
<<"Exiting now."<<endl;
221 Quit();
222 exit(-1);
223 return NULL__null;
224 }
225
226
227 Lock();
228
229 for(unsigned int i=0; i<geometries.size(); i++){
230 if(geometries[i]->GetJGeometry() == jgeom){
231 DGeometry *dgeom = geometries[i];
232 Unlock();
233 return dgeom;
234 }
235 }
236
237 jout<<"Creating DGeometry:"<<endl;
238 jout<<" Run requested:"<<jgeom->GetRunRequested()<<" found:"<<jgeom->GetRunFound()<<endl;
239 jout<<" Run validity range: "<<jgeom->GetRunMin()<<"-"<<jgeom->GetRunMax()<<endl;
240 jout<<" URL=\""<<jgeom->GetURL()<<"\""<<" context=\""<<jgeom->GetContext()<<"\""<<endl;
241 jout<<" Type=\""<<jgeom->className()<<"\""<<endl;
242
243 // Couldn't find a DGeometry object that uses this JGeometry object.
244 // Create one and add it to the list.
245 DGeometry *dgeom = new DGeometry(jgeom, this, run_number);
246 geometries.push_back(dgeom);
247
248
249 Unlock();
250
251 return dgeom;
252}
253
254
255//---------------------------------
256// GetBfield
257//---------------------------------
258DMagneticFieldMap* DApplication::GetBfield(void)
259{
260 pthread_mutex_lock(&mutex);
261
262 // If field map already exists, return it immediately
263 if(bfield){
264 pthread_mutex_unlock(&mutex);
265 return bfield;
266 }
267
268 // Create magnetic field object for use by everyone
269 // Allow a trivial homogeneous map to be used if
270 // specified on the command line
271 string bfield_type = "FineMesh";
272 GetJParameterManager()->SetDefaultParameter("BFIELD_TYPE", bfield_type);
273 if(bfield_type=="CalibDB"){
274 bfield = new DMagneticFieldMapCalibDB(this);
275 jout<<"Created Magnetic field map of type DMagneticFieldMapCalibDB."<<endl;
276 }
277 else if(bfield_type=="FineMesh"){
278 bfield = new DMagneticFieldMapFineMesh(this);
279 jout<<"Created Magnetic field map of type DMagneticFieldMapFineMesh."<<endl;
280 }
281 else if(bfield_type=="Const"){
282 bfield = new DMagneticFieldMapConst(this);
283 jout<<"Created Magnetic field map of type DMagneticFieldMapConst."<<endl;
284 }else if(bfield_type=="Spoiled"){
285 bfield = new DMagneticFieldMapSpoiled(this);
286 jout<<"Created Magnetic field map of type DMagneticFieldMapSpoiled."<<endl;
287 }else if(bfield_type=="Parameterized"){
288 bfield = new DMagneticFieldMapParameterized(this);
289 jout<<"Created Magnetic field map of type DMagneticFieldMapParameterized."<<endl;
290 }else{
291 _DBG_std::cerr<<"DApplication.cc"<<":"<<291<<
" "
<<" Unknown DMagneticFieldMap subclass \"DMagneticFieldMap"<<bfield_type<<"\" !!"<<endl;
292 exit(-1);
293 }
294
295 pthread_mutex_unlock(&mutex);
296
297 return bfield;
298}
299
300//---------------------------------
301// GetLorentzDeflections
302//---------------------------------
303DLorentzDeflections* DApplication::GetLorentzDeflections(void)
304{
305 pthread_mutex_lock(&mutex);
306
307 // If field map already exists, return it immediately
308 if(lorentz_def){
309 pthread_mutex_unlock(&mutex);
310 return lorentz_def;
311 }
312
313 // Create Lorentz deflection object
314 lorentz_def= new DLorentzMapCalibDB(this);
315
316 pthread_mutex_unlock(&mutex);
317
318 return lorentz_def;
319}
320
321//---------------------------------
322// GetRootGeom
323//---------------------------------
324DRootGeom* DApplication::GetRootGeom()
325{
326 pthread_mutex_lock(&mutex);
327
328 // If field map already exists, return it immediately
329 if(RootGeom){
330 pthread_mutex_unlock(&mutex);
331 return RootGeom;
332 }
333
334 // Create map of material properties
335 //material = new DMaterialMapCalibDB(this);
336 RootGeom = new DRootGeom(this);
337
338 pthread_mutex_unlock(&mutex);
339
340 return RootGeom;
341}
342