move some recent MiniCL work to trunk

This commit is contained in:
erwin.coumans
2010-02-08 22:42:58 +00:00
parent 52e60c8246
commit 7d4e2873e2
15 changed files with 1471 additions and 724 deletions

View File

@@ -15,10 +15,12 @@ subject to the following restrictions:
#include "MiniCLTask.h"
#include "../PlatformDefinitions.h"
#include "../SpuFakeDma.h"
#include "BulletMultiThreaded/PlatformDefinitions.h"
#include "BulletMultiThreaded/SpuFakeDma.h"
#include "LinearMath/btMinMax.h"
#include "BulletMultiThreaded/MiniCLTask/MiniCLTask.h"
#include "MiniCLTask.h"
#include "BulletMultiThreaded/MiniCLTaskScheduler.h"
#ifdef __SPU__
#include <spu_printf.h>
@@ -27,9 +29,7 @@ subject to the following restrictions:
#define spu_printf printf
#endif
#define __kernel
#define __global
#define get_global_id(a) guid
int gMiniCLNumOutstandingTasks = 0;
struct MiniCLTask_LocalStoreMemory
{
@@ -37,65 +37,23 @@ struct MiniCLTask_LocalStoreMemory
};
///////////////////////////////////////////////////
// OpenCL Kernel Function for element by element vector addition
__kernel void VectorAdd(__global const float8* a, __global const float8* b, __global float8* c, int guid)
{
// get oct-float index into global data array
int iGID = get_global_id(0);
// read inputs into registers
float8 f8InA = a[iGID];
float8 f8InB = b[iGID];
float8 f8Out = (float8)0.0f;
// add the vector elements
f8Out.s0 = f8InA.s0 + f8InB.s0;
f8Out.s1 = f8InA.s1 + f8InB.s1;
f8Out.s2 = f8InA.s2 + f8InB.s2;
f8Out.s3 = f8InA.s3 + f8InB.s3;
f8Out.s4 = f8InA.s4 + f8InB.s4;
f8Out.s5 = f8InA.s5 + f8InB.s5;
f8Out.s6 = f8InA.s6 + f8InB.s6;
f8Out.s7 = f8InA.s7 + f8InB.s7;
// write back out to GMEM
c[get_global_id(0)] = f8Out;
}
///////////////////////////////////////////////////
//-- MAIN METHOD
void processMiniCLTask(void* userPtr, void* lsMemory)
{
// BT_PROFILE("processSampleTask");
//MiniCLTask_LocalStoreMemory* localMemory = (MiniCLTask_LocalStoreMemory*)lsMemory;
MiniCLTask_LocalStoreMemory* localMemory = (MiniCLTask_LocalStoreMemory*)lsMemory;
MiniCLTaskDesc* taskDescPtr = (MiniCLTaskDesc*)userPtr;
MiniCLTaskDesc& taskDesc = *taskDescPtr;
printf("Compute Unit[%d] executed kernel %d work items [%d..%d)\n",taskDesc.m_taskId,taskDesc.m_kernelProgramId,taskDesc.m_firstWorkUnit,taskDesc.m_lastWorkUnit);
switch (taskDesc.m_kernelProgramId)
for (unsigned int i=taskDesc.m_firstWorkUnit;i<taskDesc.m_lastWorkUnit;i++)
{
case CMD_MINICL_ADDVECTOR:
{
for (unsigned int i=taskDesc.m_firstWorkUnit;i<taskDesc.m_lastWorkUnit;i++)
{
VectorAdd(*(const float8**)&taskDesc.m_argData[0][0],*(const float8**)&taskDesc.m_argData[1][0],*(float8**)&taskDesc.m_argData[2][0],i);
}
break;
}
default:
{
printf("error in processMiniCLTask: unknown command id: %d\n",taskDesc.m_kernelProgramId);
}
};
taskDesc.m_kernel->m_launcher(&taskDesc, i);
}
// printf("Compute Unit[%d] executed kernel %d work items [%d..%d)\n",taskDesc.m_taskId,taskDesc.m_kernelProgramId,taskDesc.m_firstWorkUnit,taskDesc.m_lastWorkUnit);
}

View File

@@ -16,39 +16,17 @@ subject to the following restrictions:
#ifndef MINICL__TASK_H
#define MINICL__TASK_H
#include "../PlatformDefinitions.h"
#include "BulletMultiThreaded/PlatformDefinitions.h"
#include "LinearMath/btScalar.h"
#include "LinearMath/btAlignedAllocator.h"
enum
{
CMD_MINICL_1= 1,
CMD_MINICL_ADDVECTOR
};
#define MINICL_MAX_ARGLENGTH (sizeof(void*))
#define MINI_CL_MAX_ARG 16
#define MINI_CL_MAX_KERNEL_NAME 256
struct float8
{
float s0;
float s1;
float s2;
float s3;
float s4;
float s5;
float s6;
float s7;
float8(float scalar)
{
s0=s1=s2=s3=s4=s5=s6=s7=scalar;
}
};
#define MINICL_MAX_ARGLENGTH 128
#define MINI_CL_MAX_ARG 8
struct MiniCLKernel;
ATTRIBUTE_ALIGNED16(struct) MiniCLTaskDesc
{
@@ -62,16 +40,19 @@ ATTRIBUTE_ALIGNED16(struct) MiniCLTaskDesc
}
}
uint32_t m_taskId;
uint32_t m_taskId;
uint32_t m_kernelProgramId;
uint32_t m_firstWorkUnit;
uint32_t m_lastWorkUnit;
uint32_t m_firstWorkUnit;
uint32_t m_lastWorkUnit;
char m_argData[MINI_CL_MAX_ARG][MINICL_MAX_ARGLENGTH];
int m_argSizes[MINI_CL_MAX_ARG];
MiniCLKernel* m_kernel;
void* m_argData[MINI_CL_MAX_ARG];
int m_argSizes[MINI_CL_MAX_ARG];
};
extern "C" int gMiniCLNumOutstandingTasks;
void processMiniCLTask(void* userPtr, void* lsMemory);
void* createMiniCLLocalStoreMemory();