14 #if !defined(__APPLE__)
25 ost <<
"mmap_max=" <<
opts.mmap_max_ <<
" trim_threshold=" <<
opts.trim_thr_ <<
" top_padding=" <<
opts.top_pad_
26 <<
" mmap_threshold=" <<
opts.mmap_thr_;
31 typedef enum { UNKNOWN_CPU = 0, AMD_CPU = 1, INTEL_CPU = 2 } cpu_type;
33 cpu_type get_cpu_type() {
39 static volatile int ans[4];
40 #if defined(__i386__) || defined(__x86_64__)
41 static volatile int op = 0,
a;
45 #if defined(__x86_64__)
62 :
"=m"(ans[2]),
"=m"(ans[1]),
"=m"(ans[0]),
"=m"(
a)
65 #elif defined(__i386__)
82 :
"=m"(ans[2]),
"=m"(ans[1]),
"=m"(ans[0]),
"=m"(
a)
86 const char* unknown_str =
"Unknown";
88 strcpy((
char*)&ans[0], unknown_str);
91 const char* amd_str =
"AuthenticAMD";
92 int amd_sz = strlen(amd_str);
93 const char* intel_str =
"GenuineIntel";
94 int intel_sz = strlen(intel_str);
96 char*
str = (
char*)&ans[0];
99 return strncmp(
str, amd_str, amd_sz) == 0 ? AMD_CPU
100 : strncmp(
str, intel_str, intel_sz) == 0 ? INTEL_CPU
105 const MallocOpts intel_opts(262144, 524288, 5242880, 131072);
106 const MallocOpts amd_opts(0, 8388608, 131072, 10485760);
113 switch (get_cpu_type()) {
147 #ifndef __SANITIZE_ADDRESS__
152 #ifdef M_TRIM_THRESHOLD
160 #ifdef M_MMAP_THRESHOLD
168 const char* par = std::getenv(
"CMSRUN_MALLOC_RESET");
176 if (spar.size() > 1) {
177 std::istringstream ist(spar);
181 std::cerr <<
"bad malloc options in CMSRUN_MALLOC_RESET: " << spar <<
"\n"
183 <<
"CMSRUN_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n";
185 std::cout <<
"MALLOC_OPTIONS> Reset options: "
186 <<
"CMSRUN_MALLOC_RESET=" << par <<
"\n";