CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  struct MallocOpts {
33  typedef int opt_type;
34 
37  : mmap_max_(max), trim_thr_(trim), top_pad_(pad), mmap_thr_(mmap_thr) {}
38 
43 
44  bool operator==(const MallocOpts& opts) const {
45  return mmap_max_ == opts.mmap_max_ && trim_thr_ == opts.trim_thr_ && top_pad_ == opts.top_pad_ &&
46  mmap_thr_ == opts.mmap_thr_;
47  }
48  bool operator!=(const MallocOpts& opts) const { return !operator==(opts); }
49  };
50 
51  std::ostream& operator<<(std::ostream& ost, const MallocOpts&);
52 
54  public:
57 
58  bool retrieveFromCpuType();
59  bool retrieveFromEnv();
60  void adjustMallocParams();
61  bool hasErrors() const { return !error_message_.empty(); }
63 
64  void set_mmap_max(opt_type mmap_max) {
65  values_.mmap_max_ = mmap_max;
66  changed_ = true;
67  }
68  void set_trim_thr(opt_type trim_thr) {
69  values_.trim_thr_ = trim_thr;
70  changed_ = true;
71  }
72  void set_top_pad(opt_type top_pad) {
73  values_.top_pad_ = top_pad;
74  changed_ = true;
75  }
76  void set_mmap_thr(opt_type mmap_thr) {
77  values_.mmap_thr_ = mmap_thr;
78  changed_ = true;
79  }
80 
81  MallocOpts get() const { return values_; }
82 
83  private:
84  bool changed_;
86 
88  };
89 
91 
92 } // namespace edm
93 
94 #endif
void set_trim_thr(opt_type trim_thr)
Definition: MallocOpts.h:68
std::string error_message_
Definition: MallocOpts.h:87
void set_mmap_max(opt_type mmap_max)
Definition: MallocOpts.h:64
bool hasErrors() const
Definition: MallocOpts.h:61
void set_mmap_thr(opt_type mmap_thr)
Definition: MallocOpts.h:76
opt_type mmap_max_
Definition: MallocOpts.h:39
static void trim(std::string &s)
bool operator==(const MallocOpts &opts) const
Definition: MallocOpts.h:44
MallocOpts::opt_type opt_type
Definition: MallocOpts.h:55
bool operator!=(const MallocOpts &opts) const
Definition: MallocOpts.h:48
opt_type trim_thr_
Definition: MallocOpts.h:40
MallocOpts(opt_type max, opt_type trim, opt_type pad, opt_type mmap_thr)
Definition: MallocOpts.h:36
std::string error_message() const
Definition: MallocOpts.h:62
void set_top_pad(opt_type top_pad)
Definition: MallocOpts.h:72
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
opt_type mmap_thr_
Definition: MallocOpts.h:42
MallocOptionSetter & getGlobalOptionSetter()
Definition: MallocOpts.cc:197
opt_type top_pad_
Definition: MallocOpts.h:41
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118