CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
MallocOpts.h
Go to the documentation of this file.
1 #ifndef MallocOpts_h
2 #define MallocOpts_h
3 
4 // -*- C++ -*-
5 //
6 // Package: Utilities
7 // Class : MallocOpts
8 //
9 // Original Author: Jim Kowalkowski
10 //
11 // ------------------ malloc option setter -----------------------
12 //
13 // There is a global instance of MallocOptionSetter. Upon construction,
14 // it gets the CPU type. If is it AMD or Intel, it sets the mallopt
15 // parameters to a set that works best for that environment. The best
16 // values have been chosen based on running a simple cmsRun job.
17 //
18 // The four values that get reset are:
19 // M_MMAP_MAX, M_TRIM_THRESHOLD, M_TOP_PAD, M_MMAP_THRESHOLD
20 //
21 // Current the best AMD and Intel values were calculated using:
22 // AMD Opteron(tm) Processor 248
23 // Intel Dual Core something or other
24 //
25 // These values will need to be checked when new CPUs are available or
26 // when we move to 64 bit executables.
27 
28 #include <string>
29 #include <ostream>
30 
31 namespace edm
32 {
33  struct MallocOpts
34  {
35  typedef int opt_type;
36 
39  {}
41  mmap_max_(max),trim_thr_(trim),top_pad_(pad),mmap_thr_(mmap_thr)
42  {}
43 
48 
49  bool operator==(const MallocOpts& opts) const
50  {
51  return
52  mmap_max_ == opts.mmap_max_ &&
53  trim_thr_ == opts.trim_thr_ &&
54  top_pad_ == opts.top_pad_ &&
55  mmap_thr_ == opts.mmap_thr_;
56  }
57  bool operator!=(const MallocOpts& opts) const
58  { return !operator==(opts); }
59  };
60 
61  std::ostream& operator<<(std::ostream& ost,const MallocOpts&);
62 
64  {
65  public:
68 
69  bool retrieveFromCpuType();
70  bool retrieveFromEnv();
71  void adjustMallocParams();
72  bool hasErrors() const { return !error_message_.empty(); }
74 
75  void set_mmap_max(opt_type mmap_max)
76  { values_.mmap_max_=mmap_max; changed_=true; }
77  void set_trim_thr(opt_type trim_thr)
78  { values_.trim_thr_=trim_thr; changed_=true; }
79  void set_top_pad(opt_type top_pad)
80  { values_.top_pad_=top_pad; changed_=true; }
81  void set_mmap_thr(opt_type mmap_thr)
82  { values_.mmap_thr_=mmap_thr; changed_=true; }
83 
84  MallocOpts get() const { return values_; }
85 
86  private:
87  bool changed_;
89 
91  };
92 
94 
95 }
96 
97 
98 
99 #endif
void set_trim_thr(opt_type trim_thr)
Definition: MallocOpts.h:77
std::string error_message_
Definition: MallocOpts.h:90
void set_mmap_max(opt_type mmap_max)
Definition: MallocOpts.h:75
bool hasErrors() const
Definition: MallocOpts.h:72
void set_mmap_thr(opt_type mmap_thr)
Definition: MallocOpts.h:81
opt_type mmap_max_
Definition: MallocOpts.h:44
bool operator==(const MallocOpts &opts) const
Definition: MallocOpts.h:49
MallocOpts::opt_type opt_type
Definition: MallocOpts.h:66
bool operator!=(const MallocOpts &opts) const
Definition: MallocOpts.h:57
opt_type trim_thr_
Definition: MallocOpts.h:45
MallocOpts(opt_type max, opt_type trim, opt_type pad, opt_type mmap_thr)
Definition: MallocOpts.h:40
std::string error_message() const
Definition: MallocOpts.h:73
void set_top_pad(opt_type top_pad)
Definition: MallocOpts.h:79
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
opt_type mmap_thr_
Definition: MallocOpts.h:47
MallocOptionSetter & getGlobalOptionSetter()
Definition: MallocOpts.cc:219
opt_type top_pad_
Definition: MallocOpts.h:46
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142