Added libspe2 parallel Cell SPE support contribution by IBM Germany 'Extreme Blue' project:

Thanks to Benjamin Hoeferlin, Minh Cuong Tran,Martina Huellmann,Frederick Roth.
This commit is contained in:
ejcoumans
2007-09-26 23:37:25 +00:00
parent dae8b658da
commit 5ebab3e59b
4 changed files with 498 additions and 467 deletions

View File

@@ -6,6 +6,13 @@
///This file provides some platform/compiler checks for common definitions ///This file provides some platform/compiler checks for common definitions
#ifdef WIN32 #ifdef WIN32
typedef union
{
unsigned int u;
void *p;
} addr64;
#if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300) #if defined(__MINGW32__) || defined(__CYGWIN__) || (defined (_MSC_VER) && _MSC_VER < 1300)
#else #else
#endif //__MINGW32__ #endif //__MINGW32__
@@ -22,23 +29,44 @@
#define USE_WIN32_THREADING 1 #define USE_WIN32_THREADING 1
#include <stdio.h>
#define spu_printf printf
#else #else
#if defined (__CELLOS_LV2__)
///Playstation 3 Cell SDK
#include <spu_printf.h>
#else
//non-windows systems
#define USE_PTHREADS 1
#endif //__CELLOS_LV2__
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> //for memcpy #include <string.h> //for memcpy
#if defined (__CELLOS_LV2__)
// Playstation 3 Cell SDK
#include <spu_printf.h>
#else
// posix system
#define USE_PTHREADS
#ifdef USE_LIBSPE2
#include <stdio.h>
#define spu_printf printf
#define DWORD unsigned int
typedef union
{
unsigned long long ull;
unsigned int ui[2];
void *p;
} addr64;
#endif // USE_LIBSPE2
#endif //__CELLOS_LV2__
#endif #endif
#endif //TYPE_DEFINITIONS_H #endif //TYPE_DEFINITIONS_H

View File

@@ -16,23 +16,10 @@ subject to the following restrictions:
//#define DEBUG_SPU_TASK_SCHEDULING 1 //#define DEBUG_SPU_TASK_SCHEDULING 1
#include "btThreadSupportInterface.h"
//#include "SPUAssert.h"
#include <string.h>
//class OptimizedBvhNode; //class OptimizedBvhNode;
#include "SpuCollisionTaskProcess.h" #include "SpuCollisionTaskProcess.h"
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
#include "BulletCollision/CollisionShapes/btConvexShape.h"
#include "SpuLibspe2Support.h"
#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" // for definitions processCollisionTask and createCollisionLocalStoreMemory
#include <stdio.h>
@@ -44,7 +31,6 @@ SpuCollisionTaskProcess::SpuCollisionTaskProcess(class btThreadSupportInterface*
m_maxNumOutstandingTasks(maxNumOutstandingTasks) m_maxNumOutstandingTasks(maxNumOutstandingTasks)
{ {
m_workUnitTaskBuffers = (unsigned char *)0; m_workUnitTaskBuffers = (unsigned char *)0;
m_taskBusy.resize(m_maxNumOutstandingTasks); m_taskBusy.resize(m_maxNumOutstandingTasks);
m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks); m_spuGatherTaskDesc.resize(m_maxNumOutstandingTasks);
@@ -70,9 +56,10 @@ m_maxNumOutstandingTasks(maxNumOutstandingTasks)
SpuCollisionTaskProcess::~SpuCollisionTaskProcess() SpuCollisionTaskProcess::~SpuCollisionTaskProcess()
{ {
if (m_workUnitTaskBuffers != 0) if (m_workUnitTaskBuffers != 0)
{ {
free(m_workUnitTaskBuffers); btAlignedFree(m_workUnitTaskBuffers);
m_workUnitTaskBuffers = 0; m_workUnitTaskBuffers = 0;
} }
@@ -84,15 +71,15 @@ SpuCollisionTaskProcess::~SpuCollisionTaskProcess()
void void SpuCollisionTaskProcess::initialize2()
SpuCollisionTaskProcess::initialize2()
{ {
#ifdef DEBUG_SPU_TASK_SCHEDULING #ifdef DEBUG_SPU_TASK_SCHEDULING
printf("SpuCollisionTaskProcess::initialize()\n"); printf("SpuCollisionTaskProcess::initialize()\n");
#endif //DEBUG_SPU_TASK_SCHEDULING #endif //DEBUG_SPU_TASK_SCHEDULING
if (!m_workUnitTaskBuffers) if (!m_workUnitTaskBuffers)
{ {
m_workUnitTaskBuffers = (unsigned char *)memalign(128, MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks); m_workUnitTaskBuffers = (unsigned char *)btAlignedAlloc(MIDPHASE_WORKUNIT_TASK_SIZE*m_maxNumOutstandingTasks, 128);
} }
for (int i = 0; i < m_maxNumOutstandingTasks; i++) for (int i = 0; i < m_maxNumOutstandingTasks; i++)
@@ -114,10 +101,8 @@ SpuCollisionTaskProcess::initialize2()
void SpuCollisionTaskProcess::issueTask2() void SpuCollisionTaskProcess::issueTask2()
{ {
#ifdef DEBUG_SPU_TASK_SCHEDULING #ifdef DEBUG_SPU_TASK_SCHEDULING
printf("SpuCollisionTaskProcess::issueTask (m_currentTask= %d\)n", m_currentTask); printf("SpuCollisionTaskProcess::issueTask (m_currentTask= %d\n)", m_currentTask);
#endif //DEBUG_SPU_TASK_SCHEDULING #endif //DEBUG_SPU_TASK_SCHEDULING
m_taskBusy[m_currentTask] = true; m_taskBusy[m_currentTask] = true;
@@ -265,7 +250,7 @@ SpuCollisionTaskProcess::flush2()
// all tasks are issued, wait for all tasks to be complete // all tasks are issued, wait for all tasks to be complete
while(m_numBusyTasks > 0) while(m_numBusyTasks > 0)
{ {
// Consolidating SPU code // Consolidating SPU code
unsigned int taskId; unsigned int taskId;
unsigned int outputSize; unsigned int outputSize;

View File

@@ -22,8 +22,25 @@ subject to the following restrictions:
#include "PlatformDefinitions.h" #include "PlatformDefinitions.h"
#include "LinearMath/btAlignedObjectArray.h" #include "LinearMath/btAlignedObjectArray.h"
#include "SpuNarrowPhaseCollisionTask/SpuGatheringCollisionTask.h" // for definitions processCollisionTask and createCollisionLocalStoreMemory
//#define DEBUG_SpuCollisionTaskProcess 1 #include "btThreadSupportInterface.h"
//#include "SPUAssert.h"
#include <string.h>
#include "BulletCollision/CollisionDispatch/btCollisionObject.h"
#include "BulletCollision/CollisionShapes/btCollisionShape.h"
#include "BulletCollision/CollisionShapes/btConvexShape.h"
#include <LinearMath/btAlignedAllocator.h>
#include <stdio.h>
#define DEBUG_SpuCollisionTaskProcess 1
#define CMD_GATHER_AND_PROCESS_PAIRLIST 1 #define CMD_GATHER_AND_PROCESS_PAIRLIST 1
@@ -33,26 +50,27 @@ class btPersistentManifold;
class btDispatcher; class btDispatcher;
///Task Description for SPU collision detection /////Task Description for SPU collision detection
struct SpuGatherAndProcessPairsTaskDesc //struct SpuGatherAndProcessPairsTaskDesc
{ //{
uint64_t inPtr;//m_pairArrayPtr; // uint64_t inPtr;//m_pairArrayPtr;
//mutex variable // //mutex variable
uint32_t m_someMutexVariableInMainMemory; // uint32_t m_someMutexVariableInMainMemory;
//
uint64_t m_dispatcher; // uint64_t m_dispatcher;
//
uint32_t numOnLastPage; // uint32_t numOnLastPage;
//
uint16_t numPages; // uint16_t numPages;
uint16_t taskId; // uint16_t taskId;
//
// struct CollisionTask_LocalStoreMemory* m_lsMemory; // struct CollisionTask_LocalStoreMemory* m_lsMemory;
} //}
#ifdef __CELLOS_LV2__ //
__attribute__ ((aligned (16))) //#if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2)
#endif //__attribute__ ((aligned (16)))
; //#endif
//;
///MidphaseWorkUnitInput stores individual primitive versus mesh collision detection input, to be processed by the SPU. ///MidphaseWorkUnitInput stores individual primitive versus mesh collision detection input, to be processed by the SPU.