/* author: Guochun Shi */ #include #include #include #include #include #include #include #include extern spe_program_handle_t simple_spu; double gettime(void) { struct timeval t; double result; if (gettimeofday(&t, NULL) < 0){ fprintf(stderr, "ERROR: gettimeofday() failed\n"); return -1; } result = t.tv_sec + t.tv_usec*0.000001; return result; } #define MAX_THREADS 16 pthread_t spe_pthread_ids[MAX_THREADS]; spe_context_ptr_t spe[MAX_THREADS]; spe_spu_control_area_t* ps_area[MAX_THREADS]; void* my_spe_thread(void* _arg){ spe_context_ptr_t specontext = (spe_context_ptr_t)_arg; unsigned int runflags = 0; unsigned int entry = SPE_DEFAULT_ENTRY; spe_context_run(specontext, &entry, runflags, NULL, NULL, NULL); pthread_exit(NULL); return NULL; } int main(int argc, char** argv) { int i; double t0, t1; int ite; int iterations = 1000000; int rc; int n = 8; if (argc >=2 ){ n = atoi(argv[1]); if (n <= 0){ printf("invalid spe numbers\n"); exit(1); } } for ( i=0;i