vcomp: Implement _vcomp_sections_init and _vcomp_sections_next.

This commit is contained in:
Sebastian Lackner 2015-07-16 15:01:33 +02:00 committed by Alexandre Julliard
parent 9c9d60f020
commit c019ebc82f
4 changed files with 54 additions and 6 deletions

View File

@ -58,6 +58,9 @@ struct vcomp_thread_data
/* only used for concurrent tasks */ /* only used for concurrent tasks */
struct list entry; struct list entry;
CONDITION_VARIABLE cond; CONDITION_VARIABLE cond;
/* section */
unsigned int section;
}; };
struct vcomp_team_data struct vcomp_team_data
@ -74,6 +77,11 @@ struct vcomp_team_data
/* barrier */ /* barrier */
unsigned int barrier; unsigned int barrier;
int barrier_count; int barrier_count;
/* section */
unsigned int section;
int num_sections;
int section_index;
}; };
#if defined(__i386__) #if defined(__i386__)
@ -301,6 +309,42 @@ void CDECL _vcomp_single_end(void)
TRACE("stub\n"); TRACE("stub\n");
} }
void CDECL _vcomp_sections_init(int n)
{
struct vcomp_thread_data *thread_data = vcomp_get_thread_data();
struct vcomp_team_data *team_data = thread_data->team;
TRACE("(%d)\n", n);
EnterCriticalSection(&vcomp_section);
thread_data->section++;
if ((int)(thread_data->section - team_data->section) > 0)
{
team_data->section = thread_data->section;
team_data->num_sections = n;
team_data->section_index = 0;
}
LeaveCriticalSection(&vcomp_section);
}
int CDECL _vcomp_sections_next(void)
{
struct vcomp_thread_data *thread_data = vcomp_get_thread_data();
struct vcomp_team_data *team_data = thread_data->team;
int i = -1;
TRACE("()\n");
EnterCriticalSection(&vcomp_section);
if (thread_data->section == team_data->section &&
team_data->section_index != team_data->num_sections)
{
i = team_data->section_index++;
}
LeaveCriticalSection(&vcomp_section);
return i;
}
static DWORD WINAPI _vcomp_fork_worker(void *param) static DWORD WINAPI _vcomp_fork_worker(void *param)
{ {
struct vcomp_thread_data *thread_data = param; struct vcomp_thread_data *thread_data = param;
@ -368,10 +412,12 @@ void WINAPIV _vcomp_fork(BOOL ifval, int nargs, void *wrapper, ...)
__ms_va_start(team_data.valist, wrapper); __ms_va_start(team_data.valist, wrapper);
team_data.barrier = 0; team_data.barrier = 0;
team_data.barrier_count = 0; team_data.barrier_count = 0;
team_data.section = 0;
thread_data.team = &team_data; thread_data.team = &team_data;
thread_data.thread_num = 0; thread_data.thread_num = 0;
thread_data.fork_threads = 0; thread_data.fork_threads = 0;
thread_data.section = 1;
list_init(&thread_data.entry); list_init(&thread_data.entry);
InitializeConditionVariable(&thread_data.cond); InitializeConditionVariable(&thread_data.cond);
@ -387,6 +433,7 @@ void WINAPIV _vcomp_fork(BOOL ifval, int nargs, void *wrapper, ...)
data->team = &team_data; data->team = &team_data;
data->thread_num = team_data.num_threads++; data->thread_num = team_data.num_threads++;
data->fork_threads = 0; data->fork_threads = 0;
data->section = 1;
list_remove(&data->entry); list_remove(&data->entry);
list_add_tail(&thread_data.entry, &data->entry); list_add_tail(&thread_data.entry, &data->entry);
WakeAllConditionVariable(&data->cond); WakeAllConditionVariable(&data->cond);
@ -405,6 +452,7 @@ void WINAPIV _vcomp_fork(BOOL ifval, int nargs, void *wrapper, ...)
data->team = &team_data; data->team = &team_data;
data->thread_num = team_data.num_threads; data->thread_num = team_data.num_threads;
data->fork_threads = 0; data->fork_threads = 0;
data->section = 1;
InitializeConditionVariable(&data->cond); InitializeConditionVariable(&data->cond);
thread = CreateThread(NULL, 0, _vcomp_fork_worker, data, 0, NULL); thread = CreateThread(NULL, 0, _vcomp_fork_worker, data, 0, NULL);

View File

@ -83,8 +83,8 @@
@ stub _vcomp_reduction_u2 @ stub _vcomp_reduction_u2
@ stub _vcomp_reduction_u4 @ stub _vcomp_reduction_u4
@ stub _vcomp_reduction_u8 @ stub _vcomp_reduction_u8
@ stub _vcomp_sections_init @ cdecl _vcomp_sections_init(long)
@ stub _vcomp_sections_next @ cdecl _vcomp_sections_next()
@ cdecl _vcomp_set_num_threads(long) @ cdecl _vcomp_set_num_threads(long)
@ cdecl _vcomp_single_begin(long) @ cdecl _vcomp_single_begin(long)
@ cdecl _vcomp_single_end() @ cdecl _vcomp_single_end()

View File

@ -83,8 +83,8 @@
@ stub _vcomp_reduction_u2 @ stub _vcomp_reduction_u2
@ stub _vcomp_reduction_u4 @ stub _vcomp_reduction_u4
@ stub _vcomp_reduction_u8 @ stub _vcomp_reduction_u8
@ stub _vcomp_sections_init @ cdecl _vcomp_sections_init(long) vcomp._vcomp_sections_init
@ stub _vcomp_sections_next @ cdecl _vcomp_sections_next() vcomp._vcomp_sections_next
@ cdecl _vcomp_set_num_threads(long) vcomp._vcomp_set_num_threads @ cdecl _vcomp_set_num_threads(long) vcomp._vcomp_set_num_threads
@ cdecl _vcomp_single_begin(long) vcomp._vcomp_single_begin @ cdecl _vcomp_single_begin(long) vcomp._vcomp_single_begin
@ cdecl _vcomp_single_end() vcomp._vcomp_single_end @ cdecl _vcomp_single_end() vcomp._vcomp_single_end

View File

@ -83,8 +83,8 @@
@ stub _vcomp_reduction_u2 @ stub _vcomp_reduction_u2
@ stub _vcomp_reduction_u4 @ stub _vcomp_reduction_u4
@ stub _vcomp_reduction_u8 @ stub _vcomp_reduction_u8
@ stub _vcomp_sections_init @ cdecl _vcomp_sections_init(long) vcomp._vcomp_sections_init
@ stub _vcomp_sections_next @ cdecl _vcomp_sections_next() vcomp._vcomp_sections_next
@ cdecl _vcomp_set_num_threads(long) vcomp._vcomp_set_num_threads @ cdecl _vcomp_set_num_threads(long) vcomp._vcomp_set_num_threads
@ cdecl _vcomp_single_begin(long) vcomp._vcomp_single_begin @ cdecl _vcomp_single_begin(long) vcomp._vcomp_single_begin
@ cdecl _vcomp_single_end() vcomp._vcomp_single_end @ cdecl _vcomp_single_end() vcomp._vcomp_single_end