added sample task, for multi threading tests

added union vec_float4 m_Vec128; for btVector3 for SPU and PPU.
This commit is contained in:
erwin.coumans
2008-06-03 21:24:34 +00:00
parent 8028fa4999
commit 5e3777ddd2
6 changed files with 174 additions and 15 deletions

View File

@@ -0,0 +1,75 @@
/*
Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SpuSampleTask.h"
#include "BulletDynamics/Dynamics/btRigidBody.h"
#include "../PlatformDefinitions.h"
#include "../SpuFakeDma.h"
#include "LinearMath/btMinMax.h"
#include <stdio.h>
struct SampleTask_LocalStoreMemory
{
};
//-- MAIN METHOD
void processSampleTask(void* userPtr, void* lsMemory)
{
// BT_PROFILE("processSampleTask");
SampleTask_LocalStoreMemory* localMemory = (SampleTask_LocalStoreMemory*)lsMemory;
SpuSampleTaskDesc* taskDescPtr = (SpuSampleTaskDesc*)userPtr;
SpuSampleTaskDesc& taskDesc = *taskDescPtr;
switch (taskDesc.m_sampleCommand)
{
case CMD_SAMPLE_INTEGRATE_BODIES:
{
#ifdef __SPU__
spu_printf("hello SPU world\n");
#else
printf("hello world\n");
#endif
break;
}
default:
{
}
};
}
#if defined(__CELLOS_LV2__) || defined (LIBSPE2)
ATTRIBUTE_ALIGNED16(SampleTask_LocalStoreMemory gLocalStoreMemory);
void* createSampleLocalStoreMemory()
{
return &gLocalStoreMemory;
}
#else
void* createSampleLocalStoreMemory()
{
return new SampleTask_LocalStoreMemory;
};
#endif

View File

@@ -0,0 +1,53 @@
/*
Bullet Continuous Collision Detection and Physics Library, Copyright (c) 2007 Erwin Coumans
This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#ifndef SPU_SAMPLE_TASK_H
#define SPU_SAMPLE_TASK_H
#include "../PlatformDefinitions.h"
#include "LinearMath/btScalar.h"
#include "LinearMath/btVector3.h"
#include "LinearMath/btMatrix3x3.h"
#include "LinearMath/btAlignedAllocator.h"
enum
{
CMD_SAMPLE_INTEGRATE_BODIES = 1
};
ATTRIBUTE_ALIGNED16(struct) SpuSampleTaskDesc
{
BT_DECLARE_ALIGNED_ALLOCATOR();
uint32_t m_sampleCommand;
uint32_t m_taskId;
uint64_t m_mainMemoryPtr;
int m_sampleValue;
};
void processSampleTask(void* userPtr, void* lsMemory);
void* createSampleLocalStoreMemory();
#endif //SPU_SAMPLE_TASK_H

View File

@@ -105,7 +105,7 @@ void SpuSampleTaskProcess::initialize()
}
void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue)
void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue,int sampleCommand)
{
#ifdef DEBUG_SPU_TASK_SCHEDULING
@@ -123,13 +123,14 @@ void SpuSampleTaskProcess::issueTask(void* sampleMainMemPtr,int sampleValue)
taskDesc.m_mainMemoryPtr = reinterpret_cast<uint64_t>(sampleMainMemPtr);
taskDesc.m_sampleValue = sampleValue;
taskDesc.m_sampleCommand = sampleCommand;
//some bookkeeping to recognize finished tasks
taskDesc.m_taskId = m_currentTask;
}
m_threadInterface->sendRequest(CMD_SAMPLE_TASK_COMMAND, (uint32_t) &taskDesc, m_currentTask);
m_threadInterface->sendRequest(1, (uint32_t) &taskDesc, m_currentTask);
// if all tasks busy, wait for spu event to clear the task.

View File

@@ -26,18 +26,8 @@ subject to the following restrictions:
#include "LinearMath/btAlignedObjectArray.h"
///SpuSampleTaskDesc
struct SpuSampleTaskDesc
{
uint64_t m_mainMemoryPtr;
int m_sampleValue;
uint16_t m_taskId;
}
#if defined(__CELLOS_LV2__) || defined(USE_LIBSPE2)
__attribute__ ((aligned (16)))
#endif
;
#include "SpuSampleTask/SpuSampleTask.h"
//just add your commands here, try to keep them globally unique for debugging purposes
#define CMD_SAMPLE_TASK_COMMAND 10
@@ -76,7 +66,7 @@ public:
///call initialize in the beginning of the frame, before addCollisionPairToTask
void initialize();
void issueTask(void* sampleMainMemPtr,int sampleValue);
void issueTask(void* sampleMainMemPtr,int sampleValue,int sampleCommand);
///call flush to submit potential outstanding work to SPUs and wait for all involved SPUs to be finished
void flush();