| 68 | } |
| 69 | |
| 70 | std::string CPUDevice::getName() |
| 71 | { |
| 72 | #if defined(__APPLE__) |
| 73 | char name[256] = {}; |
| 74 | size_t nameSize = sizeof(name)-1; |
| 75 | if (sysctlbyname("machdep.cpu.brand_string", &name, &nameSize, nullptr, 0) == 0 && strlen(name) > 0) |
| 76 | return name; |
| 77 | #elif defined(OIDN_ARCH_X64) |
| 78 | int regs[3][4]; |
| 79 | char name[sizeof(regs)+1] = {}; |
| 80 | |
| 81 | cpuid(regs[0], 0x80000000); |
| 82 | if (static_cast<unsigned int>(regs[0][0]) >= 0x80000004) |
| 83 | { |
| 84 | cpuid(regs[0], 0x80000002); |
| 85 | cpuid(regs[1], 0x80000003); |
| 86 | cpuid(regs[2], 0x80000004); |
| 87 | memcpy(name, regs, sizeof(regs)); |
| 88 | if (strlen(name) > 0) |
| 89 | return name; |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | return "CPU"; // fallback |
| 94 | } |
| 95 | |
| 96 | // Returns the native CPU architecture but this may not be what we are allowed to use (e.g. AMX) |
| 97 | CPUArch CPUDevice::getNativeArch() |