test
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 63 of file MallocOpts.h.

Member Typedef Documentation

Definition at line 66 of file MallocOpts.h.

Constructor & Destructor Documentation

edm::MallocOptionSetter::MallocOptionSetter ( )

Definition at line 145 of file MallocOpts.cc.

References adjustMallocParams(), ecal_dqm_sourceclient-live_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:90
bool hasErrors() const
Definition: MallocOpts.h:72

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 #ifndef __SANITIZE_ADDRESS__
166 #ifdef M_MMAP_MAX
167  if(mallopt(M_MMAP_MAX,values_.mmap_max_)<0)
168  error_message_ += "Could not set M_MMAP_MAX\n";
169 #endif
170 #ifdef M_TRIM_THRESHOLD
171  if(mallopt(M_TRIM_THRESHOLD,values_.trim_thr_)<0)
172  error_message_ += "Could not set M_TRIM_THRESHOLD\n";
173 #endif
174 #ifdef M_TOP_PAD
175  if(mallopt(M_TOP_PAD,values_.top_pad_)<0)
176  error_message_ += "ERROR: Could not set M_TOP_PAD\n";
177 #endif
178 #ifdef M_MMAP_THRESHOLD
179  if(mallopt(M_MMAP_THRESHOLD,values_.mmap_thr_)<0)
180  error_message_ += "ERROR: Could not set M_MMAP_THRESHOLD\n";
181 #endif
182 #endif
183  }
std::string error_message_
Definition: MallocOpts.h:90
opt_type mmap_max_
Definition: MallocOpts.h:44
opt_type trim_thr_
Definition: MallocOpts.h:45
opt_type mmap_thr_
Definition: MallocOpts.h:47
opt_type top_pad_
Definition: MallocOpts.h:46
std::string edm::MallocOptionSetter::error_message ( ) const
inline

Definition at line 73 of file MallocOpts.h.

References error_message_.

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

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

Definition at line 72 of file MallocOpts.h.

References error_message_.

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

72 { return !error_message_.empty(); }
std::string error_message_
Definition: MallocOpts.h:90
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 185 of file MallocOpts.cc.

References ecal_dqm_sourceclient-live_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().

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

Definition at line 75 of file MallocOpts.h.

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

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

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

Definition at line 81 of file MallocOpts.h.

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

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

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

Definition at line 79 of file MallocOpts.h.

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

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

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

Definition at line 77 of file MallocOpts.h.

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

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

78  { values_.trim_thr_=trim_thr; changed_=true; }
opt_type trim_thr_
Definition: MallocOpts.h:45

Member Data Documentation

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

Definition at line 90 of file MallocOpts.h.

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

MallocOpts edm::MallocOptionSetter::values_
private