mirror of
https://github.com/bulletphysics/bullet3.git
synced 2026-09-05 18:08:32 +00:00
move some recent MiniCL work to trunk
This commit is contained in:
@@ -14,6 +14,7 @@ subject to the following restrictions:
|
||||
*/
|
||||
|
||||
//#define __CELLOS_LV2__ 1
|
||||
#define __BT_SKIP_UINT64_H 1
|
||||
|
||||
#define USE_SAMPLE_PROCESS 1
|
||||
#ifdef USE_SAMPLE_PROCESS
|
||||
@@ -43,21 +44,18 @@ void* SamplelsMemoryFunc()
|
||||
#else
|
||||
|
||||
|
||||
#include "btThreadSupportInterface.h"
|
||||
#include "BulletMultiThreaded/btThreadSupportInterface.h"
|
||||
|
||||
//# include "SPUAssert.h"
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#include "MiniCL/cl_platform.h"
|
||||
|
||||
extern "C" {
|
||||
extern char SPU_SAMPLE_ELF_SYMBOL[];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
MiniCLTaskScheduler::MiniCLTaskScheduler(btThreadSupportInterface* threadInterface, int maxNumOutstandingTasks)
|
||||
:m_threadInterface(threadInterface),
|
||||
m_maxNumOutstandingTasks(maxNumOutstandingTasks)
|
||||
@@ -66,6 +64,8 @@ m_maxNumOutstandingTasks(maxNumOutstandingTasks)
|
||||
m_taskBusy.resize(m_maxNumOutstandingTasks);
|
||||
m_spuSampleTaskDesc.resize(m_maxNumOutstandingTasks);
|
||||
|
||||
m_kernels.resize(0);
|
||||
|
||||
for (int i = 0; i < m_maxNumOutstandingTasks; i++)
|
||||
{
|
||||
m_taskBusy[i] = false;
|
||||
@@ -105,7 +105,7 @@ void MiniCLTaskScheduler::initialize()
|
||||
}
|
||||
|
||||
|
||||
void MiniCLTaskScheduler::issueTask(int firstWorkUnit, int lastWorkUnit,int kernelProgramId,char* argData,int* argSizes)
|
||||
void MiniCLTaskScheduler::issueTask(int firstWorkUnit, int lastWorkUnit, MiniCLKernel* kernel)
|
||||
{
|
||||
|
||||
#ifdef DEBUG_SPU_TASK_SCHEDULING
|
||||
@@ -120,16 +120,18 @@ void MiniCLTaskScheduler::issueTask(int firstWorkUnit, int lastWorkUnit,int kern
|
||||
// send task description in event message
|
||||
taskDesc.m_firstWorkUnit = firstWorkUnit;
|
||||
taskDesc.m_lastWorkUnit = lastWorkUnit;
|
||||
taskDesc.m_kernelProgramId = kernelProgramId;
|
||||
taskDesc.m_kernel = kernel;
|
||||
//some bookkeeping to recognize finished tasks
|
||||
taskDesc.m_taskId = m_currentTask;
|
||||
|
||||
for (int i=0;i<MINI_CL_MAX_ARG;i++)
|
||||
// for (int i=0;i<MINI_CL_MAX_ARG;i++)
|
||||
for (unsigned int i=0; i < kernel->m_numArgs; i++)
|
||||
{
|
||||
taskDesc.m_argSizes[i] = argSizes[i];
|
||||
taskDesc.m_argSizes[i] = kernel->m_argSizes[i];
|
||||
if (taskDesc.m_argSizes[i])
|
||||
{
|
||||
memcpy(&taskDesc.m_argData[i],&argData[MINICL_MAX_ARGLENGTH*i],taskDesc.m_argSizes[i]);
|
||||
taskDesc.m_argData[i] = kernel->m_argData[i];
|
||||
// memcpy(&taskDesc.m_argData[i],&argData[MINICL_MAX_ARGLENGTH*i],taskDesc.m_argSizes[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -221,6 +223,296 @@ void MiniCLTaskScheduler::flush()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
typedef void (*MiniCLKernelLauncher0)(int);
|
||||
typedef void (*MiniCLKernelLauncher1)(void*, int);
|
||||
typedef void (*MiniCLKernelLauncher2)(void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher3)(void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher4)(void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher5)(void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher6)(void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher7)(void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher8)(void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher9)(void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher10)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher11)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher12)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher13)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher14)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher15)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
typedef void (*MiniCLKernelLauncher16)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, void*, int);
|
||||
|
||||
|
||||
static void kernelLauncher0(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher0)(taskDesc->m_kernel->m_launcher))(guid);
|
||||
}
|
||||
static void kernelLauncher1(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher1)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher2(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher2)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher3(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher3)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher4(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher4)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher5(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher5)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher6(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher6)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher7(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher7)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher8(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher8)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher9(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher9)(taskDesc->m_kernel->m_pCode))( taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher10(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher10)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher11(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher11)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher12(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher12)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
taskDesc->m_argData[11],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher13(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher13)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
taskDesc->m_argData[11],
|
||||
taskDesc->m_argData[12],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher14(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher14)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
taskDesc->m_argData[11],
|
||||
taskDesc->m_argData[12],
|
||||
taskDesc->m_argData[13],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher15(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher15)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
taskDesc->m_argData[11],
|
||||
taskDesc->m_argData[12],
|
||||
taskDesc->m_argData[13],
|
||||
taskDesc->m_argData[14],
|
||||
guid);
|
||||
}
|
||||
static void kernelLauncher16(MiniCLTaskDesc* taskDesc, int guid)
|
||||
{
|
||||
((MiniCLKernelLauncher16)(taskDesc->m_kernel->m_pCode))(taskDesc->m_argData[0],
|
||||
taskDesc->m_argData[1],
|
||||
taskDesc->m_argData[2],
|
||||
taskDesc->m_argData[3],
|
||||
taskDesc->m_argData[4],
|
||||
taskDesc->m_argData[5],
|
||||
taskDesc->m_argData[6],
|
||||
taskDesc->m_argData[7],
|
||||
taskDesc->m_argData[8],
|
||||
taskDesc->m_argData[9],
|
||||
taskDesc->m_argData[10],
|
||||
taskDesc->m_argData[11],
|
||||
taskDesc->m_argData[12],
|
||||
taskDesc->m_argData[13],
|
||||
taskDesc->m_argData[14],
|
||||
taskDesc->m_argData[15],
|
||||
guid);
|
||||
}
|
||||
|
||||
static kernelLauncherCB spLauncherList[MINI_CL_MAX_ARG+1] =
|
||||
{
|
||||
kernelLauncher0,
|
||||
kernelLauncher1,
|
||||
kernelLauncher2,
|
||||
kernelLauncher3,
|
||||
kernelLauncher4,
|
||||
kernelLauncher5,
|
||||
kernelLauncher6,
|
||||
kernelLauncher7,
|
||||
kernelLauncher8,
|
||||
kernelLauncher9,
|
||||
kernelLauncher10,
|
||||
kernelLauncher11,
|
||||
kernelLauncher12,
|
||||
kernelLauncher13,
|
||||
kernelLauncher14,
|
||||
kernelLauncher15,
|
||||
kernelLauncher16
|
||||
};
|
||||
|
||||
void MiniCLKernel::updateLauncher()
|
||||
{
|
||||
m_launcher = spLauncherList[m_numArgs];
|
||||
}
|
||||
|
||||
struct MiniCLKernelDescEntry
|
||||
{
|
||||
void* pCode;
|
||||
char* pName;
|
||||
};
|
||||
static MiniCLKernelDescEntry spKernelDesc[256];
|
||||
static int sNumKernelDesc = 0;
|
||||
|
||||
MiniCLKernelDesc::MiniCLKernelDesc(void* pCode, char* pName)
|
||||
{
|
||||
for(int i = 0; i < sNumKernelDesc; i++)
|
||||
{
|
||||
if(!strcmp(pName, spKernelDesc[i].pName))
|
||||
{ // already registered
|
||||
btAssert(spKernelDesc[i].pCode == pCode);
|
||||
return;
|
||||
}
|
||||
}
|
||||
spKernelDesc[sNumKernelDesc].pCode = pCode;
|
||||
spKernelDesc[sNumKernelDesc].pName = pName;
|
||||
sNumKernelDesc++;
|
||||
}
|
||||
|
||||
|
||||
MiniCLKernel* MiniCLKernel::registerSelf()
|
||||
{
|
||||
m_scheduler->registerKernel(this);
|
||||
for(int i = 0; i < sNumKernelDesc; i++)
|
||||
{
|
||||
if(!strcmp(m_name, spKernelDesc[i].pName))
|
||||
{
|
||||
m_pCode = spKernelDesc[i].pCode;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user