@@ -224,6 +224,10 @@ static int RunBigEndian()
224
224
return 0 ;
225
225
}
226
226
227
+ #define MITH_MAX_CONTEXT_NUM 12
228
+ #define STACK_SZ (1024 * 64)
229
+ K_THREAD_STACK_ARRAY_DEFINE (stack_ctx , MITH_MAX_CONTEXT_NUM , STACK_SZ );
230
+
227
231
/* Function: mith_main
228
232
Description:
229
233
main function that fires off work items.
@@ -291,15 +295,25 @@ size_t mith_main_loop(ee_workload *workload, unsigned int num_iterations, unsign
291
295
}
292
296
th_log (TH_INFO ,"Starting Run..." );
293
297
298
+ if (num_contexts > MITH_MAX_CONTEXT_NUM ) {
299
+ th_log (TH_INFO , "Too much contexts selected!" );
300
+ return 0 ;
301
+ }
302
+
303
+ pthread_attr_t attr [MITH_MAX_CONTEXT_NUM ] = {};
304
+
294
305
/* now to start the timer, and get the first item */
295
306
/* from here on we need to worry about thread safety */
296
307
al_signal_start ();
297
308
/* create the thread pool */
298
- for (i = 0 ; i < num_contexts ; i ++ )
299
- al_thread_create (& (context [i ].thread ),bench_thread ,(void * )(& context [i ]));
309
+ for (i = 0 ; i < num_contexts ; i ++ ) {
310
+ pthread_attr_init (& attr [i ]);
311
+ pthread_attr_setstack (& attr [i ], & stack_ctx [i ][0 ], STACK_SZ );
312
+ pthread_create ((pthread_t * )(& (context [i ].thread )),& attr [i ],bench_thread ,(void * )(& context [i ]));
313
+ }
300
314
/* and wait until threads are all done executing */
301
315
for (i = 0 ; i < num_contexts ; i ++ )
302
- al_thread_join ( (context [i ].thread ),& context_ret );
316
+ pthread_join (( pthread_t ) (context [i ].thread ),& context_ret );
303
317
total_time = al_signal_finished ();
304
318
/* workload is now done, report results */
305
319
/* from here on, only one thread operates */
0 commit comments