vcomp: Implement omp_get_num_procs().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50041
Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 616e2284e0)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
Gijs Vermeulen 2021-06-04 20:10:27 +02:00 committed by Michael Stefaniuc
parent 4fddab4813
commit 718699df40
2 changed files with 19 additions and 2 deletions

View File

@ -41,6 +41,7 @@ static DWORD vcomp_context_tls = TLS_OUT_OF_INDEXES;
static HMODULE vcomp_module;
static int vcomp_max_threads;
static int vcomp_num_threads;
static int vcomp_num_procs;
static BOOL vcomp_nested_fork = FALSE;
static RTL_CRITICAL_SECTION vcomp_section;
@ -986,8 +987,8 @@ int CDECL omp_get_nested(void)
int CDECL omp_get_num_procs(void)
{
TRACE("stub\n");
return 1;
TRACE("\n");
return vcomp_num_procs;
}
int CDECL omp_get_num_threads(void)
@ -1680,6 +1681,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved)
vcomp_module = instance;
vcomp_max_threads = sysinfo.dwNumberOfProcessors;
vcomp_num_threads = sysinfo.dwNumberOfProcessors;
vcomp_num_procs = sysinfo.dwNumberOfProcessors;
break;
}

View File

@ -117,6 +117,7 @@ static void (CDECL *pomp_destroy_lock)(omp_lock_t *lock);
static void (CDECL *pomp_destroy_nest_lock)(omp_nest_lock_t *lock);
static int (CDECL *pomp_get_max_threads)(void);
static int (CDECL *pomp_get_nested)(void);
static int (CDECL *pomp_get_num_procs)(void);
static int (CDECL *pomp_get_num_threads)(void);
static int (CDECL *pomp_get_thread_num)(void);
static int (CDECL *pomp_in_parallel)(void);
@ -352,6 +353,7 @@ static BOOL init_vcomp(void)
VCOMP_GET_PROC(omp_destroy_nest_lock);
VCOMP_GET_PROC(omp_get_max_threads);
VCOMP_GET_PROC(omp_get_nested);
VCOMP_GET_PROC(omp_get_num_procs);
VCOMP_GET_PROC(omp_get_num_threads);
VCOMP_GET_PROC(omp_get_thread_num);
VCOMP_GET_PROC(omp_in_parallel);
@ -2209,11 +2211,24 @@ static void test_reduction_float_double(void)
}
}
static void test_omp_get_num_procs(void)
{
SYSTEM_INFO sysinfo;
int num_procs;
num_procs = pomp_get_num_procs();
ok(num_procs > 0, "expected non-zero num_procs\n");
GetSystemInfo(&sysinfo);
ok(sysinfo.dwNumberOfProcessors > 0, "expected non-zero dwNumberOfProcessors\n");
ok(num_procs == sysinfo.dwNumberOfProcessors, "got dwNumberOfProcessors %d num_procs %d\n", sysinfo.dwNumberOfProcessors, num_procs);
}
START_TEST(vcomp)
{
if (!init_vcomp())
return;
test_omp_get_num_procs();
test_omp_get_num_threads(FALSE);
test_omp_get_num_threads(TRUE);
test_vcomp_fork();