MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / get_cpu_name

Function get_cpu_name

src/src/benchmarking.hpp:93–118  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

91}
92
93inline std::string get_cpu_name() {
94#ifdef _WIN32
95 int cpu_info[4] = {0, 0, 0, 0};
96 char brand[0x40] = {0};
97 __cpuid(cpu_info, 0x80000000);
98 unsigned int max_ex_id = static_cast<unsigned int>(cpu_info[0]);
99 if (max_ex_id >= 0x80000004) {
100 __cpuid(cpu_info, 0x80000002);
101 std::memcpy(brand, cpu_info, sizeof(cpu_info));
102 __cpuid(cpu_info, 0x80000003);
103 std::memcpy(brand + 16, cpu_info, sizeof(cpu_info));
104 __cpuid(cpu_info, 0x80000004);
105 std::memcpy(brand + 32, cpu_info, sizeof(cpu_info));
106 }
107 std::string name(brand);
108 while (!name.empty() && std::isspace(static_cast<unsigned char>(name.front()))) {
109 name.erase(name.begin());
110 }
111 while (!name.empty() && std::isspace(static_cast<unsigned char>(name.back()))) {
112 name.pop_back();
113 }
114 return name;
115#else
116 return {};
117#endif
118}
119
120inline void write_bench_csv(const BenchmarkResults_t& results, const std::string& model_tag, const std::string& output_dir = ".") {
121 std::string safe_tag = sanitize_model_tag_for_filename(model_tag);

Callers 1

write_bench_csvFunction · 0.85

Calls 3

eraseMethod · 0.80
emptyMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected