1 /* Global headerfile of the OpenMP Testsuite */
3 #ifndef OMP_TESTSUITE_H
4 #define OMP_TESTSUITE_H
11 /**********************************************************/
12 #define LOOPCOUNT 1000 /* Number of iterations to slit amongst threads */
13 #define REPETITIONS 10 /* Number of times to run each test */
15 /* following times are in seconds */
18 /* Definitions for tasks */
19 /**********************************************************/
21 #define MAX_TASKS_PER_THREAD 5
24 // Windows versions of pthread_create() and pthread_join()
26 typedef HANDLE pthread_t
;
28 // encapsulates the information about a pthread-callable function
29 struct thread_func_info_t
{
30 void* (*start_routine
)(void*);
34 // call the void* start_routine(void*);
35 static DWORD
__thread_func_wrapper(LPVOID lpParameter
) {
36 struct thread_func_info_t
* function_information
;
37 function_information
= (struct thread_func_info_t
*)lpParameter
;
38 function_information
->start_routine(function_information
->arg
);
39 free(function_information
);
44 static int pthread_create(pthread_t
*thread
, void *attr
,
45 void *(*start_routine
) (void *), void *arg
) {
47 struct thread_func_info_t
* info
;
48 info
= (struct thread_func_info_t
*)malloc(sizeof(struct thread_func_info_t
));
49 info
->start_routine
= start_routine
;
51 pthread
= CreateThread(NULL
, 0, __thread_func_wrapper
, info
, 0, NULL
);
52 if (pthread
== NULL
) {
53 fprintf(stderr
, "CreateThread() failed: Error #%u.\n", GetLastError());
59 // retval is ignored for now
60 static int pthread_join(pthread_t thread
, void **retval
) {
62 rc
= WaitForSingleObject(thread
, INFINITE
);
63 if (rc
== WAIT_FAILED
) {
64 fprintf(stderr
, "WaitForSingleObject() failed: Error #%u.\n",
68 rc
= CloseHandle(thread
);
70 fprintf(stderr
, "CloseHandle() failed: Error #%u.\n", GetLastError());