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 143 of file MallocOpts.cc.

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

143  :
144  changed_(false)
145  {
147  {
149  if(hasErrors())
150  {
151  std::cerr << "ERROR: Reset of malloc options has fails:\n"
152  << error_message_ << "\n";
153  }
154  }
155  }
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 157 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().

158  {
159  if(changed_==false) return; // only adjust if they changed
160  error_message_.clear();
161  changed_ = false;
162 
163 #ifdef M_MMAP_MAX
164  if(mallopt(M_MMAP_MAX,values_.mmap_max_)<0)
165  error_message_ += "Could not set M_MMAP_MAX\n";
166 #endif
167 #ifdef M_TRIM_THRESHOLD
168  if(mallopt(M_TRIM_THRESHOLD,values_.trim_thr_)<0)
169  error_message_ += "Could not set M_TRIM_THRESHOLD\n";
170 #endif
171 #ifdef M_TOP_PAD
172  if(mallopt(M_TOP_PAD,values_.top_pad_)<0)
173  error_message_ += "ERROR: Could not set M_TOP_PAD\n";
174 #endif
175 #ifdef M_MMAP_THRESHOLD
176  if(mallopt(M_MMAP_THRESHOLD,values_.mmap_thr_)<0)
177  error_message_ += "ERROR: Could not set M_MMAP_THRESHOLD\n";
178 #endif
179  }
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

Definition at line 85 of file MallocOpts.h.

References values_.

Referenced by Options.Options::__getitem__(), and edm::service::SimpleMemoryCheck::SimpleMemoryCheck().

85 { return values_; }
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 117 of file MallocOpts.cc.

References changed_, and values_.

Referenced by MallocOptionSetter().

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

Definition at line 181 of file MallocOpts.cc.

References benchmark_cfg::cerr, changed_, gather_cfg::cout, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, Gflash::par, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.

Referenced by MallocOptionSetter().

182  {
183  const char* par = getenv("CMSRUN_MALLOC_RESET");
184  if(par==0) return false; // leave quickly here
185  std::string spar(par);
186  bool rc = false;
187 
188  // CMSRUN_MALLOC_RESET = "mmap_max trim_thres top_pad mmap_thres"
189 
190  if(spar.size()>1)
191  {
192  std::istringstream ist(spar);
195 
196  if(ist.bad())
197  {
198  std::cerr << "bad malloc options in CMSRUN_MALLOC_RESET: "
199  << spar << "\n"
200  << "format is: "
201  << "CMSRUN_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n";
202  }
203  else
204  {
205  std::cout << "MALLOC_OPTIONS> Reset options: "
206  << "CMSRUN_MALLOC_RESET=" << par << "\n";
207  }
208  rc=true;
209  changed_=true;
210  }
211 
212  return rc;
213  }
opt_type mmap_max_
Definition: MallocOpts.h:45
opt_type trim_thr_
Definition: MallocOpts.h:46
tuple cout
Definition: gather_cfg.py:41
opt_type mmap_thr_
Definition: MallocOpts.h:48
opt_type top_pad_
Definition: MallocOpts.h:47
const double par[8 *NPar][4]
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