CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
edm::MallocOptionSetter Class Reference

#include <MallocOpts.h>

Public Types

typedef MallocOpts::opt_type opt_type
 

Public Member Functions

void adjustMallocParams ()
 
std::string error_message () const
 
MallocOpts get () const
 
bool hasErrors () const
 
 MallocOptionSetter ()
 
bool retrieveFromCpuType ()
 
bool retrieveFromEnv ()
 
void set_mmap_max (opt_type mmap_max)
 
void set_mmap_thr (opt_type mmap_thr)
 
void set_top_pad (opt_type top_pad)
 
void set_trim_thr (opt_type trim_thr)
 

Private Attributes

bool changed_
 
std::string error_message_
 
MallocOpts values_
 

Detailed Description

Definition at line 64 of file MallocOpts.h.

Member Typedef Documentation

Definition at line 67 of file MallocOpts.h.

Constructor & Destructor Documentation

edm::MallocOptionSetter::MallocOptionSetter ( )

Definition at line 145 of file MallocOpts.cc.

References adjustMallocParams(), dtNoiseDBValidation_cfg::cerr, error_message_, hasErrors(), retrieveFromCpuType(), and retrieveFromEnv().

145  :
146  changed_(false)
147  {
149  {
151  if(hasErrors())
152  {
153  std::cerr << "ERROR: Reset of malloc options has fails:\n"
154  << error_message_ << "\n";
155  }
156  }
157  }
std::string error_message_
Definition: MallocOpts.h:91
bool hasErrors() const
Definition: MallocOpts.h:73

Member Function Documentation

void edm::MallocOptionSetter::adjustMallocParams ( )

Definition at line 159 of file MallocOpts.cc.

References changed_, error_message_, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.

Referenced by MallocOptionSetter(), and edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

160  {
161  if(changed_==false) return; // only adjust if they changed
162  error_message_.clear();
163  changed_ = false;
164 
165 #ifdef M_MMAP_MAX
166  if(mallopt(M_MMAP_MAX,values_.mmap_max_)<0)
167  error_message_ += "Could not set M_MMAP_MAX\n";
168 #endif
169 #ifdef M_TRIM_THRESHOLD
170  if(mallopt(M_TRIM_THRESHOLD,values_.trim_thr_)<0)
171  error_message_ += "Could not set M_TRIM_THRESHOLD\n";
172 #endif
173 #ifdef M_TOP_PAD
174  if(mallopt(M_TOP_PAD,values_.top_pad_)<0)
175  error_message_ += "ERROR: Could not set M_TOP_PAD\n";
176 #endif
177 #ifdef M_MMAP_THRESHOLD
178  if(mallopt(M_MMAP_THRESHOLD,values_.mmap_thr_)<0)
179  error_message_ += "ERROR: Could not set M_MMAP_THRESHOLD\n";
180 #endif
181  }
std::string error_message_
Definition: MallocOpts.h:91
opt_type mmap_max_
Definition: MallocOpts.h:45
opt_type trim_thr_
Definition: MallocOpts.h:46
opt_type mmap_thr_
Definition: MallocOpts.h:48
opt_type top_pad_
Definition: MallocOpts.h:47
std::string edm::MallocOptionSetter::error_message ( ) const
inline

Definition at line 74 of file MallocOpts.h.

References error_message_.

Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

74 { return error_message_; }
std::string error_message_
Definition: MallocOpts.h:91
MallocOpts edm::MallocOptionSetter::get ( void  ) const
inline
bool edm::MallocOptionSetter::hasErrors ( ) const
inline

Definition at line 73 of file MallocOpts.h.

References error_message_.

Referenced by MallocOptionSetter(), and edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

73 { return !error_message_.empty(); }
std::string error_message_
Definition: MallocOpts.h:91
bool edm::MallocOptionSetter::retrieveFromCpuType ( )

Definition at line 119 of file MallocOpts.cc.

References changed_, and values_.

Referenced by MallocOptionSetter().

120  {
121  bool rc=true;
122 
123  switch(get_cpu_type())
124  {
125  case AMD_CPU:
126  {
127  values_ = amd_opts;
128  changed_=true;
129  break;
130  }
131  case INTEL_CPU:
132  {
133  values_ = intel_opts;
134  changed_=true;
135  break;
136  }
137  case UNKNOWN_CPU:
138  default:
139  rc=false;
140  }
141 
142  return rc;
143  }
bool edm::MallocOptionSetter::retrieveFromEnv ( )

Definition at line 183 of file MallocOpts.cc.

References dtNoiseDBValidation_cfg::cerr, changed_, gather_cfg::cout, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, AlCaHLTBitMon_QueryRunRegistry::string, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.

Referenced by MallocOptionSetter().

184  {
185  const char* par = getenv("CMSRUN_MALLOC_RESET");
186  if(par==0) return false; // leave quickly here
187  std::string spar(par);
188  bool rc = false;
189 
190  // CMSRUN_MALLOC_RESET = "mmap_max trim_thres top_pad mmap_thres"
191 
192  if(spar.size()>1)
193  {
194  std::istringstream ist(spar);
197 
198  if(ist.bad())
199  {
200  std::cerr << "bad malloc options in CMSRUN_MALLOC_RESET: "
201  << spar << "\n"
202  << "format is: "
203  << "CMSRUN_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n";
204  }
205  else
206  {
207  std::cout << "MALLOC_OPTIONS> Reset options: "
208  << "CMSRUN_MALLOC_RESET=" << par << "\n";
209  }
210  rc=true;
211  changed_=true;
212  }
213 
214  return rc;
215  }
opt_type mmap_max_
Definition: MallocOpts.h:45
opt_type trim_thr_
Definition: MallocOpts.h:46
tuple cout
Definition: gather_cfg.py:121
opt_type mmap_thr_
Definition: MallocOpts.h:48
opt_type top_pad_
Definition: MallocOpts.h:47
void edm::MallocOptionSetter::set_mmap_max ( opt_type  mmap_max)
inline

Definition at line 76 of file MallocOpts.h.

References changed_, edm::MallocOpts::mmap_max_, and values_.

Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

77  { values_.mmap_max_=mmap_max; changed_=true; }
opt_type mmap_max_
Definition: MallocOpts.h:45
void edm::MallocOptionSetter::set_mmap_thr ( opt_type  mmap_thr)
inline

Definition at line 82 of file MallocOpts.h.

References changed_, edm::MallocOpts::mmap_thr_, and values_.

Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

83  { values_.mmap_thr_=mmap_thr; changed_=true; }
opt_type mmap_thr_
Definition: MallocOpts.h:48
void edm::MallocOptionSetter::set_top_pad ( opt_type  top_pad)
inline

Definition at line 80 of file MallocOpts.h.

References changed_, edm::MallocOpts::top_pad_, and values_.

Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

81  { values_.top_pad_=top_pad; changed_=true; }
opt_type top_pad_
Definition: MallocOpts.h:47
void edm::MallocOptionSetter::set_trim_thr ( opt_type  trim_thr)
inline

Definition at line 78 of file MallocOpts.h.

References changed_, edm::MallocOpts::trim_thr_, and values_.

Referenced by edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

79  { values_.trim_thr_=trim_thr; changed_=true; }
opt_type trim_thr_
Definition: MallocOpts.h:46

Member Data Documentation

bool edm::MallocOptionSetter::changed_
private
std::string edm::MallocOptionSetter::error_message_
private

Definition at line 91 of file MallocOpts.h.

Referenced by adjustMallocParams(), error_message(), hasErrors(), and MallocOptionSetter().

MallocOpts edm::MallocOptionSetter::values_
private