From f7b671178c710ad12fc9aa1661d51138b01be452 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 1 Mar 2023 12:48:37 +1100 Subject: [PATCH] Added vcomp_for_dynamic_init_i8 patchset --- ...Implement-_vcomp_for_dynamic_init_i8.patch | 199 ++++++++++++++++++ patches/vcomp_for_dynamic_init_i8/definition | 1 + 2 files changed, 200 insertions(+) create mode 100644 patches/vcomp_for_dynamic_init_i8/0001-vcomp-Implement-_vcomp_for_dynamic_init_i8.patch create mode 100644 patches/vcomp_for_dynamic_init_i8/definition diff --git a/patches/vcomp_for_dynamic_init_i8/0001-vcomp-Implement-_vcomp_for_dynamic_init_i8.patch b/patches/vcomp_for_dynamic_init_i8/0001-vcomp-Implement-_vcomp_for_dynamic_init_i8.patch new file mode 100644 index 00000000..783561e1 --- /dev/null +++ b/patches/vcomp_for_dynamic_init_i8/0001-vcomp-Implement-_vcomp_for_dynamic_init_i8.patch @@ -0,0 +1,199 @@ +From 84aac220084db0058e68e5800992842179fef4f6 Mon Sep 17 00:00:00 2001 +From: Ben Shefte +Date: Wed, 1 Mar 2023 07:37:52 +1100 +Subject: [PATCH] vcomp: Implement _vcomp_for_dynamic_init_i8 + +Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52012 +--- + dlls/vcomp/main.c | 135 ++++++++++++++++++++++++++++++++++++++++++ + dlls/vcomp/vcomp.spec | 6 +- + 2 files changed, 138 insertions(+), 3 deletions(-) + +diff --git a/dlls/vcomp/main.c b/dlls/vcomp/main.c +index 374adf3991a..faa863d3ea4 100644 +--- a/dlls/vcomp/main.c ++++ b/dlls/vcomp/main.c +@@ -1031,6 +1031,26 @@ double CDECL omp_get_wtime(void) + return GetTickCount() / 1000.0; + } + ++/***************************************************** ++* omp_get_wtick - Taken from: ++* https://gist.github.com/Randl/45bcca59720f661fa033a67d5f44bff0 ++*/ ++double CDECL omp_get_wtick (void) ++{ ++ /*return GetTickCount();*/ ++ FILETIME createTime; ++ FILETIME exitTime; ++ FILETIME kernelTime; ++ FILETIME userTime; ++ ULARGE_INTEGER li; ++ ++ GetProcessTimes(GetCurrentProcess(), &createTime, &exitTime, &kernelTime, &userTime); ++ li.LowPart = userTime.dwLowDateTime; ++ li.HighPart = userTime.dwHighDateTime; ++ ++ return (double)li.QuadPart / 10000000.0; ++} ++ + void CDECL omp_set_dynamic(int val) + { + TRACE("(%d): stub\n", val); +@@ -1483,6 +1503,77 @@ void CDECL _vcomp_for_dynamic_init(unsigned int flags, unsigned int first, unsig + } + } + ++void CDECL _vcomp_for_dynamic_init_i8(ULONG64 flags, ULONG64 first, ULONG64 last, ++ ULONG64 step, ULONG64 chunksize) ++{ ++ ULONG64 iterations, per_thread, remaining; ++ struct vcomp_thread_data *thread_data = vcomp_init_thread_data(); ++ struct vcomp_team_data *team_data = thread_data->team; ++ struct vcomp_task_data *task_data = thread_data->task; ++ LONG64 num_threads = team_data ? team_data->num_threads : 1; ++ LONG64 thread_num = thread_data->thread_num; ++ unsigned int type = flags & ~VCOMP_DYNAMIC_FLAGS_INCREMENT; ++ ++ TRACE("(%llu, %llu, %llu, %lld, %llu)\n", flags, first, last, step, chunksize); ++ ++ if (step <= 0) ++ { ++ thread_data->dynamic_type = 0; ++ return; ++ } ++ ++ if (flags & VCOMP_DYNAMIC_FLAGS_INCREMENT) ++ iterations = 1 + (last - first) / step; ++ else ++ { ++ iterations = 1 + (first - last) / step; ++ step *= -1; ++ } ++ ++ if (type == VCOMP_DYNAMIC_FLAGS_STATIC) ++ { ++ per_thread = iterations / num_threads; ++ remaining = iterations - per_thread * num_threads; ++ ++ if (thread_num < remaining) ++ per_thread++; ++ else if (per_thread) ++ first += remaining * step; ++ else ++ { ++ thread_data->dynamic_type = 0; ++ return; ++ } ++ ++ thread_data->dynamic_type = VCOMP_DYNAMIC_FLAGS_STATIC; ++ thread_data->dynamic_begin = first + per_thread * thread_num * step; ++ thread_data->dynamic_end = thread_data->dynamic_begin + (per_thread - 1) * step; ++ } ++ else ++ { ++ if (type != VCOMP_DYNAMIC_FLAGS_CHUNKED && ++ type != VCOMP_DYNAMIC_FLAGS_GUIDED) ++ { ++ FIXME("unsupported flags %llu\n", flags); ++ type = VCOMP_DYNAMIC_FLAGS_GUIDED; ++ } ++ ++ EnterCriticalSection(&vcomp_section); ++ thread_data->dynamic++; ++ thread_data->dynamic_type = type; ++ if ((LONG64)(thread_data->dynamic - task_data->dynamic) > 0) ++ { ++ task_data->dynamic = thread_data->dynamic; ++ task_data->dynamic_first = first; ++ task_data->dynamic_last = last; ++ task_data->dynamic_iterations = iterations; ++ task_data->dynamic_step = step; ++ task_data->dynamic_chunksize = chunksize; ++ } ++ LeaveCriticalSection(&vcomp_section); ++ } ++} ++ + int CDECL _vcomp_for_dynamic_next(unsigned int *begin, unsigned int *end) + { + struct vcomp_thread_data *thread_data = vcomp_init_thread_data(); +@@ -1527,6 +1618,50 @@ int CDECL _vcomp_for_dynamic_next(unsigned int *begin, unsigned int *end) + return 0; + } + ++LONG64 CDECL _vcomp_for_dynamic_next_i8(LONG64 *begin, LONG64 *end) ++{ ++ struct vcomp_thread_data *thread_data = vcomp_init_thread_data(); ++ struct vcomp_task_data *task_data = thread_data->task; ++ struct vcomp_team_data *team_data = thread_data->team; ++ LONG64 num_threads = team_data ? team_data->num_threads : 1; ++ ++ TRACE("(%p, %p)\n", begin, end); ++ ++ if (thread_data->dynamic_type == VCOMP_DYNAMIC_FLAGS_STATIC) ++ { ++ *begin = thread_data->dynamic_begin; ++ *end = thread_data->dynamic_end; ++ thread_data->dynamic_type = 0; ++ return 1; ++ } ++ else if (thread_data->dynamic_type == VCOMP_DYNAMIC_FLAGS_CHUNKED || ++ thread_data->dynamic_type == VCOMP_DYNAMIC_FLAGS_GUIDED) ++ { ++ unsigned int iterations = 0; ++ EnterCriticalSection(&vcomp_section); ++ if (thread_data->dynamic == task_data->dynamic && ++ task_data->dynamic_iterations != 0) ++ { ++ iterations = min(task_data->dynamic_iterations, task_data->dynamic_chunksize); ++ if (thread_data->dynamic_type == VCOMP_DYNAMIC_FLAGS_GUIDED && ++ task_data->dynamic_iterations > num_threads * task_data->dynamic_chunksize) ++ { ++ iterations = (task_data->dynamic_iterations + num_threads - 1) / num_threads; ++ } ++ *begin = task_data->dynamic_first; ++ *end = task_data->dynamic_first + (iterations - 1) * task_data->dynamic_step; ++ task_data->dynamic_iterations -= iterations; ++ task_data->dynamic_first += iterations * task_data->dynamic_step; ++ if (!task_data->dynamic_iterations) ++ *end = task_data->dynamic_last; ++ } ++ LeaveCriticalSection(&vcomp_section); ++ return iterations != 0; ++ } ++ ++ return 0; ++} ++ + int CDECL omp_in_parallel(void) + { + TRACE("()\n"); +diff --git a/dlls/vcomp/vcomp.spec b/dlls/vcomp/vcomp.spec +index fb67146e058..09bf45550d5 100644 +--- a/dlls/vcomp/vcomp.spec ++++ b/dlls/vcomp/vcomp.spec +@@ -56,9 +56,9 @@ + @ cdecl _vcomp_enter_critsect(ptr) + @ cdecl _vcomp_flush() + @ cdecl _vcomp_for_dynamic_init(long long long long long) +-@ stub _vcomp_for_dynamic_init_i8 ++@ cdecl -arch=win64 _vcomp_for_dynamic_init_i8(int64 int64 int64 int64 int64) + @ cdecl _vcomp_for_dynamic_next(ptr ptr) +-@ stub _vcomp_for_dynamic_next_i8 ++@ cdecl -arch=win64 _vcomp_for_dynamic_next_i8(ptr ptr) + @ cdecl _vcomp_for_static_end() + @ cdecl _vcomp_for_static_init(long long long long ptr ptr ptr ptr ptr) + @ cdecl _vcomp_for_static_init_i8(int64 int64 int64 int64 ptr ptr ptr ptr ptr) +@@ -96,7 +96,7 @@ + @ cdecl omp_get_num_procs() + @ cdecl omp_get_num_threads() + @ cdecl omp_get_thread_num() +-@ stub omp_get_wtick ++@ cdecl omp_get_wtick() + @ cdecl omp_get_wtime() + @ cdecl omp_in_parallel() + @ cdecl omp_init_lock(ptr) +-- +2.39.2 + diff --git a/patches/vcomp_for_dynamic_init_i8/definition b/patches/vcomp_for_dynamic_init_i8/definition new file mode 100644 index 00000000..855a1106 --- /dev/null +++ b/patches/vcomp_for_dynamic_init_i8/definition @@ -0,0 +1 @@ +Fixes: [52012] Implement _vcomp_for_dynamic_init_i8.