CMS 3D CMS Logo

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
edm::MallocOpts::opt_type
int opt_type
Definition: MallocOpts.h:33
edm::MallocOpts::trim_thr_
opt_type trim_thr_
Definition: MallocOpts.h:40
edm::MallocOptionSetter::retrieveFromCpuType
bool retrieveFromCpuType()
Definition: MallocOpts.cc:109
edm::MallocOptionSetter::changed_
bool changed_
Definition: MallocOpts.h:84
edm::getGlobalOptionSetter
MallocOptionSetter & getGlobalOptionSetter()
Definition: MallocOpts.cc:196
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::max
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:118
edm::MallocOptionSetter::opt_type
MallocOpts::opt_type opt_type
Definition: MallocOpts.h:55
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::MallocOptionSetter
Definition: MallocOpts.h:53
edm::MallocOptionSetter::set_mmap_thr
void set_mmap_thr(opt_type mmap_thr)
Definition: MallocOpts.h:76
edm::MallocOptionSetter::MallocOptionSetter
MallocOptionSetter()
Definition: MallocOpts.cc:131
edm::MallocOpts::mmap_thr_
opt_type mmap_thr_
Definition: MallocOpts.h:42
edm::MallocOpts
Definition: MallocOpts.h:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::MallocOptionSetter::get
MallocOpts get() const
Definition: MallocOpts.h:81
edm::MallocOptionSetter::error_message_
std::string error_message_
Definition: MallocOpts.h:87
edm::MallocOptionSetter::adjustMallocParams
void adjustMallocParams()
Definition: MallocOpts.cc:140
edm::MallocOptionSetter::set_top_pad
void set_top_pad(opt_type top_pad)
Definition: MallocOpts.h:72
edm::MallocOpts::MallocOpts
MallocOpts(opt_type max, opt_type trim, opt_type pad, opt_type mmap_thr)
Definition: MallocOpts.h:36
edm::MallocOpts::mmap_max_
opt_type mmap_max_
Definition: MallocOpts.h:39
edm::MallocOptionSetter::hasErrors
bool hasErrors() const
Definition: MallocOpts.h:61
edm::MallocOptionSetter::set_mmap_max
void set_mmap_max(opt_type mmap_max)
Definition: MallocOpts.h:64
edm::MallocOpts::MallocOpts
MallocOpts()
Definition: MallocOpts.h:35
edm::MallocOptionSetter::set_trim_thr
void set_trim_thr(opt_type trim_thr)
Definition: MallocOpts.h:68
edm::MallocOpts::top_pad_
opt_type top_pad_
Definition: MallocOpts.h:41
edm::MallocOpts::operator!=
bool operator!=(const MallocOpts &opts) const
Definition: MallocOpts.h:48
edm::MallocOptionSetter::values_
MallocOpts values_
Definition: MallocOpts.h:85
edm::MallocOptionSetter::error_message
std::string error_message() const
Definition: MallocOpts.h:62
edm::MallocOptionSetter::retrieveFromEnv
bool retrieveFromEnv()
Definition: MallocOpts.cc:166
trim
static void trim(std::string &s)
Definition: DTCCablingMapProducer.cc:67
edm::MallocOpts::operator==
bool operator==(const MallocOpts &opts) const
Definition: MallocOpts.h:44
geometryDiff.opts
opts
Definition: geometryDiff.py:11