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 // $Id: MallocOpts.h,v 1.1 2007/12/20 19:36:47 jbk Exp $
11 //
12 // ------------------ malloc option setter -----------------------
13 //
14 // There is a global instance of MallocOptionSetter. Upon construction,
15 // it gets the CPU type. If is it AMD or Intel, it sets the mallopt
16 // parameters to a set that works best for that environment. The best
17 // values have been chosen based on running a simple cmsRun job.
18 //
19 // The four values that get reset are:
20 // M_MMAP_MAX, M_TRIM_THRESHOLD, M_TOP_PAD, M_MMAP_THRESHOLD
21 //
22 // Current the best AMD and Intel values were calculated using:
23 // AMD Opteron(tm) Processor 248
24 // Intel Dual Core something or other
25 //
26 // These values will need to be checked when new CPUs are available or
27 // when we move to 64 bit executables.
28 
29 #include <string>
30 #include <ostream>
31 
32 namespace edm
33 {
34  struct MallocOpts
35  {
36  typedef int opt_type;
37 
40  {}
42  mmap_max_(max),trim_thr_(trim),top_pad_(pad),mmap_thr_(mmap_thr)
43  {}
44 
49 
50  bool operator==(const MallocOpts& opts) const
51  {
52  return
53  mmap_max_ == opts.mmap_max_ &&
54  trim_thr_ == opts.trim_thr_ &&
55  top_pad_ == opts.top_pad_ &&
56  mmap_thr_ == opts.mmap_thr_;
57  }
58  bool operator!=(const MallocOpts& opts) const
59  { return !operator==(opts); }
60  };
61 
62  std::ostream& operator<<(std::ostream& ost,const MallocOpts&);
63 
65  {
66  public:
69 
70  bool retrieveFromCpuType();
71  bool retrieveFromEnv();
72  void adjustMallocParams();
73  bool hasErrors() const { return !error_message_.empty(); }
74  std::string error_message() const { return error_message_; }
75 
76  void set_mmap_max(opt_type mmap_max)
77  { values_.mmap_max_=mmap_max; changed_=true; }
78  void set_trim_thr(opt_type trim_thr)
79  { values_.trim_thr_=trim_thr; changed_=true; }
80  void set_top_pad(opt_type top_pad)
81  { values_.top_pad_=top_pad; changed_=true; }
82  void set_mmap_thr(opt_type mmap_thr)
83  { values_.mmap_thr_=mmap_thr; changed_=true; }
84 
85  MallocOpts get() const { return values_; }
86 
87  private:
88  bool changed_;
90 
91  std::string error_message_;
92  };
93 
95 
96 }
97 
98 
99 
100 #endif
void set_trim_thr(opt_type trim_thr)
Definition: MallocOpts.h:78
std::string error_message_
Definition: MallocOpts.h:91
void set_mmap_max(opt_type mmap_max)
Definition: MallocOpts.h:76
bool hasErrors() const
Definition: MallocOpts.h:73
void set_mmap_thr(opt_type mmap_thr)
Definition: MallocOpts.h:82
opt_type mmap_max_
Definition: MallocOpts.h:45
bool operator==(const MallocOpts &opts) const
Definition: MallocOpts.h:50
MallocOpts::opt_type opt_type
Definition: MallocOpts.h:67
bool operator!=(const MallocOpts &opts) const
Definition: MallocOpts.h:58
opt_type trim_thr_
Definition: MallocOpts.h:46
MallocOpts(opt_type max, opt_type trim, opt_type pad, opt_type mmap_thr)
Definition: MallocOpts.h:41
std::string error_message() const
Definition: MallocOpts.h:74
void set_top_pad(opt_type top_pad)
Definition: MallocOpts.h:80
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
opt_type mmap_thr_
Definition: MallocOpts.h:48
MallocOptionSetter & getGlobalOptionSetter()
Definition: MallocOpts.cc:217
opt_type top_pad_
Definition: MallocOpts.h:47
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:137