Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
sysinfo.cpp
Go to the documentation of this file.
1// -------------------------------------------------------//
2//
3// SHAMROCK code for hydrodynamics
4// Copyright (c) 2021-2026 Timothée David--Cléris <tim.shamrock@proton.me>
5// SPDX-License-Identifier: CeCILL Free Software License Agreement v2.1
6// Shamrock is licensed under the CeCILL 2.1 License, see LICENSE for more information
7//
8// -------------------------------------------------------//
9
16#include "shambase/string.hpp"
17#include "sysinfo.hpp"
18#include <cpuid.h>
19
20// written from code present on https://en.wikipedia.org/wiki/CPUID
21inline std::string get_cpu_name() {
22 uint32_t brand[12];
23
24 if (!__get_cpuid_max(0x80000004, NULL)) {
25 fprintf(stderr, "Feature not implemented.");
26 }
27
28 __get_cpuid(0x80000002, brand + 0x0, brand + 0x1, brand + 0x2, brand + 0x3);
29 __get_cpuid(0x80000003, brand + 0x4, brand + 0x5, brand + 0x6, brand + 0x7);
30 __get_cpuid(0x80000004, brand + 0x8, brand + 0x9, brand + 0xa, brand + 0xb);
31 return shambase::format_printf("Brand: %s\n", brand);
32}
void throw_with_loc(std::string message, SourceLocation loc=SourceLocation{})
Throw an exception and append the source location to it.