view ppe/Spe.cc @ 6:b25035e3282d

fix
author yutaka@localhost.localdomain
date Sat, 10 Apr 2010 16:50:55 +0900
parents 68a98d68d62a
children
line wrap: on
line source

#include <libspe2.h>
#include <pthread.h>

void *run_abs_spe(void *arg)
{
  spe_context_ptr_t *spe = (spe_context_ptr_t*) arg;

  unsigned int entry;
  spe_stop_info_t stop_info;

  entry = SPE_DEFAULT_ENTRY;
  spe_context_run(*spe, &entry, 0, 0, NULL, &stop_info); 

  return NULL;
}


void
spe_run_start(spe_context_ptr_t *spe, spe_program_handle_t *prog, pthread_t *thread, int spe_num)
{

  for (int i = 0; i < spe_num; i++) {
    spe[i] = spe_context_create(0, NULL);
    spe_program_load(spe[i], prog);
    pthread_create(&thread[i], NULL, run_abs_spe, &spe[i]);
  }

}

void
spe_run_endwait(spe_context_ptr_t *spe, pthread_t *thread, int spe_num)
{

  for (int i = 0; i < spe_num; i++) {
    pthread_join(thread[i], NULL);
    spe_context_destroy(spe[i]);
  }

}