Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef SPU_GATHERING_COLLISION_TASK_H
00017 #define SPU_GATHERING_COLLISION_TASK_H
00018
00019 #include "../PlatformDefinitions.h"
00020
00021
00022
00024 struct SpuGatherAndProcessPairsTaskDesc
00025 {
00026 ppu_address_t m_inPairPtr;
00027
00028 uint32_t m_someMutexVariableInMainMemory;
00029
00030 ppu_address_t m_dispatcher;
00031
00032 uint32_t numOnLastPage;
00033
00034 uint16_t numPages;
00035 uint16_t taskId;
00036 bool m_useEpa;
00037
00038 struct CollisionTask_LocalStoreMemory* m_lsMemory;
00039 }
00040
00041 #if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2)
00042 __attribute__ ((aligned (128)))
00043 #endif
00044 ;
00045
00046
00047 void processCollisionTask(void* userPtr, void* lsMemory);
00048
00049 void* createCollisionLocalStoreMemory();
00050 void deleteCollisionLocalStoreMemory();
00051
00052 #if defined(USE_LIBSPE2) && defined(__SPU__)
00053 #include "../SpuLibspe2Support.h"
00054 #include <spu_intrinsics.h>
00055 #include <spu_mfcio.h>
00056 #include <SpuFakeDma.h>
00057
00058
00059
00060
00061
00062 int main(unsigned long long speid, addr64 argp, addr64 envp)
00063 {
00064 printf("SPU: hello \n");
00065
00066 ATTRIBUTE_ALIGNED128(btSpuStatus status);
00067 ATTRIBUTE_ALIGNED16( SpuGatherAndProcessPairsTaskDesc taskDesc ) ;
00068 unsigned int received_message = Spu_Mailbox_Event_Nothing;
00069 bool shutdown = false;
00070
00071 cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00072 cellDmaWaitTagStatusAll(DMA_MASK(3));
00073
00074 status.m_status = Spu_Status_Free;
00075 status.m_lsMemory.p = createCollisionLocalStoreMemory();
00076
00077 cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00078 cellDmaWaitTagStatusAll(DMA_MASK(3));
00079
00080
00081 while ( btLikely( !shutdown ) )
00082 {
00083
00084 received_message = spu_read_in_mbox();
00085
00086 if( btLikely( received_message == Spu_Mailbox_Event_Task ))
00087 {
00088 #ifdef DEBUG_LIBSPE2_SPU_TASK
00089 printf("SPU: received Spu_Mailbox_Event_Task\n");
00090 #endif //DEBUG_LIBSPE2_SPU_TASK
00091
00092
00093 cellDmaGet(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00094 cellDmaWaitTagStatusAll(DMA_MASK(3));
00095
00096 btAssert(status.m_status==Spu_Status_Occupied);
00097
00098 cellDmaGet(&taskDesc, status.m_taskDesc.p, sizeof(SpuGatherAndProcessPairsTaskDesc), DMA_TAG(3), 0, 0);
00099 cellDmaWaitTagStatusAll(DMA_MASK(3));
00100 #ifdef DEBUG_LIBSPE2_SPU_TASK
00101 printf("SPU:processCollisionTask\n");
00102 #endif //DEBUG_LIBSPE2_SPU_TASK
00103 processCollisionTask((void*)&taskDesc, taskDesc.m_lsMemory);
00104
00105 #ifdef DEBUG_LIBSPE2_SPU_TASK
00106 printf("SPU:finished processCollisionTask\n");
00107 #endif //DEBUG_LIBSPE2_SPU_TASK
00108 }
00109 else
00110 {
00111 #ifdef DEBUG_LIBSPE2_SPU_TASK
00112 printf("SPU: received ShutDown\n");
00113 #endif //DEBUG_LIBSPE2_SPU_TASK
00114 if( btLikely( received_message == Spu_Mailbox_Event_Shutdown ) )
00115 {
00116 shutdown = true;
00117 }
00118 else
00119 {
00120
00121 }
00122 }
00123
00124
00125 status.m_status = Spu_Status_Free;
00126 cellDmaLargePut(&status, argp.ull, sizeof(btSpuStatus), DMA_TAG(3), 0, 0);
00127 cellDmaWaitTagStatusAll(DMA_MASK(3));
00128
00129
00130 }
00131
00132 printf("SPU: shutdown\n");
00133 return 0;
00134 }
00135 #endif // USE_LIBSPE2
00136
00137
00138 #endif //SPU_GATHERING_COLLISION_TASK_H
00139
00140