Go to the source code of this file.
Data Structures | |
struct | cell_global_info |
Global vars, for now anyway. More... | |
Defines | |
#define | MAX_SPUS 8 |
Functions | |
void | send_mbox_message (spe_context_ptr_t ctx, unsigned int msg) |
Write a 1-word message to the given SPE mailbox. | |
uint | wait_mbox_message (spe_context_ptr_t ctx) |
Wait for a 1-word message to arrive in given mailbox. | |
void | cell_start_spus (struct cell_context *cell) |
Create the SPU threads. | |
void | cell_spu_exit (struct cell_context *cell) |
Tell all the SPUs to stop/exit. | |
Variables | |
struct cell_global_info | cell_global |
Utility/wrappers for communicating with the SPUs. | |
spe_program_handle_t | g3d_spu |
This is the handle for the actual SPE code. |
#define MAX_SPUS 8 |
Definition at line 39 of file cell_spu.h.
void cell_spu_exit | ( | struct cell_context * | cell | ) |
Tell all the SPUs to stop/exit.
This is done when the driver's exiting / cleaning up.
Definition at line 168 of file cell_spu.c.
References CELL_CMD_EXIT, cell_global, cell_context::num_spus, send_mbox_message(), cell_global_info::spe_contexts, and cell_global_info::spe_threads.
00169 { 00170 uint i; 00171 00172 for (i = 0; i < cell->num_spus; i++) { 00173 send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_EXIT); 00174 } 00175 00176 /* wait for threads to exit */ 00177 for (i = 0; i < cell->num_spus; i++) { 00178 void *value; 00179 pthread_join(cell_global.spe_threads[i], &value); 00180 cell_global.spe_threads[i] = 0; 00181 cell_global.spe_contexts[i] = 0; 00182 } 00183 }
void cell_start_spus | ( | struct cell_context * | cell | ) |
Create the SPU threads.
This is done once during driver initialization. This involves setting the the "init" message which is sent to each SPU. The init message specifies an SPU id, total number of SPUs, location and number of batch buffers, etc.
Definition at line 113 of file cell_spu.c.
References assert, ASSERT_ALIGN16, cell_init_info::buffer_status, cell_init_info::buffers, cell_global, CELL_NUM_BUFFERS, cell_thread_function(), cell_init_info::cmd, cell_global_info::command, cell_context::debug_flags, cell_init_info::debug_flags, FALSE, g3d_spu, cell_init_info::id, cell_global_info::inits, MAX_SPUS, cell_init_info::num_spus, cell_context::num_spus, one_time_init(), cell_global_info::spe_contexts, cell_global_info::spe_threads, and TRUE.
00114 { 00115 static boolean one_time_init = FALSE; 00116 uint i, j; 00117 00118 if (one_time_init) { 00119 fprintf(stderr, "PPU: Multiple rendering contexts not yet supported " 00120 "on Cell.\n"); 00121 abort(); 00122 } 00123 00124 one_time_init = TRUE; 00125 00126 assert(cell->num_spus <= MAX_SPUS); 00127 00128 ASSERT_ALIGN16(&cell_global.command[0]); 00129 ASSERT_ALIGN16(&cell_global.command[1]); 00130 00131 ASSERT_ALIGN16(&cell_global.inits[0]); 00132 ASSERT_ALIGN16(&cell_global.inits[1]); 00133 00134 for (i = 0; i < cell->num_spus; i++) { 00135 cell_global.inits[i].id = i; 00136 cell_global.inits[i].num_spus = cell->num_spus; 00137 cell_global.inits[i].debug_flags = cell->debug_flags; 00138 cell_global.inits[i].cmd = &cell_global.command[i]; 00139 for (j = 0; j < CELL_NUM_BUFFERS; j++) { 00140 cell_global.inits[i].buffers[j] = cell->buffer[j]; 00141 } 00142 cell_global.inits[i].buffer_status = &cell->buffer_status[0][0][0]; 00143 00144 cell_global.spe_contexts[i] = spe_context_create(0, NULL); 00145 if (!cell_global.spe_contexts[i]) { 00146 fprintf(stderr, "spe_context_create() failed\n"); 00147 exit(1); 00148 } 00149 00150 if (spe_program_load(cell_global.spe_contexts[i], &g3d_spu)) { 00151 fprintf(stderr, "spe_program_load() failed\n"); 00152 exit(1); 00153 } 00154 00155 pthread_create(&cell_global.spe_threads[i], /* returned thread handle */ 00156 NULL, /* pthread attribs */ 00157 &cell_thread_function, /* start routine */ 00158 &cell_global.inits[i]); /* thread argument */ 00159 } 00160 }
void send_mbox_message | ( | spe_context_ptr_t | ctx, | |
unsigned int | msg | |||
) |
uint wait_mbox_message | ( | spe_context_ptr_t | ctx | ) |
Wait for a 1-word message to arrive in given mailbox.
Definition at line 68 of file cell_spu.c.
00069 { 00070 do { 00071 unsigned data; 00072 int count = spe_out_mbox_read(ctx, &data, 1); 00073 00074 if (count == 1) { 00075 return data; 00076 } 00077 00078 if (count < 0) { 00079 /* error */ ; 00080 } 00081 } while (1); 00082 }
struct cell_global_info cell_global |
Utility/wrappers for communicating with the SPUs.
Cell/SPU info that's not per-context.
Definition at line 51 of file cell_spu.c.
spe_program_handle_t g3d_spu |
This is the handle for the actual SPE code.