Cell: clean-up cell_spu_exit() code
authorBrian <brian.paul@tungstengraphics.com>
Thu, 10 Jan 2008 16:13:10 +0000 (09:13 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Thu, 10 Jan 2008 18:26:20 +0000 (11:26 -0700)
src/mesa/pipe/cell/ppu/cell_context.c
src/mesa/pipe/cell/ppu/cell_spu.c
src/mesa/pipe/cell/ppu/cell_spu.h

index 4fcf804d828f5f5a8e4b838a453fcb9de720a1c8..57178c835f91861800e47d192802356253898f73 100644 (file)
@@ -148,7 +148,6 @@ cell_destroy_context( struct pipe_context *pipe )
    struct cell_context *cell = cell_context(pipe);
 
    cell_spu_exit(cell);
-   wait_spus(cell->num_spus);
 
    free(cell);
 }
@@ -255,7 +254,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
 
 #if 0
    test_spus(cell);
-   wait_spus();
 #endif
 
    return &cell->pipe;
index a7dbf24dd8f1c34c7378f85331a271b2b5688f3d..44ad3f22b391f29faf200d8efd2975d0f30926a4 100644 (file)
@@ -194,32 +194,23 @@ test_spus(struct cell_context *cell)
 }
 
 
-/**
- * Wait for all SPUs to exit/return.
- */
-void
-wait_spus(uint num_spus)
-{
-   uint i;
-   void *value;
-
-   for (i = 0; i < num_spus; i++) {
-      pthread_join(cell_global.spe_threads[i], &value);
-   }
-}
-
-
 /**
  * Tell all the SPUs to stop/exit.
  */
 void
 cell_spu_exit(struct cell_context *cell)
 {
-   unsigned i;
+   uint i;
 
    for (i = 0; i < cell->num_spus; i++) {
       send_mbox_message(cell_global.spe_contexts[i], CELL_CMD_EXIT);
    }
 
-   wait_spus(cell->num_spus);
+   /* wait for threads to exit */
+   for (i = 0; i < cell->num_spus; i++) {
+      void *value;
+      pthread_join(cell_global.spe_threads[i], &value);
+      cell_global.spe_threads[i] = 0;
+      cell_global.spe_contexts[i] = 0;
+   }
 }
index 612cb45c59deb4ce44b0c90fd9eb27c62eabd284..d11001af62ba4fec75b47f2f2a9b8221dc84c45a 100644 (file)
@@ -82,9 +82,6 @@ void
 test_spus(struct cell_context *cell);
 
 
-void
-wait_spus(uint num_spus);
-
 void
 cell_spu_exit(struct cell_context *cell);