CMS 3D CMS Logo

edm::MallocOptionSetter Class Reference

#include <FWCore/Utilities/interface/MallocOpts.h>

List of all members.

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

typedef MallocOpts::opt_type edm::MallocOptionSetter::opt_type

Definition at line 67 of file MallocOpts.h.


Constructor & Destructor Documentation

edm::MallocOptionSetter::MallocOptionSetter (  ) 

Definition at line 140 of file MallocOpts.cc.

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

00140                                         :
00141     changed_(false)
00142   {
00143     if(retrieveFromEnv() || retrieveFromCpuType())
00144       {
00145         adjustMallocParams();
00146         if(hasErrors())
00147           {
00148             std::cerr << "ERROR: Reset of malloc options has fails:\n"
00149                       << error_message_ << "\n";
00150           }
00151       }
00152   }


Member Function Documentation

void edm::MallocOptionSetter::adjustMallocParams (  ) 

Definition at line 154 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().

00155   {
00156     if(changed_==false) return; // only adjust if they changed
00157     error_message_.clear();
00158     changed_ = false;
00159 
00160     if(mallopt(M_MMAP_MAX,values_.mmap_max_)<0)
00161       error_message_ += "Could not set M_MMAP_MAX\n"; 
00162     if(mallopt(M_TRIM_THRESHOLD,values_.trim_thr_)<0)
00163       error_message_ += "Could not set M_TRIM_THRESHOLD\n"; 
00164     if(mallopt(M_TOP_PAD,values_.top_pad_)<0)
00165       error_message_ += "ERROR: Could not set M_TOP_PAD\n";
00166     if(mallopt(M_MMAP_THRESHOLD,values_.mmap_thr_)<0)
00167       error_message_ += "ERROR: Could not set M_MMAP_THRESHOLD\n";
00168   }

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().

00074 { return error_message_; }

MallocOpts edm::MallocOptionSetter::get ( void   )  const [inline]

Definition at line 85 of file MallocOpts.h.

References values_.

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

00085 { 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().

00073 { return !error_message_.empty(); }

bool edm::MallocOptionSetter::retrieveFromCpuType (  ) 

Definition at line 114 of file MallocOpts.cc.

References edm::AMD_CPU, edm::amd_opts, changed_, edm::get_cpu_type(), edm::INTEL_CPU, edm::intel_opts, edm::UNKNOWN_CPU, and values_.

Referenced by MallocOptionSetter().

00115   {
00116     bool rc=true;
00117 
00118     switch(get_cpu_type())
00119       {
00120       case AMD_CPU:
00121         {
00122           values_ = amd_opts;
00123           changed_=true;
00124           break;
00125         }
00126       case INTEL_CPU:
00127         {
00128           values_ = intel_opts;
00129           changed_=true;
00130           break;
00131         }
00132       case UNKNOWN_CPU:
00133       default:
00134         rc=false;
00135       }
00136 
00137     return rc;
00138   }

bool edm::MallocOptionSetter::retrieveFromEnv (  ) 

Definition at line 170 of file MallocOpts.cc.

References TestMuL1L2Filter_cff::cerr, changed_, GenMuonPlsPt100GeV_cfg::cout, edm::MallocOpts::mmap_max_, edm::MallocOpts::mmap_thr_, edm::MallocOpts::top_pad_, edm::MallocOpts::trim_thr_, and values_.

Referenced by MallocOptionSetter().

00171   {
00172     const char* par = getenv("CMSRUN_MALLOC_RESET");
00173     if(par==0) return false; // leave quickly here
00174     std::string spar(par);
00175     bool rc = false;
00176       
00177     // CMSRUN_MALLOC_RESET = "mmap_max trim_thres top_pad mmap_thres"
00178       
00179     if(spar.size()>1)
00180       {
00181         std::istringstream ist(spar);
00182         ist >> values_.mmap_max_ >> values_.trim_thr_
00183             >> values_.top_pad_ >> values_.mmap_thr_;
00184 
00185         if(ist.bad())
00186           {
00187             std::cerr << "bad malloc options in CMSRUN_MALLOC_RESET: "
00188                       << spar << "\n"
00189                       << "format is: "
00190                       << "CMSRUN_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n";
00191           }
00192         else
00193           {
00194             std::cout << "MALLOC_OPTIONS> Reset options: "
00195                       << "CMSRUN_MALLOC_RESET=" << par << "\n";
00196           }
00197         rc=true;
00198         changed_=true;
00199       }
00200 
00201     return rc;
00202   }

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().

00077     { values_.mmap_max_=mmap_max; changed_=true; }

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().

00083     { values_.mmap_thr_=mmap_thr; changed_=true; }

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().

00081     { values_.top_pad_=top_pad; changed_=true; }

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().

00079     { values_.trim_thr_=trim_thr; changed_=true; }


Member Data Documentation

bool edm::MallocOptionSetter::changed_ [private]

Definition at line 88 of file MallocOpts.h.

Referenced by adjustMallocParams(), retrieveFromCpuType(), retrieveFromEnv(), set_mmap_max(), set_mmap_thr(), set_top_pad(), and set_trim_thr().

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]

Definition at line 89 of file MallocOpts.h.

Referenced by adjustMallocParams(), get(), retrieveFromCpuType(), retrieveFromEnv(), set_mmap_max(), set_mmap_thr(), set_top_pad(), and set_trim_thr().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:41:47 2009 for CMSSW by  doxygen 1.5.4