From 6e6fd116a803ce14bebd23bd6dc031f60821e4fa Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 29 Oct 2019 13:33:31 -0700 Subject: [PATCH 1/2] client (Win): find and show # of processor groups at startup; if > 1 group, show group for each created process. The goal is to get information on hosts with >64 processors, in preparation for possible intelligent allocation to processor groups. --- client/app_start.cpp | 8 +++++++ client/hostinfo_win.cpp | 53 +++++++++++++++++++++++++++++++++++++++-- lib/hostinfo.h | 8 +++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/client/app_start.cpp b/client/app_start.cpp index a7c48e9815..9a079bbd15 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -843,6 +843,14 @@ int ACTIVE_TASK::start(bool test) { pid = process_info.dwProcessId; process_handle = process_info.hProcess; CloseHandle(process_info.hThread); // thread handle is not used + + // if host has multiple processor groups (i.e. > 64 processors) + // see which one was used for this job, and show it + // + if (log_flags.task_debug && gstate.host_info.n_processor_groups > 0) { + int i = get_processor_group(process_handle); + msg_printf(wup->project, MSG_INFO, "[task_debug] task is running in processor group %d", i); + } #elif defined(__EMX__) char* argv[100]; diff --git a/client/hostinfo_win.cpp b/client/hostinfo_win.cpp index d5797ca801..7cf9d2ca2e 100644 --- a/client/hostinfo_win.cpp +++ b/client/hostinfo_win.cpp @@ -1418,6 +1418,56 @@ int HOST_INFO::get_virtualbox_version() { return 0; } +// get info about processor groups +// +static void show_proc_info(SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX &pi) { + for (int i=0; i 0) { + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX pi = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX)p; + show_proc_info(*pi); + p += pi->Size; + size -= pi->Size; + n_processor_groups++; + } +} + +typedef BOOL (WINAPI *GPGA)(HANDLE, PUSHORT, PUSHORT); +int get_processor_group(HANDLE process_handle) { + USHORT groups[1], count; + static GPGA gpga = 0; + if (!gpga) { + gpga = (GPGA) GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "GetProcessGroupAffinity"); + } + if (!gpga) return 0; + count = 1; + BOOL ret = gpga(process_handle, &count, groups); + if (ret && count>0) { + return groups[0]; + } + return -1; +} // Gets host information; called on startup and before each sched RPC // @@ -1459,6 +1509,7 @@ int HOST_INFO::get_host_info(bool init) { if (!strlen(host_cpid)) { generate_host_cpid(); } + win_get_processor_info(); return 0; } @@ -1520,5 +1571,3 @@ bool HOST_INFO::users_idle(bool /*check_all_logins*/, double idle_time_to_run) { double seconds_time_to_run = 60 * idle_time_to_run; return seconds_idle > seconds_time_to_run; } - - diff --git a/lib/hostinfo.h b/lib/hostinfo.h index ec9e6c61ab..419ae02d69 100644 --- a/lib/hostinfo.h +++ b/lib/hostinfo.h @@ -95,6 +95,10 @@ public: int num_opencl_cpu_platforms; OPENCL_CPU_PROP opencl_cpu_prop[MAX_OPENCL_CPU_PLATFORMS]; +#ifdef _WIN32 + int n_processor_groups; +#endif + HOST_INFO(); int parse(XML_PARSER&, bool static_items_only = false); int write(MIOFILE&, bool include_net_info, bool include_coprocs); @@ -126,10 +130,14 @@ public: char* os_name, const int os_name_size, char* os_version, const int os_version_size); static bool parse_linux_os_info(const std::vector& lines, const LINUX_OS_INFO_PARSER parser, char* os_name, const int os_name_size, char* os_version, const int os_version_size); +#ifdef _WIN32 + void win_get_processor_info(); +#endif }; #ifdef _WIN64 int get_wsl_information(bool& wsl_available, WSLS& wsls); +int get_processor_group(HANDLE); #endif #ifdef __APPLE__ From b65ccaa61cf743153fbd04b56ff85acd394d16c4 Mon Sep 17 00:00:00 2001 From: Vitalii Koshura Date: Thu, 6 Feb 2020 17:58:09 +0100 Subject: [PATCH 2/2] [client] Fix Windows build Signed-off-by: Vitalii Koshura --- client/app_start.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/app_start.cpp b/client/app_start.cpp index 962e752d13..9b61b69be7 100644 --- a/client/app_start.cpp +++ b/client/app_start.cpp @@ -844,6 +844,7 @@ int ACTIVE_TASK::start(bool test) { process_handle = process_info.hProcess; CloseHandle(process_info.hThread); // thread handle is not used +#ifdef _WIN64 // if host has multiple processor groups (i.e. > 64 processors) // see which one was used for this job, and show it // @@ -851,6 +852,7 @@ int ACTIVE_TASK::start(bool test) { int i = get_processor_group(process_handle); msg_printf(wup->project, MSG_INFO, "[task_debug] task is running in processor group %d", i); } +#endif #elif defined(__EMX__) char* argv[100];