comparison ppe/Spe.cc @ 0:68a98d68d62a

commit
author yutaka@localhost.localdomain
date Sun, 28 Mar 2010 19:47:00 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:68a98d68d62a
1 #include <libspe2.h>
2 #include <pthread.h>
3
4 void *run_abs_spe(void *arg)
5 {
6 spe_context_ptr_t *spe = (spe_context_ptr_t*) arg;
7
8 unsigned int entry;
9 spe_stop_info_t stop_info;
10
11 entry = SPE_DEFAULT_ENTRY;
12 spe_context_run(*spe, &entry, 0, 0, NULL, &stop_info);
13
14 return NULL;
15 }
16
17
18 void
19 spe_run_start(spe_context_ptr_t *spe, spe_program_handle_t *prog, pthread_t *thread, int spe_num)
20 {
21
22 for (int i = 0; i < spe_num; i++) {
23 spe[i] = spe_context_create(0, NULL);
24 spe_program_load(spe[i], prog);
25 pthread_create(&thread[i], NULL, run_abs_spe, &spe[i]);
26 }
27
28 }
29
30 void
31 spe_run_endwait(spe_context_ptr_t *spe, pthread_t *thread, int spe_num)
32 {
33
34 for (int i = 0; i < spe_num; i++) {
35 pthread_join(thread[i], NULL);
36 spe_context_destroy(spe[i]);
37 }
38
39 }