13 #if !defined(__APPLE__) 33 typedef enum { UNKNOWN_CPU = 0, AMD_CPU = 1, INTEL_CPU = 2 }
cpu_type;
43 static volatile int op = 0,
a;
44 static volatile int ans[4];
47 #if defined(__x86_64__) 49 __asm__ __volatile__(
"pushq %%rdx;\ 63 :
"=m"(ans[2]),
"=m"(ans[1]),
"=m"(ans[0]),
"=m"(
a)
66 #elif defined(__i386__) 68 __asm__ __volatile__(
"pushl %%edx;\ 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 ?
101 strncmp(str, intel_str, intel_sz) == 0 ? INTEL_CPU : UNKNOWN_CPU;
105 const MallocOpts intel_opts(262144, 524288, 5242880, 131072);
106 const MallocOpts amd_opts(0, 8388608, 131072, 10485760);
115 switch (get_cpu_type()) {
139 std::cerr <<
"ERROR: Reset of malloc options has fails:\n" 157 #ifdef M_TRIM_THRESHOLD 165 #ifdef M_MMAP_THRESHOLD 174 const char* par =
getenv(
"ART_MALLOC_RESET");
180 if (spar.size() > 1) {
181 std::istringstream ist(spar);
187 <<
"bad malloc options in ART_MALLOC_RESET: " << spar <<
"\n" 189 <<
"ART_MALLOC_RESET=\"mmap_max trim_thres top_pad mmap_thres\"\n";
191 std::cout <<
"MALLOC_OPTIONS> Reset options: " 192 <<
"ART_MALLOC_RESET=" << par <<
"\n";
bool retrieveFromCpuType()
std::string error_message_
std::ostream & operator<<(std::ostream &os, const GroupSelector &gs)
std::string getenv(std::string const &name)
void adjustMallocParams()