00001 #include <malloc_align.h>
00002 #include <free_align.h>
00003 #include <stdlib.h>
00004 #include <string.h>
00005
00006 #include <moc.h>
00007 #include <ppu/moc.h>
00008 #include <internal/imoc.h>
00009 #include <internal/ppu/imoc_core_ppu.h>
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 uint8_t moc_spu_thread_count = 0;
00020
00021
00022
00023
00024 uint8_t moc_ppu_thread_count = 0;
00025
00026
00027
00028
00029
00030
00031 moc_spu_thread_t moc_spu_thread_list[MOC_SPU_THREAD_MAX];
00032
00033 uint32_t moc_spu_buffer_size = MOC_BUFFER_SIZE;
00034
00035 uint8_t moc_spu_queue_size = MOC_QUEUE_SIZE;
00036
00037 void* moc_spe_pthread_func(void *arg)
00038 {
00039 moc_spu_thread_t* handle = (moc_spu_thread_t*) arg;
00040
00041 if (spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1) != 0)
00042 {
00043 if (spe_context_run(handle->speid, &handle->spe_entry_adress, 0,
00044 handle->argp, handle->envp, &handle->stop_info) < 0)
00045 {
00046 fprintf(
00047 stderr,
00048 "FAILED Thread %u: spe_context_run(errno=%d strerror=%s)\n",
00049 handle->rank, errno, strerror(errno));
00050 pthread_exit(NULL);
00051 }
00052 }
00053 else
00054 {
00055 fprintf(stderr, "ERROR Thread %u: No usable SPE\n", handle->rank);
00056 }
00057
00058 if (spe_context_destroy(handle->speid) != 0)
00059 {
00060 fprintf(
00061 stderr,
00062 "FAILED Thread %u: spe_context_destroy(errno=%d strerror=%s)\n",
00063 handle->rank, errno, strerror(errno));
00064 pthread_exit(NULL);
00065 }
00066
00067 if (handle->stop_info.stop_reason == SPE_EXIT)
00068 {
00069 if (handle->stop_info.result.spe_exit_code != 0)
00070 {
00071 fprintf(
00072 stderr,
00073 "FAILED Thread %u: SPE returned a non-zero exit status (%i)\n",
00074 handle->rank, handle->stop_info.result.spe_exit_code);
00075 }
00076 }
00077 else
00078 if (handle->stop_info.stop_reason == SPE_STOP_AND_SIGNAL)
00079 {
00080 fprintf(
00081 stderr,
00082 " FAILED Thread %u: SPE Stop and Signal (Signalcode: %i)\n",
00083 handle->rank, handle->stop_info.result.spe_signal_code);
00084 }
00085 else
00086 {
00087 fprintf(
00088 stderr,
00089 " FAILED Thread %u: SPE abnormally terminated (Reason: %i)\n",
00090 handle->rank, handle->stop_info.stop_reason);
00091 }
00092 pthread_exit(NULL);
00093 }
00094
00095
00096