Commit 7eb5901f authored by Simon Spannagel's avatar Simon Spannagel
Browse files

allpix exec: add CPU id info

parent 95e86259
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@
 */

#include <atomic>
#include <cpuid.h>
#include <csignal>
#include <cstdlib>
#include <fstream>
@@ -124,6 +125,25 @@ int main(int argc, const char* argv[]) {
#ifdef ALLPIX_GEANT4_AVAILABLE
            std::cout << "                     Geant4 " << G4VERSION_NUMBER << std::endl;
#endif

            char cpu_string[0x40];
            unsigned int cpu_info[4] = {0, 0, 0, 0};
            __cpuid(0x80000000, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
            unsigned int n_ex_ids = cpu_info[0];
            memset(cpu_string, 0, sizeof(cpu_string));
            for(unsigned int j = 0x80000000; j <= n_ex_ids; ++j) {
                __cpuid(j, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
                if(j == 0x80000002) {
                    memcpy(cpu_string, cpu_info, sizeof(cpu_info));
                } else if(j == 0x80000003) {
                    memcpy(cpu_string + 16, cpu_info, sizeof(cpu_info));
                } else if(j == 0x80000004) {
                    memcpy(cpu_string + 32, cpu_info, sizeof(cpu_info));
                }
            }
            std::cout << "               running on " << std::thread::hardware_concurrency() << "x " << cpu_string
                      << std::endl;

            std::cout << std::endl;
            std::cout << "Copyright (c) 2016-2022 CERN and the Allpix Squared authors." << std::endl << std::endl;
            std::cout << "This software is distributed under the terms of the MIT License." << std::endl;