This commit is contained in:
Erwin Coumans
2013-05-23 19:15:28 -07:00
38 changed files with 3222 additions and 176 deletions

View File

@@ -46,15 +46,14 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
//#endif
cl_platform_id platformId;
// if (useInterop)
// {
// m_data->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
// } else
{
m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&platformId);
b3OpenCLUtils::printPlatformInfo(platformId);
m_clData->m_clContext = b3OpenCLUtils::createContextFromType(deviceType, &ciErrNum, 0,0,preferredDeviceIndex, preferredPlatformIndex,&m_clData->m_platformId);
}
@@ -68,7 +67,7 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
m_clData->m_clQueue = clCreateCommandQueue(m_clData->m_clContext, m_clData->m_clDevice, 0, &ciErrNum);
oclCHECKERROR(ciErrNum, CL_SUCCESS);
b3OpenCLUtils::printDeviceInfo(m_clData->m_clDevice);
b3OpenCLDeviceInfo info;
b3OpenCLUtils::getDeviceInfo(m_clData->m_clDevice,&info);
m_clData->m_clDeviceName = info.m_deviceName;
@@ -78,6 +77,10 @@ void GpuDemo::initCL(int preferredDeviceIndex, int preferredPlatformIndex)
}
GpuDemoInternalData* GpuDemo::getInternalData()
{
return m_clData;
}
int GpuDemo::registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites, int largeSphereThreshold, int mediumSphereThreshold)
{

View File

@@ -38,9 +38,9 @@ public:
:useOpenCL(true),
preferredOpenCLPlatformIndex(-1),
preferredOpenCLDeviceIndex(-1),
arraySizeX(25),
arraySizeY(20),
arraySizeZ(25),
arraySizeX(30),
arraySizeY(30),
arraySizeZ(30),
m_useConcaveMesh(false),
gapX(14.3),
gapY(14.0),
@@ -67,6 +67,8 @@ public:
int registerGraphicsSphereShape(const ConstructionInfo& ci, float radius, bool usePointSprites=true, int largeSphereThreshold=100, int mediumSphereThreshold=10);
struct GpuDemoInternalData* getInternalData();
};
#endif

View File

@@ -5,6 +5,7 @@
struct GpuDemoInternalData
{
cl_platform_id m_platformId;
cl_context m_clContext;
cl_device_id m_clDevice;
cl_command_queue m_clQueue;

View File

@@ -13,6 +13,9 @@
#include "OpenGLWindow/X11OpenGLWindow.h"
#endif
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
#include "GpuDemoInternalData.h"
#include "OpenGLWindow/GLPrimitiveRenderer.h"
#include "OpenGLWindow/GLInstancingRenderer.h"
//#include "OpenGL3CoreRenderer.h"
@@ -68,7 +71,9 @@ int selectedDemo = 0;
GpuDemo::CreateFunc* allDemos[]=
{
// ConcaveCompound2Scene::MyCreateFunc,
// GpuConvexScene::MyCreateFunc,
//ConcaveSphereScene::MyCreateFunc,
GpuBoxPlaneScene::MyCreateFunc,
GpuConvexPlaneScene::MyCreateFunc,
@@ -76,7 +81,7 @@ GpuDemo::CreateFunc* allDemos[]=
GpuCompoundScene::MyCreateFunc,
GpuConvexScene::MyCreateFunc,
ConcaveSphereScene::MyCreateFunc,
@@ -322,7 +327,7 @@ sth_stash* initFont(GLPrimitiveRenderer* primRender)
void Usage()
{
printf("\nprogram.exe [--selected_demo=<int>] [--cl_device=<int>] [--benchmark] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--use_concave_mesh] [--new_batching]\n");
printf("\nprogram.exe [--selected_demo=<int>] [--cl_device=<int>] [--benchmark] [--dump_timings] [--disable_opencl] [--cl_platform=<int>] [--x_dim=<int>] [--y_dim=<num>] [--z_dim=<int>] [--x_gap=<float>] [--y_gap=<float>] [--z_gap=<float>] [--use_concave_mesh] [--new_batching]\n");
};
@@ -392,6 +397,7 @@ extern bool useNewBatchingKernel;
int main(int argc, char* argv[])
{
FILE* defaultOutput = stdout;
b3Vector3 test(1,2,3);
test.x = 1;
@@ -435,13 +441,6 @@ int main(int argc, char* argv[])
args.GetCmdLineArgument("z_gap", ci.gapZ);
printf("Demo settings:\n");
printf("x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
printf("x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ);
printf("Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex);
printf("Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex);
printf("-----------------------------------------------------\n");
#ifndef B3_NO_PROFILE
b3ProfileManager::Reset();
@@ -604,13 +603,25 @@ int main(int argc, char* argv[])
// render.init();
demo->initPhysics(ci);
printf("-----------------------------------------------------\n");
FILE* f = 0;
FILE* csvFile = 0;
FILE* detailsFile = 0;
if (benchmark)
{
gPause = false;
char fileName[1024];
char prefixFileName[1024];
char csvFileName[1024];
char detailsFileName[1024];
b3OpenCLDeviceInfo info;
b3OpenCLUtils::getDeviceInfo(demo->getInternalData()->m_clDevice,&info);
#ifdef _WIN32
SYSTEMTIME time;
@@ -624,23 +635,43 @@ int main(int argc, char* argv[])
{
printf("unknown", buf);
}
sprintf(fileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d.csv",g_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond);
printf("Open file %s\n", fileName);
sprintf(prefixFileName,"%s_%s_%s_%d_%d_%d_date_%d-%d-%d_time_%d-%d-%d",info.m_deviceName,buf,demoNames[selectedDemo],ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,time.wDay,time.wMonth,time.wYear,time.wHour,time.wMinute,time.wSecond);
#else
sprintf(fileName,"%s_%d_%d_%d.csv",g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
printf("Open file %s\n", fileName);
sprintf(prefixFileName,"%s_%d_%d_%d",info.m_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
#endif
sprintf(csvFileName,"%s.csv",prefixFileName);
sprintf(detailsFileName,"%s.txt",prefixFileName);
printf("Open csv file %s and details file %s\n", csvFileName,detailsFileName);
//GetSystemTime(&time2);
f=fopen(fileName,"w");
csvFile=fopen(csvFileName,"w");
detailsFile = fopen(detailsFileName,"w");
if (detailsFile)
defaultOutput = detailsFile;
//if (f)
// fprintf(f,"%s (%dx%dx%d=%d),\n", g_deviceName,ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ,ci.arraySizeX*ci.arraySizeY*ci.arraySizeZ);
}
printf("-----------------------------------------------------\n");
fprintf(defaultOutput,"Demo settings:\n");
fprintf(defaultOutput," SelectedDemo=%d, demoname = %s\n", selectedDemo, demo->getName());
fprintf(defaultOutput," x_dim=%d, y_dim=%d, z_dim=%d\n",ci.arraySizeX,ci.arraySizeY,ci.arraySizeZ);
fprintf(defaultOutput," x_gap=%f, y_gap=%f, z_gap=%f\n",ci.gapX,ci.gapY,ci.gapZ);
fprintf(defaultOutput,"\nOpenCL settings:\n");
fprintf(defaultOutput," Preferred cl_device index %d\n", ci.preferredOpenCLDeviceIndex);
fprintf(defaultOutput," Preferred cl_platform index%d\n", ci.preferredOpenCLPlatformIndex);
fprintf(defaultOutput,"\n");
b3OpenCLUtils::printPlatformInfo(defaultOutput, demo->getInternalData()->m_platformId);
fprintf(defaultOutput,"\n");
b3OpenCLUtils::printDeviceInfo(defaultOutput, demo->getInternalData()->m_clDevice);
fprintf(defaultOutput,"\n");
do
{
b3ProfileManager::Reset();
@@ -696,20 +727,29 @@ int main(int argc, char* argv[])
}
if (dump_timings)
b3ProfileManager::dumpAll();
if (f)
{
static int count=0;
b3ProfileManager::dumpAll(stdout);
}
if (count>2 && count<102)
if (csvFile)
{
static int frameCount=0;
if (frameCount>0)
{
DumpSimulationTime(f);
DumpSimulationTime(csvFile);
if (detailsFile)
{
fprintf(detailsFile,"\n==================================\nFrame %d:\n", frameCount);
b3ProfileManager::dumpAll(detailsFile);
}
}
if (count>=102)
if (frameCount>=102)
window->setRequestExit();
count++;
frameCount++;
}
@@ -720,8 +760,16 @@ int main(int argc, char* argv[])
demo->exitPhysics();
b3ProfileManager::CleanupMemory();
delete demo;
if (f)
fclose(f);
if (detailsFile)
{
fclose(detailsFile);
detailsFile=0;
}
if (csvFile)
{
fclose(csvFile);
csvFile=0;
}
}

View File

@@ -25,12 +25,12 @@ function createProject(vendor)
links {
"gwen",
"Bullet3Common",
"Bullet3Geometry",
"Bullet3Collision",
"Bullet3Dynamics",
"Bullet2FileLoader",
"Bullet3OpenCL_" .. vendor
"Bullet3OpenCL_" .. vendor,
"Bullet3Dynamics",
"Bullet3Collision",
"Bullet3Geometry",
"Bullet3Common",
}
@@ -89,6 +89,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("Apple")
createProject("AMD")
createProject("Intel")

View File

@@ -173,14 +173,16 @@ void ConcaveScene::createConcaveMesh(const ConstructionInfo& ci, const char* fil
f = fopen(relativeFileName,"r");
if (f)
{
fclose(f);
break;
}
}
}
if (f)
{
fclose(f);
f=0;
}
else
return;

View File

@@ -33,7 +33,7 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci)
float camPos[4]={ci.arraySizeX,ci.arraySizeY/2,ci.arraySizeZ,0};
//float camPos[4]={1,12.5,1.5,0};
m_instancingRenderer->setCameraTargetPosition(camPos);
m_instancingRenderer->setCameraDistance(40);
m_instancingRenderer->setCameraDistance(100);
char msg[1024];
@@ -44,10 +44,15 @@ void GpuConvexScene::setupScene(const ConstructionInfo& ci)
int GpuConvexScene::createDynamicsObjects(const ConstructionInfo& ci)
{
int strideInBytes = 9*sizeof(float);
/* int strideInBytes = 9*sizeof(float);
int numVertices = sizeof(barrel_vertices)/strideInBytes;
int numIndices = sizeof(barrel_indices)/sizeof(int);
return createDynamicsObjects2(ci,barrel_vertices,numVertices,barrel_indices,numIndices);
*/
int strideInBytes = 9*sizeof(float);
int numVertices = sizeof(cube_vertices)/strideInBytes;
int numIndices = sizeof(cube_indices)/sizeof(int);
return createDynamicsObjects2(ci,cube_vertices,numVertices,cube_indices,numIndices);
}
int GpuBoxPlaneScene::createDynamicsObjects(const ConstructionInfo& ci)
@@ -99,8 +104,8 @@ int GpuConvexScene::createDynamicsObjects2(const ConstructionInfo& ci, const flo
{
//mass=0.f;
}
//b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
b3Vector3 position(i*2.2,10+j*2.2,k*2.2);
b3Vector3 position((j&1)+i*2.2,1+j*2.,(j&1)+k*2.2);
//b3Vector3 position(i*2.2,10+j*1.9,k*2.2);
b3Quaternion orn(0,0,0,1);

View File

@@ -47,7 +47,7 @@ int sGlutScreenWidth = 640;
int sGlutScreenHeight = 480;
int sLastmousepos[2] = {0,0};
#include "basic_initialize/b3OpenCLUtils.h"
#include "Bullet3OpenCL/Initialize/b3OpenCLUtils.h"
cl_context g_cxMainContext;
cl_command_queue g_cqCommandQue;

View File

@@ -30,8 +30,8 @@ function createProject(vendor)
files {
"main.cpp",
"../../opencl/basic_initialize/b3OpenCLUtils.cpp",
"../../opencl/basic_initialize/b3OpenCLUtils.h",
"../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.cpp",
"../../src/Bullet3OpenCL/Initialize/b3OpenCLUtils.h",
"../../btgui/OpenGLWindow/GLInstancingRenderer.cpp",
"../../btgui/OpenGLWindow/GLInstancingRenderer.h",
"../../btgui/OpenGLWindow/GLPrimitiveRenderer.h",
@@ -78,6 +78,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("Apple")
createProject("AMD")
createProject("Intel")

View File

@@ -1171,6 +1171,7 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh
#endif /* GL_VERSION_1_1 */
/* ---------------------------------- GLU ---------------------------------- */
#define GLEW_NO_GLU
#ifndef GLEW_NO_GLU
/* this is where we can safely include GLU */

View File

@@ -35,7 +35,7 @@ subject to the following restrictions:
#include <GL/glu.h>
#else
#include <GL/gl.h>
#include <GL/glu.h>
//#include <GL/glu.h>
#endif //_WINDOWS
#endif //APPLE

View File

@@ -1,11 +1,13 @@
#include "X11OpenGLWindow.h"
#include "OpenGLInclude.h"
#include<stdio.h>
#include<stdlib.h>
#include<X11/X.h>
#include<X11/Xlib.h>
#include<GL/gl.h>
#include<GL/glx.h>
#include<GL/glu.h>
//#include<GL/glu.h>
GLint att[] = { GLX_RGBA, GLX_DEPTH_SIZE, 24, GLX_DOUBLEBUFFER, None };
@@ -47,7 +49,8 @@ struct InternalData2
X11OpenGLWindow::X11OpenGLWindow()
:m_OpenGLInitialized(false)
:m_OpenGLInitialized(false),
m_requestedExit(false)
{
m_data = new InternalData2;
}
@@ -369,12 +372,12 @@ float X11OpenGLWindow::getTimeInSeconds()
bool X11OpenGLWindow::requestedExit() const
{
return false;
return m_requestedExit;
}
void X11OpenGLWindow::setRequestExit()
{
m_requestedExit=true;
}
void X11OpenGLWindow::setRenderCallback( b3RenderCallback renderCallback)
@@ -413,3 +416,9 @@ void X11OpenGLWindow::setKeyboardCallback( b3KeyboardCallback keyboardCallback)
m_data->m_keyboardCallback = keyboardCallback;
}
b3KeyboardCallback X11OpenGLWindow::getKeyboardCallback()
{
return m_data->m_keyboardCallback;
}

View File

@@ -10,6 +10,7 @@ class X11OpenGLWindow : public b3gWindowInterface
struct InternalData2* m_data;
bool m_OpenGLInitialized;
bool m_requestedExit;
protected:
@@ -52,6 +53,7 @@ public:
virtual void setResizeCallback(b3ResizeCallback resizeCallback);
virtual void setWheelCallback(b3WheelCallback wheelCallback);
virtual void setKeyboardCallback( b3KeyboardCallback keyboardCallback);
virtual b3KeyboardCallback getKeyboardCallback();
virtual void setRenderCallback( b3RenderCallback renderCallback);

View File

@@ -1,4 +1,7 @@
function findOpenCL_clew()
return true;
end
function findOpenCL_Apple()
if os.is("macosx") then
@@ -41,6 +44,21 @@
return false
end
function initOpenCL_clew()
configuration{}
includedirs {
projectRootDir .. "src/clew"
}
defines {"B3_USE_CLEW"}
files {
projectRootDir .. "src/clew/clew.c",
projectRootDir .. "src/clew/clew.h"
}
if os.is("Linux") then
links {"dl"}
end
end
function initOpenCL_Apple()
configuration{}
includedirs {
@@ -119,6 +137,9 @@
end
function findOpenCL (vendor )
if vendor=="clew" then
return findOpenCL_clew()
end
if vendor=="AMD" then
return findOpenCL_AMD()
end
@@ -135,6 +156,9 @@
end
function initOpenCL ( vendor )
if vendor=="clew" then
initOpenCL_clew()
end
if vendor=="AMD" then
initOpenCL_AMD()
end

View File

@@ -108,7 +108,8 @@
-- include "../opencl/vector_add"
include "../btgui/Gwen"
include "../btgui/GwenOpenGLTest"
include "../test/clew"
include "../Demos3/GpuGuiInitialize"
include "../test/OpenCL/BasicInitialize"
-- include "../test/OpenCL/BroadphaseCollision"
-- include "../test/OpenCL/NarrowphaseCollision"

View File

@@ -24,6 +24,7 @@ function stringifyKernel(filenameIn, filenameOut, kernelMethod)
end
oneline = string.sub(lines,startpos,endpos)
oneline = string.gsub(oneline,"\n","")
oneline = string.gsub(oneline,"\"","\\\"");
oneline = '\"' .. oneline .. '\\n\"'
oneline = string.gsub(oneline,"\\\\n","")
oneline = oneline .. "\n"

26
build/stringify_linux.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/sh
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32Kernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/RadixSort32KernelsCL.h" --stringname="radixSort32KernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/BoundSearchKernelsCL.h" --stringname="boundSearchKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/PrefixScanKernelsCL.h" --stringname="prefixScanKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernels.cl" --headerfile="../src/Bullet3OpenCL/ParallelPrimitives/kernels/FillKernelsCL.h" --stringname="fillKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sap.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapKernels.h" --stringname="sapCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapFast.cl" --headerfile="../src/Bullet3OpenCL/BroadphaseCollision/kernels/sapFastKernels.h" --stringname="sapFastCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/sat.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satKernels.h" --stringname="satKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/satClipHullContacts.h" --stringname="satClipKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/primitiveContacts.h" --stringname="primitiveContactsKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.cl" --headerfile="../src/Bullet3OpenCL/NarrowphaseCollision/kernels/bvhTraversal.h" --stringname="bvhTraversalKernelCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/integrateKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/integrateKernel.h" --stringname="integrateKernelCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/updateAabbsKernel.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/updateAabbsKernel.h" --stringname="updateAabbsKernelCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/solverSetup.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/solverSetup.h" --stringname="solverSetupCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/solverSetup2.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/solverSetup2.h" --stringname="solverSetup2CL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/batchingKernels.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/batchingKernels.h" --stringname="batchingKernelsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/batchingKernelsNew.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/batchingKernelsNew.h" --stringname="batchingKernelsNewCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/solverUtils.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/solverUtils.h" --stringname="solverUtilsCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/solveContact.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/solveContact.h" --stringname="solveContactCL" stringify
./premake4_linux --file=stringifyKernel.lua --kernelfile="../src/Bullet3OpenCL/RigidBody//kernels/solveFriction.cl" --headerfile="../src/Bullet3OpenCL/RigidBody//kernels/solveFriction.h" --stringname="solveFrictionCL" stringify

View File

@@ -68,7 +68,11 @@ public:
mVec128 = v128;
}
#else
b3Scalar m_floats[4];
union
{
b3Scalar m_floats[4];
struct {b3Scalar x,y,z,w;};
};
#endif // B3_USE_SSE
#endif //__CELLOS_LV2__ __SPU__

View File

@@ -565,6 +565,7 @@ void b3ProfileManager::dumpRecursive(b3ProfileIterator* profileIterator, int spa
void b3ProfileManager::dumpAll()
{
b3ProfileIterator* profileIterator = 0;
@@ -576,6 +577,67 @@ void b3ProfileManager::dumpAll()
}
void b3ProfileManager::dumpRecursive(FILE* f, b3ProfileIterator* profileIterator, int spacing)
{
profileIterator->First();
if (profileIterator->Is_Done())
return;
float accumulated_time=0,parent_time = profileIterator->Is_Root() ? b3ProfileManager::Get_Time_Since_Reset() : profileIterator->Get_Current_Parent_Total_Time();
int i;
int frames_since_reset = b3ProfileManager::Get_Frame_Count_Since_Reset();
for (i=0;i<spacing;i++) fprintf(f,".");
fprintf(f,"----------------------------------\n");
for (i=0;i<spacing;i++) fprintf(f,".");
fprintf(f,"Profiling: %s (total running time: %.3f ms) ---\n", profileIterator->Get_Current_Parent_Name(), parent_time );
float totalTime = 0.f;
int numChildren = 0;
for (i = 0; !profileIterator->Is_Done(); i++,profileIterator->Next())
{
numChildren++;
float current_total_time = profileIterator->Get_Current_Total_Time();
accumulated_time += current_total_time;
float fraction = parent_time > B3_EPSILON ? (current_total_time / parent_time) * 100 : 0.f;
{
int i; for (i=0;i<spacing;i++) fprintf(f,".");
}
fprintf(f,"%d -- %s (%.2f %%) :: %.3f ms / frame (%d calls)\n",i, profileIterator->Get_Current_Name(), fraction,(current_total_time / (double)frames_since_reset),profileIterator->Get_Current_Total_Calls());
totalTime += current_total_time;
//recurse into children
}
if (parent_time < accumulated_time)
{
fprintf(f,"what's wrong\n");
}
for (i=0;i<spacing;i++)
fprintf(f,".");
fprintf(f,"%s (%.3f %%) :: %.3f ms\n", "Unaccounted:",parent_time > B3_EPSILON ? ((parent_time - accumulated_time) / parent_time) * 100 : 0.f, parent_time - accumulated_time);
for (i=0;i<numChildren;i++)
{
profileIterator->Enter_Child(i);
dumpRecursive(f,profileIterator,spacing+3);
profileIterator->Enter_Parent();
}
}
void b3ProfileManager::dumpAll(FILE* f)
{
b3ProfileIterator* profileIterator = 0;
profileIterator = b3ProfileManager::Get_Iterator();
dumpRecursive(f, profileIterator,0);
b3ProfileManager::Release_Iterator(profileIterator);
}
#endif //B3_NO_PROFILE

View File

@@ -174,9 +174,11 @@ public:
static void Release_Iterator( b3ProfileIterator * iterator ) { delete ( iterator); }
static void dumpRecursive(b3ProfileIterator* profileIterator, int spacing);
static void dumpAll();
static void dumpRecursive(FILE* f, b3ProfileIterator* profileIterator, int spacing);
static void dumpAll(FILE* f);
private:
static b3ProfileNode Root;
static b3ProfileNode * CurrentNode;

View File

@@ -221,12 +221,12 @@ inline int b3GetVersion()
#define B3_FORCE_INLINE inline
///@todo: check out alignment methods for other platforms/compilers
///#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
///#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
///#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
#define B3_ATTRIBUTE_ALIGNED16(a) a
#define B3_ATTRIBUTE_ALIGNED64(a) a
#define B3_ATTRIBUTE_ALIGNED128(a) a
#define B3_ATTRIBUTE_ALIGNED16(a) a __attribute__ ((aligned (16)))
#define B3_ATTRIBUTE_ALIGNED64(a) a __attribute__ ((aligned (64)))
#define B3_ATTRIBUTE_ALIGNED128(a) a __attribute__ ((aligned (128)))
///#define B3_ATTRIBUTE_ALIGNED16(a) a
///#define B3_ATTRIBUTE_ALIGNED64(a) a
///#define B3_ATTRIBUTE_ALIGNED128(a) a
#ifndef assert
#include <assert.h>
#endif

View File

@@ -38,8 +38,8 @@ typedef float float4 __attribute__ ((vector_size(16)));
#include <emmintrin.h>
long _maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult );
long _maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult );
long b3_maxdot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
const float4 *vertices = (const float4*) vv;
static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
@@ -422,9 +422,9 @@ long _maxdot_large( const float *vv, const float *vec, unsigned long count, floa
return maxIndex;
}
long _mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult );
long b3_mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult );
long _mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_mindot_large( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
const float4 *vertices = (const float4*) vv;
static const unsigned char indexTable[16] = {-1, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 };
@@ -816,36 +816,36 @@ long _mindot_large( const float *vv, const float *vec, unsigned long count, floa
#include <arm_neon.h>
static long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _mindot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long _mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_mindot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_mindot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult );
static long b3_mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult );
long (*_maxdot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _maxdot_large_sel;
long (*_mindot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = _mindot_large_sel;
long (*b3_maxdot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = b3_maxdot_large_sel;
long (*b3_mindot_large)( const float *vv, const float *vec, unsigned long count, float *dotResult ) = b3_mindot_large_sel;
extern "C" {int _get_cpu_capabilities( void );}
static long _maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
static long b3_maxdot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
if( _get_cpu_capabilities() & 0x2000 )
_maxdot_large = _maxdot_large_v1;
b3_maxdot_large = _maxdot_large_v1;
else
_maxdot_large = _maxdot_large_v0;
b3_maxdot_large = _maxdot_large_v0;
return _maxdot_large(vv, vec, count, dotResult);
return b3_maxdot_large(vv, vec, count, dotResult);
}
static long _mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
static long b3_mindot_large_sel( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
if( _get_cpu_capabilities() & 0x2000 )
_mindot_large = _mindot_large_v1;
b3_mindot_large = _mindot_large_v1;
else
_mindot_large = _mindot_large_v0;
b3_mindot_large = _mindot_large_v0;
return _mindot_large(vv, vec, count, dotResult);
return b3_mindot_large(vv, vec, count, dotResult);
}
@@ -853,7 +853,7 @@ static long _mindot_large_sel( const float *vv, const float *vec, unsigned long
#define vld1q_f32_aligned_postincrement( _ptr ) ({ float32x4_t _r; asm( "vld1.f32 {%0}, [%1, :128]!\n" : "=w" (_r), "+r" (_ptr) ); /*return*/ _r; })
long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_maxdot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
unsigned long i = 0;
float32x4_t vvec = vld1q_f32_aligned_postincrement( vec );
@@ -1043,7 +1043,7 @@ long _maxdot_large_v0( const float *vv, const float *vec, unsigned long count, f
}
long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_maxdot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
float32x4_t vvec = vld1q_f32_aligned_postincrement( vec );
float32x4_t vLo = vcombine_f32(vget_low_f32(vvec), vget_low_f32(vvec));
@@ -1238,7 +1238,7 @@ long _maxdot_large_v1( const float *vv, const float *vec, unsigned long count, f
}
long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_mindot_large_v0( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
unsigned long i = 0;
float32x4_t vvec = vld1q_f32_aligned_postincrement( vec );
@@ -1426,7 +1426,7 @@ long _mindot_large_v0( const float *vv, const float *vec, unsigned long count, f
return vget_lane_u32(iLo, 0);
}
long _mindot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult )
long b3_mindot_large_v1( const float *vv, const float *vec, unsigned long count, float *dotResult )
{
float32x4_t vvec = vld1q_f32_aligned_postincrement( vec );
float32x4_t vLo = vcombine_f32(vget_low_f32(vvec), vget_low_f32(vvec));

View File

@@ -106,7 +106,11 @@ public:
mVec128 = v128;
}
#else
b3Scalar m_floats[4];
union
{
b3Scalar m_floats[4];
struct {b3Scalar x,y,z,w;};
};
#endif
#endif //__CELLOS_LV2__ __SPU__

View File

@@ -16,6 +16,9 @@ subject to the following restrictions:
#ifndef B3_OPENCL_INCLUDE_H
#define B3_OPENCL_INCLUDE_H
#ifdef B3_USE_CLEW
#include "clew.h"
#else
#ifdef __APPLE__
#ifdef USE_MINICL
@@ -34,6 +37,7 @@ subject to the following restrictions:
#endif //_WIN32
#endif
#endif //__APPLE__
#endif //B3_USE_CLEW
#include <assert.h>
#include <stdio.h>

View File

@@ -51,13 +51,17 @@ static const char* spPlatformVendor =
"NVIDIA Corporation";
#elif defined(CL_PLATFORM_INTEL)
"Intel(R) Corporation";
#elif defined(B3_USE_CLEW)
"clew (OpenCL Extension Wrangler library)";
#else
"Unknown Vendor";
#endif
#ifndef CL_PLATFORM_MINI_CL
#ifdef _WIN32
#ifndef B3_USE_CLEW
#include "CL/cl_gl.h"
#endif //B3_USE_CLEW
#endif //_WIN32
#endif
@@ -84,9 +88,44 @@ void MyFatalBreakAPPLE( const char * errstr ,
}
#ifdef B3_USE_CLEW
int b3OpenCLUtils_clewInit()
{
int result = -1;
#ifdef _WIN32
const char* cl = "OpenCL.dll";
#elif defined __APPLE__
const char* cl = "/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL";
#else//presumable Linux?
//linux (tested on Ubuntu 12.10 with Catalyst 13.4 beta drivers, not that there is no symbolic link from libOpenCL.so
const char* cl = "libOpenCL.so.1";
result = clewInit(cl);
if (result != CLEW_SUCCESS)
{
cl = "libOpenCL.so";
} else
{
clewExit();
}
#endif
result = clewInit(cl);
if (result!=CLEW_SUCCESS)
printf("clewInit failed with error code %d\n",result);
else
{
printf("clewInit succesfull using %s\n",cl);
}
return result;
}
#endif
int b3OpenCLUtils_getNumPlatforms(cl_int* pErrNum)
{
#ifdef B3_USE_CLEW
b3OpenCLUtils_clewInit();
#endif
cl_platform_id pPlatforms[10] = { 0 };
@@ -110,6 +149,10 @@ const char* b3OpenCLUtils_getSdkVendorName()
cl_platform_id b3OpenCLUtils_getPlatform(int platformIndex0, cl_int* pErrNum)
{
#ifdef B3_USE_CLEW
b3OpenCLUtils_clewInit();
#endif
cl_platform_id platform = 0;
unsigned int platformIndex = (unsigned int )platformIndex0;
cl_uint numPlatforms;
@@ -145,14 +188,14 @@ void b3OpenCLUtils::getPlatformInfo(cl_platform_id platform, b3OpenCLPlatformInf
oclCHECKERROR(ciErrNum,CL_SUCCESS);
}
void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform)
void b3OpenCLUtils_printPlatformInfo(FILE* f, cl_platform_id platform)
{
b3OpenCLPlatformInfo platformInfo;
b3OpenCLUtils::getPlatformInfo (platform, &platformInfo);
printf("Platform info:\n");
printf(" CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
printf(" CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName);
printf(" CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion);
fprintf(f,"Platform info:\n");
fprintf(f," CL_PLATFORM_VENDOR: \t\t\t%s\n",platformInfo.m_platformVendor);
fprintf(f," CL_PLATFORM_NAME: \t\t\t%s\n",platformInfo.m_platformName);
fprintf(f," CL_PLATFORM_VERSION: \t\t\t%s\n",platformInfo.m_platformVersion);
}
@@ -174,6 +217,7 @@ cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d
cps[0] = CL_CONTEXT_PLATFORM;
cps[1] = (cl_context_properties)platform;
#ifdef _WIN32
#ifndef B3_USE_CLEW
if (pGLContext && pGLDC)
{
cps[2] = CL_GL_CONTEXT_KHR;
@@ -181,6 +225,7 @@ cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d
cps[4] = CL_WGL_HDC_KHR;
cps[5] = (cl_context_properties)pGLDC;
}
#endif //B3_USE_CLEW
#endif //_WIN32
num_entries = B3_MAX_CL_DEVICES;
@@ -243,6 +288,11 @@ cl_context b3OpenCLUtils_createContextFromPlatform(cl_platform_id platform, cl_d
cl_context b3OpenCLUtils_createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC , int preferredDeviceIndex, int preferredPlatformIndex, cl_platform_id* retPlatformId)
{
#ifdef B3_USE_CLEW
b3OpenCLUtils_clewInit();
#endif
cl_uint numPlatforms;
cl_context retContext = 0;
unsigned int i;
@@ -450,57 +500,57 @@ void b3OpenCLUtils::getDeviceInfo(cl_device_id device, b3OpenCLDeviceInfo* info)
}
void b3OpenCLUtils_printDeviceInfo(cl_device_id device)
void b3OpenCLUtils_printDeviceInfo(FILE* f, cl_device_id device)
{
b3OpenCLDeviceInfo info;
b3OpenCLUtils::getDeviceInfo(device,&info);
printf("Device Info:\n");
printf(" CL_DEVICE_NAME: \t\t\t%s\n", info.m_deviceName);
printf(" CL_DEVICE_VENDOR: \t\t\t%s\n", info.m_deviceVendor);
printf(" CL_DRIVER_VERSION: \t\t\t%s\n", info.m_driverVersion);
fprintf(f,"Device Info:\n");
fprintf(f," CL_DEVICE_NAME: \t\t\t%s\n", info.m_deviceName);
fprintf(f," CL_DEVICE_VENDOR: \t\t\t%s\n", info.m_deviceVendor);
fprintf(f," CL_DRIVER_VERSION: \t\t\t%s\n", info.m_driverVersion);
if( info.m_deviceType & CL_DEVICE_TYPE_CPU )
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU");
fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU");
if( info.m_deviceType & CL_DEVICE_TYPE_GPU )
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU");
fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU");
if( info.m_deviceType & CL_DEVICE_TYPE_ACCELERATOR )
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR");
fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR");
if( info.m_deviceType & CL_DEVICE_TYPE_DEFAULT )
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
fprintf(f," CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
printf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", info.m_computeUnits);
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", info.m_workitemDims);
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", info.m_workItemSize[0], info.m_workItemSize[1], info.m_workItemSize[2]);
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", info.m_workgroupSize);
printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", info.m_clockFrequency);
printf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", info.m_addressBits);
printf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_maxMemAllocSize/ (1024 * 1024)));
printf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_globalMemSize/ (1024 * 1024)));
printf(" CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", info.m_errorCorrectionSupport== CL_TRUE ? "yes" : "no");
printf(" CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", info.m_localMemType == 1 ? "local" : "global");
printf(" CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(info.m_localMemSize / 1024));
printf(" CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(info.m_constantBufferSize / 1024));
fprintf(f," CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", info.m_computeUnits);
fprintf(f," CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", info.m_workitemDims);
fprintf(f," CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", info.m_workItemSize[0], info.m_workItemSize[1], info.m_workItemSize[2]);
fprintf(f," CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", info.m_workgroupSize);
fprintf(f," CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", info.m_clockFrequency);
fprintf(f," CL_DEVICE_ADDRESS_BITS:\t\t%u\n", info.m_addressBits);
fprintf(f," CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_maxMemAllocSize/ (1024 * 1024)));
fprintf(f," CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(info.m_globalMemSize/ (1024 * 1024)));
fprintf(f," CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", info.m_errorCorrectionSupport== CL_TRUE ? "yes" : "no");
fprintf(f," CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", info.m_localMemType == 1 ? "local" : "global");
fprintf(f," CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(info.m_localMemSize / 1024));
fprintf(f," CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(info.m_constantBufferSize / 1024));
if( info.m_queueProperties & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE )
printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE");
fprintf(f," CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE");
if( info.m_queueProperties & CL_QUEUE_PROFILING_ENABLE )
printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE");
fprintf(f," CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE");
printf(" CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", info.m_imageSupport);
fprintf(f," CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", info.m_imageSupport);
printf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", info.m_maxReadImageArgs);
printf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", info.m_maxWriteImageArgs);
printf("\n CL_DEVICE_IMAGE <dim>");
printf("\t\t\t2D_MAX_WIDTH\t %u\n", info.m_image2dMaxWidth);
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", info.m_image2dMaxHeight);
printf("\t\t\t\t\t3D_MAX_WIDTH\t %u\n", info.m_image3dMaxWidth);
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", info.m_image3dMaxHeight);
printf("\t\t\t\t\t3D_MAX_DEPTH\t %u\n", info.m_image3dMaxDepth);
fprintf(f," CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", info.m_maxReadImageArgs);
fprintf(f," CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", info.m_maxWriteImageArgs);
fprintf(f,"\n CL_DEVICE_IMAGE <dim>");
fprintf(f,"\t\t\t2D_MAX_WIDTH\t %u\n", info.m_image2dMaxWidth);
fprintf(f,"\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", info.m_image2dMaxHeight);
fprintf(f,"\t\t\t\t\t3D_MAX_WIDTH\t %u\n", info.m_image3dMaxWidth);
fprintf(f,"\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", info.m_image3dMaxHeight);
fprintf(f,"\t\t\t\t\t3D_MAX_DEPTH\t %u\n", info.m_image3dMaxDepth);
if (info.m_deviceExtensions != 0)
printf("\n CL_DEVICE_EXTENSIONS:%s\n",info.m_deviceExtensions);
fprintf(f,"\n CL_DEVICE_EXTENSIONS:%s\n",info.m_deviceExtensions);
else
printf(" CL_DEVICE_EXTENSIONS: None\n");
printf(" CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>\t");
printf("CHAR %u, SHORT %u, INT %u,LONG %u, FLOAT %u, DOUBLE %u\n\n\n",
fprintf(f," CL_DEVICE_EXTENSIONS: None\n");
fprintf(f," CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>\t");
fprintf(f,"CHAR %u, SHORT %u, INT %u,LONG %u, FLOAT %u, DOUBLE %u\n\n\n",
info.m_vecWidthChar, info.m_vecWidthShort, info.m_vecWidthInt, info.m_vecWidthLong,info.m_vecWidthFloat, info.m_vecWidthDouble);

View File

@@ -36,7 +36,7 @@ int b3OpenCLUtils_getNumDevices(cl_context cxMainContext);
cl_device_id b3OpenCLUtils_getDevice(cl_context cxMainContext, int nr);
void b3OpenCLUtils_printDeviceInfo(cl_device_id device);
void b3OpenCLUtils_printDeviceInfo(FILE* f, cl_device_id device);
cl_kernel b3OpenCLUtils_compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum, cl_program prog,const char* additionalMacros);
@@ -49,7 +49,8 @@ int b3OpenCLUtils_getNumPlatforms(cl_int* pErrNum);
///get the nr'th platform, where nr is in the range [0..getNumPlatforms)
cl_platform_id b3OpenCLUtils_getPlatform(int nr, cl_int* pErrNum);
void b3OpenCLUtils_printPlatformInfo(cl_platform_id platform);
void b3OpenCLUtils_printPlatformInfo(FILE* f, cl_platform_id platform);
const char* b3OpenCLUtils_getSdkVendorName();
@@ -132,7 +133,12 @@ struct b3OpenCLUtils
static inline void printDeviceInfo(cl_device_id device)
{
b3OpenCLUtils_printDeviceInfo(device);
b3OpenCLUtils_printDeviceInfo(stdout, device);
}
static inline void printDeviceInfo(FILE* f, cl_device_id device)
{
b3OpenCLUtils_printDeviceInfo(f,device);
}
static inline cl_kernel compileCLKernelFromString( cl_context clContext,cl_device_id device, const char* kernelSource, const char* kernelName, cl_int* pErrNum=0, cl_program prog=0,const char* additionalMacros = "" )
@@ -161,7 +167,12 @@ struct b3OpenCLUtils
static inline void printPlatformInfo(cl_platform_id platform)
{
b3OpenCLUtils_printPlatformInfo(platform);
b3OpenCLUtils_printPlatformInfo(stdout, platform);
}
static inline void printPlatformInfo(FILE* f, cl_platform_id platform)
{
b3OpenCLUtils_printPlatformInfo(f,platform);
}
static inline const char* getSdkVendorName()

View File

@@ -8,6 +8,8 @@ struct b3GpuFace
b3Vector4 m_plane;
int m_indexOffset;
int m_numIndices;
int m_unusedPadding1;
int m_unusedPadding2;
};
B3_ATTRIBUTE_ALIGNED16(struct) b3ConvexPolyhedronCL

View File

@@ -22,6 +22,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("AMD")
createProject("Intel")
createProject("NVIDIA")

312
src/clew/clew.c Normal file
View File

@@ -0,0 +1,312 @@
//////////////////////////////////////////////////////////////////////////
// Copyright (c) 2009 Organic Vectory B.V.
// Written by George van Venrooij
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file license.txt)
//////////////////////////////////////////////////////////////////////////
#include "clew.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#define VC_EXTRALEAN
#include <windows.h>
typedef HMODULE CLEW_DYNLIB_HANDLE;
#define CLEW_DYNLIB_OPEN LoadLibrary
#define CLEW_DYNLIB_CLOSE FreeLibrary
#define CLEW_DYNLIB_IMPORT GetProcAddress
#else
#include <dlfcn.h>
typedef void* CLEW_DYNLIB_HANDLE;
#define CLEW_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
#define CLEW_DYNLIB_CLOSE dlclose
#define CLEW_DYNLIB_IMPORT dlsym
#endif
#include <stdlib.h>
//! \brief module handle
static CLEW_DYNLIB_HANDLE module = NULL;
// Variables holding function entry points
PFNCLGETPLATFORMIDS __clewGetPlatformIDs = NULL;
PFNCLGETPLATFORMINFO __clewGetPlatformInfo = NULL;
PFNCLGETDEVICEIDS __clewGetDeviceIDs = NULL;
PFNCLGETDEVICEINFO __clewGetDeviceInfo = NULL;
PFNCLCREATECONTEXT __clewCreateContext = NULL;
PFNCLCREATECONTEXTFROMTYPE __clewCreateContextFromType = NULL;
PFNCLRETAINCONTEXT __clewRetainContext = NULL;
PFNCLRELEASECONTEXT __clewReleaseContext = NULL;
PFNCLGETCONTEXTINFO __clewGetContextInfo = NULL;
PFNCLCREATECOMMANDQUEUE __clewCreateCommandQueue = NULL;
PFNCLRETAINCOMMANDQUEUE __clewRetainCommandQueue = NULL;
PFNCLRELEASECOMMANDQUEUE __clewReleaseCommandQueue = NULL;
PFNCLGETCOMMANDQUEUEINFO __clewGetCommandQueueInfo = NULL;
#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
PFNCLSETCOMMANDQUEUEPROPERTY __clewSetCommandQueueProperty = NULL;
#endif
PFNCLCREATEBUFFER __clewCreateBuffer = NULL;
PFNCLCREATESUBBUFFER __clewCreateSubBuffer = NULL;
PFNCLCREATEIMAGE2D __clewCreateImage2D = NULL;
PFNCLCREATEIMAGE3D __clewCreateImage3D = NULL;
PFNCLRETAINMEMOBJECT __clewRetainMemObject = NULL;
PFNCLRELEASEMEMOBJECT __clewReleaseMemObject = NULL;
PFNCLGETSUPPORTEDIMAGEFORMATS __clewGetSupportedImageFormats = NULL;
PFNCLGETMEMOBJECTINFO __clewGetMemObjectInfo = NULL;
PFNCLGETIMAGEINFO __clewGetImageInfo = NULL;
PFNCLSETMEMOBJECTDESTRUCTORCALLBACK __clewSetMemObjectDestructorCallback = NULL;
PFNCLCREATESAMPLER __clewCreateSampler = NULL;
PFNCLRETAINSAMPLER __clewRetainSampler = NULL;
PFNCLRELEASESAMPLER __clewReleaseSampler = NULL;
PFNCLGETSAMPLERINFO __clewGetSamplerInfo = NULL;
PFNCLCREATEPROGRAMWITHSOURCE __clewCreateProgramWithSource = NULL;
PFNCLCREATEPROGRAMWITHBINARY __clewCreateProgramWithBinary = NULL;
PFNCLRETAINPROGRAM __clewRetainProgram = NULL;
PFNCLRELEASEPROGRAM __clewReleaseProgram = NULL;
PFNCLBUILDPROGRAM __clewBuildProgram = NULL;
PFNCLUNLOADCOMPILER __clewUnloadCompiler = NULL;
PFNCLGETPROGRAMINFO __clewGetProgramInfo = NULL;
PFNCLGETPROGRAMBUILDINFO __clewGetProgramBuildInfo = NULL;
PFNCLCREATEKERNEL __clewCreateKernel = NULL;
PFNCLCREATEKERNELSINPROGRAM __clewCreateKernelsInProgram = NULL;
PFNCLRETAINKERNEL __clewRetainKernel = NULL;
PFNCLRELEASEKERNEL __clewReleaseKernel = NULL;
PFNCLSETKERNELARG __clewSetKernelArg = NULL;
PFNCLGETKERNELINFO __clewGetKernelInfo = NULL;
PFNCLGETKERNELWORKGROUPINFO __clewGetKernelWorkGroupInfo = NULL;
PFNCLWAITFOREVENTS __clewWaitForEvents = NULL;
PFNCLGETEVENTINFO __clewGetEventInfo = NULL;
PFNCLCREATEUSEREVENT __clewCreateUserEvent = NULL;
PFNCLRETAINEVENT __clewRetainEvent = NULL;
PFNCLRELEASEEVENT __clewReleaseEvent = NULL;
PFNCLSETUSEREVENTSTATUS __clewSetUserEventStatus = NULL;
PFNCLSETEVENTCALLBACK __clewSetEventCallback = NULL;
PFNCLGETEVENTPROFILINGINFO __clewGetEventProfilingInfo = NULL;
PFNCLFLUSH __clewFlush = NULL;
PFNCLFINISH __clewFinish = NULL;
PFNCLENQUEUEREADBUFFER __clewEnqueueReadBuffer = NULL;
PFNCLENQUEUEREADBUFFERRECT __clewEnqueueReadBufferRect = NULL;
PFNCLENQUEUEWRITEBUFFER __clewEnqueueWriteBuffer = NULL;
PFNCLENQUEUEWRITEBUFFERRECT __clewEnqueueWriteBufferRect = NULL;
PFNCLENQUEUECOPYBUFFER __clewEnqueueCopyBuffer = NULL;
PFNCLENQUEUEREADIMAGE __clewEnqueueReadImage = NULL;
PFNCLENQUEUEWRITEIMAGE __clewEnqueueWriteImage = NULL;
PFNCLENQUEUECOPYIMAGE __clewEnqueueCopyImage = NULL;
PFNCLENQUEUECOPYBUFFERRECT __clewEnqueueCopyBufferRect = NULL;
PFNCLENQUEUECOPYIMAGETOBUFFER __clewEnqueueCopyImageToBuffer = NULL;
PFNCLENQUEUECOPYBUFFERTOIMAGE __clewEnqueueCopyBufferToImage = NULL;
PFNCLENQUEUEMAPBUFFER __clewEnqueueMapBuffer = NULL;
PFNCLENQUEUEMAPIMAGE __clewEnqueueMapImage = NULL;
PFNCLENQUEUEUNMAPMEMOBJECT __clewEnqueueUnmapMemObject = NULL;
PFNCLENQUEUENDRANGEKERNEL __clewEnqueueNDRangeKernel = NULL;
PFNCLENQUEUETASK __clewEnqueueTask = NULL;
PFNCLENQUEUENATIVEKERNEL __clewEnqueueNativeKernel = NULL;
PFNCLENQUEUEMARKER __clewEnqueueMarker = NULL;
PFNCLENQUEUEWAITFOREVENTS __clewEnqueueWaitForEvents = NULL;
PFNCLENQUEUEBARRIER __clewEnqueueBarrier = NULL;
PFNCLGETEXTENSIONFUNCTIONADDRESS __clewGetExtensionFunctionAddress = NULL;
void clewExit(void)
{
if (module != NULL)
{
// Ignore errors
CLEW_DYNLIB_CLOSE(module);
module = NULL;
}
}
int clewInit(const char* path)
{
int error = 0;
// Check if already initialized
if (module != NULL)
{
return CLEW_SUCCESS;
}
// Load library
module = CLEW_DYNLIB_OPEN(path);
// Check for errors
if (module == NULL)
{
return CLEW_ERROR_OPEN_FAILED;
}
// Set unloading
error = atexit(clewExit);
if (error)
{
// Failure queuing atexit, shutdown with error
CLEW_DYNLIB_CLOSE(module);
module = NULL;
return CLEW_ERROR_ATEXIT_FAILED;
}
// Determine function entry-points
__clewGetPlatformIDs = (PFNCLGETPLATFORMIDS )CLEW_DYNLIB_IMPORT(module, "clGetPlatformIDs");
__clewGetPlatformInfo = (PFNCLGETPLATFORMINFO )CLEW_DYNLIB_IMPORT(module, "clGetPlatformInfo");
__clewGetDeviceIDs = (PFNCLGETDEVICEIDS )CLEW_DYNLIB_IMPORT(module, "clGetDeviceIDs");
__clewGetDeviceInfo = (PFNCLGETDEVICEINFO )CLEW_DYNLIB_IMPORT(module, "clGetDeviceInfo");
__clewCreateContext = (PFNCLCREATECONTEXT )CLEW_DYNLIB_IMPORT(module, "clCreateContext");
__clewCreateContextFromType = (PFNCLCREATECONTEXTFROMTYPE )CLEW_DYNLIB_IMPORT(module, "clCreateContextFromType");
__clewRetainContext = (PFNCLRETAINCONTEXT )CLEW_DYNLIB_IMPORT(module, "clRetainContext");
__clewReleaseContext = (PFNCLRELEASECONTEXT )CLEW_DYNLIB_IMPORT(module, "clReleaseContext");
__clewGetContextInfo = (PFNCLGETCONTEXTINFO )CLEW_DYNLIB_IMPORT(module, "clGetContextInfo");
__clewCreateCommandQueue = (PFNCLCREATECOMMANDQUEUE )CLEW_DYNLIB_IMPORT(module, "clCreateCommandQueue");
__clewRetainCommandQueue = (PFNCLRETAINCOMMANDQUEUE )CLEW_DYNLIB_IMPORT(module, "clRetainCommandQueue");
__clewReleaseCommandQueue = (PFNCLRELEASECOMMANDQUEUE )CLEW_DYNLIB_IMPORT(module, "clReleaseCommandQueue");
__clewGetCommandQueueInfo = (PFNCLGETCOMMANDQUEUEINFO )CLEW_DYNLIB_IMPORT(module, "clGetCommandQueueInfo");
#ifdef CL_USE_DEPRECATED_OPENCL_1_0_APIS
__clewSetCommandQueueProperty = (PFNCLSETCOMMANDQUEUEPROPERTY )CLEW_DYNLIB_IMPORT(module, "clSetCommandQueueProperty");
#endif
__clewCreateBuffer = (PFNCLCREATEBUFFER )CLEW_DYNLIB_IMPORT(module, "clCreateBuffer");
__clewCreateSubBuffer = (PFNCLCREATESUBBUFFER )CLEW_DYNLIB_IMPORT(module, "clCreateBuffer");
__clewCreateImage2D = (PFNCLCREATEIMAGE2D )CLEW_DYNLIB_IMPORT(module, "clCreateImage2D");
__clewCreateImage3D = (PFNCLCREATEIMAGE3D )CLEW_DYNLIB_IMPORT(module, "clCreateImage3D");
__clewRetainMemObject = (PFNCLRETAINMEMOBJECT )CLEW_DYNLIB_IMPORT(module, "clRetainMemObject");
__clewReleaseMemObject = (PFNCLRELEASEMEMOBJECT )CLEW_DYNLIB_IMPORT(module, "clReleaseMemObject");
__clewGetSupportedImageFormats = (PFNCLGETSUPPORTEDIMAGEFORMATS )CLEW_DYNLIB_IMPORT(module, "clGetSupportedImageFormats");
__clewGetMemObjectInfo = (PFNCLGETMEMOBJECTINFO )CLEW_DYNLIB_IMPORT(module, "clGetMemObjectInfo");
__clewGetImageInfo = (PFNCLGETIMAGEINFO )CLEW_DYNLIB_IMPORT(module, "clGetImageInfo");
__clewSetMemObjectDestructorCallback = (PFNCLSETMEMOBJECTDESTRUCTORCALLBACK)CLEW_DYNLIB_IMPORT(module, "clSetMemObjectDestructorCallback");
__clewCreateSampler = (PFNCLCREATESAMPLER )CLEW_DYNLIB_IMPORT(module, "clCreateSampler");
__clewRetainSampler = (PFNCLRETAINSAMPLER )CLEW_DYNLIB_IMPORT(module, "clRetainSampler");
__clewReleaseSampler = (PFNCLRELEASESAMPLER )CLEW_DYNLIB_IMPORT(module, "clReleaseSampler");
__clewGetSamplerInfo = (PFNCLGETSAMPLERINFO )CLEW_DYNLIB_IMPORT(module, "clGetSamplerInfo");
__clewCreateProgramWithSource = (PFNCLCREATEPROGRAMWITHSOURCE )CLEW_DYNLIB_IMPORT(module, "clCreateProgramWithSource");
__clewCreateProgramWithBinary = (PFNCLCREATEPROGRAMWITHBINARY )CLEW_DYNLIB_IMPORT(module, "clCreateProgramWithBinary");
__clewRetainProgram = (PFNCLRETAINPROGRAM )CLEW_DYNLIB_IMPORT(module, "clRetainProgram");
__clewReleaseProgram = (PFNCLRELEASEPROGRAM )CLEW_DYNLIB_IMPORT(module, "clReleaseProgram");
__clewBuildProgram = (PFNCLBUILDPROGRAM )CLEW_DYNLIB_IMPORT(module, "clBuildProgram");
__clewUnloadCompiler = (PFNCLUNLOADCOMPILER )CLEW_DYNLIB_IMPORT(module, "clUnloadCompiler");
__clewGetProgramInfo = (PFNCLGETPROGRAMINFO )CLEW_DYNLIB_IMPORT(module, "clGetProgramInfo");
__clewGetProgramBuildInfo = (PFNCLGETPROGRAMBUILDINFO )CLEW_DYNLIB_IMPORT(module, "clGetProgramBuildInfo");
__clewCreateKernel = (PFNCLCREATEKERNEL )CLEW_DYNLIB_IMPORT(module, "clCreateKernel");
__clewCreateKernelsInProgram = (PFNCLCREATEKERNELSINPROGRAM )CLEW_DYNLIB_IMPORT(module, "clCreateKernelsInProgram");
__clewRetainKernel = (PFNCLRETAINKERNEL )CLEW_DYNLIB_IMPORT(module, "clRetainKernel");
__clewReleaseKernel = (PFNCLRELEASEKERNEL )CLEW_DYNLIB_IMPORT(module, "clReleaseKernel");
__clewSetKernelArg = (PFNCLSETKERNELARG )CLEW_DYNLIB_IMPORT(module, "clSetKernelArg");
__clewGetKernelInfo = (PFNCLGETKERNELINFO )CLEW_DYNLIB_IMPORT(module, "clGetKernelInfo");
__clewGetKernelWorkGroupInfo = (PFNCLGETKERNELWORKGROUPINFO )CLEW_DYNLIB_IMPORT(module, "clGetKernelWorkGroupInfo");
__clewWaitForEvents = (PFNCLWAITFOREVENTS )CLEW_DYNLIB_IMPORT(module, "clWaitForEvents");
__clewGetEventInfo = (PFNCLGETEVENTINFO )CLEW_DYNLIB_IMPORT(module, "clGetEventInfo");
__clewCreateUserEvent = (PFNCLCREATEUSEREVENT )CLEW_DYNLIB_IMPORT(module, "clCreateUserEvent");
__clewRetainEvent = (PFNCLRETAINEVENT )CLEW_DYNLIB_IMPORT(module, "clRetainEvent");
__clewReleaseEvent = (PFNCLRELEASEEVENT )CLEW_DYNLIB_IMPORT(module, "clReleaseEvent");
__clewSetUserEventStatus = (PFNCLSETUSEREVENTSTATUS )CLEW_DYNLIB_IMPORT(module, "clSetUserEventStatus");
__clewSetEventCallback = (PFNCLSETEVENTCALLBACK )CLEW_DYNLIB_IMPORT(module, "clSetEventCallback");
__clewGetEventProfilingInfo = (PFNCLGETEVENTPROFILINGINFO )CLEW_DYNLIB_IMPORT(module, "clGetEventProfilingInfo");
__clewFlush = (PFNCLFLUSH )CLEW_DYNLIB_IMPORT(module, "clFlush");
__clewFinish = (PFNCLFINISH )CLEW_DYNLIB_IMPORT(module, "clFinish");
__clewEnqueueReadBuffer = (PFNCLENQUEUEREADBUFFER )CLEW_DYNLIB_IMPORT(module, "clEnqueueReadBuffer");
__clewEnqueueReadBufferRect = (PFNCLENQUEUEREADBUFFERRECT )CLEW_DYNLIB_IMPORT(module, "clEnqueueReadBufferRect");
__clewEnqueueWriteBuffer = (PFNCLENQUEUEWRITEBUFFER )CLEW_DYNLIB_IMPORT(module, "clEnqueueWriteBuffer");
__clewEnqueueWriteBufferRect = (PFNCLENQUEUEWRITEBUFFERRECT )CLEW_DYNLIB_IMPORT(module, "clEnqueueWriteBufferRect");
__clewEnqueueCopyBuffer = (PFNCLENQUEUECOPYBUFFER )CLEW_DYNLIB_IMPORT(module, "clEnqueueCopyBuffer");
__clewEnqueueCopyBufferRect = (PFNCLENQUEUECOPYBUFFERRECT )CLEW_DYNLIB_IMPORT(module, "clEnqueueCopyBufferRect");
__clewEnqueueReadImage = (PFNCLENQUEUEREADIMAGE )CLEW_DYNLIB_IMPORT(module, "clEnqueueReadImage");
__clewEnqueueWriteImage = (PFNCLENQUEUEWRITEIMAGE )CLEW_DYNLIB_IMPORT(module, "clEnqueueWriteImage");
__clewEnqueueCopyImage = (PFNCLENQUEUECOPYIMAGE )CLEW_DYNLIB_IMPORT(module, "clEnqueueCopyImage");
__clewEnqueueCopyImageToBuffer = (PFNCLENQUEUECOPYIMAGETOBUFFER )CLEW_DYNLIB_IMPORT(module, "clEnqueueCopyImageToBuffer");
__clewEnqueueCopyBufferToImage = (PFNCLENQUEUECOPYBUFFERTOIMAGE )CLEW_DYNLIB_IMPORT(module, "clEnqueueCopyBufferToImage");
__clewEnqueueMapBuffer = (PFNCLENQUEUEMAPBUFFER )CLEW_DYNLIB_IMPORT(module, "clEnqueueMapBuffer");
__clewEnqueueMapImage = (PFNCLENQUEUEMAPIMAGE )CLEW_DYNLIB_IMPORT(module, "clEnqueueMapImage");
__clewEnqueueUnmapMemObject = (PFNCLENQUEUEUNMAPMEMOBJECT )CLEW_DYNLIB_IMPORT(module, "clEnqueueUnmapMemObject");
__clewEnqueueNDRangeKernel = (PFNCLENQUEUENDRANGEKERNEL )CLEW_DYNLIB_IMPORT(module, "clEnqueueNDRangeKernel");
__clewEnqueueTask = (PFNCLENQUEUETASK )CLEW_DYNLIB_IMPORT(module, "clEnqueueTask");
__clewEnqueueNativeKernel = (PFNCLENQUEUENATIVEKERNEL )CLEW_DYNLIB_IMPORT(module, "clEnqueueNativeKernel");
__clewEnqueueMarker = (PFNCLENQUEUEMARKER )CLEW_DYNLIB_IMPORT(module, "clEnqueueMarker");
__clewEnqueueWaitForEvents = (PFNCLENQUEUEWAITFOREVENTS )CLEW_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents");
__clewEnqueueBarrier = (PFNCLENQUEUEBARRIER )CLEW_DYNLIB_IMPORT(module, "clEnqueueBarrier");
__clewGetExtensionFunctionAddress = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLEW_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress");
return CLEW_SUCCESS;
}
const char* clewErrorString(cl_int error)
{
static const char* strings[] =
{
// Error Codes
"CL_SUCCESS" // 0
, "CL_DEVICE_NOT_FOUND" // -1
, "CL_DEVICE_NOT_AVAILABLE" // -2
, "CL_COMPILER_NOT_AVAILABLE" // -3
, "CL_MEM_OBJECT_ALLOCATION_FAILURE" // -4
, "CL_OUT_OF_RESOURCES" // -5
, "CL_OUT_OF_HOST_MEMORY" // -6
, "CL_PROFILING_INFO_NOT_AVAILABLE" // -7
, "CL_MEM_COPY_OVERLAP" // -8
, "CL_IMAGE_FORMAT_MISMATCH" // -9
, "CL_IMAGE_FORMAT_NOT_SUPPORTED" // -10
, "CL_BUILD_PROGRAM_FAILURE" // -11
, "CL_MAP_FAILURE" // -12
, "" // -13
, "" // -14
, "" // -15
, "" // -16
, "" // -17
, "" // -18
, "" // -19
, "" // -20
, "" // -21
, "" // -22
, "" // -23
, "" // -24
, "" // -25
, "" // -26
, "" // -27
, "" // -28
, "" // -29
, "CL_INVALID_VALUE" // -30
, "CL_INVALID_DEVICE_TYPE" // -31
, "CL_INVALID_PLATFORM" // -32
, "CL_INVALID_DEVICE" // -33
, "CL_INVALID_CONTEXT" // -34
, "CL_INVALID_QUEUE_PROPERTIES" // -35
, "CL_INVALID_COMMAND_QUEUE" // -36
, "CL_INVALID_HOST_PTR" // -37
, "CL_INVALID_MEM_OBJECT" // -38
, "CL_INVALID_IMAGE_FORMAT_DESCRIPTOR" // -39
, "CL_INVALID_IMAGE_SIZE" // -40
, "CL_INVALID_SAMPLER" // -41
, "CL_INVALID_BINARY" // -42
, "CL_INVALID_BUILD_OPTIONS" // -43
, "CL_INVALID_PROGRAM" // -44
, "CL_INVALID_PROGRAM_EXECUTABLE" // -45
, "CL_INVALID_KERNEL_NAME" // -46
, "CL_INVALID_KERNEL_DEFINITION" // -47
, "CL_INVALID_KERNEL" // -48
, "CL_INVALID_ARG_INDEX" // -49
, "CL_INVALID_ARG_VALUE" // -50
, "CL_INVALID_ARG_SIZE" // -51
, "CL_INVALID_KERNEL_ARGS" // -52
, "CL_INVALID_WORK_DIMENSION" // -53
, "CL_INVALID_WORK_GROUP_SIZE" // -54
, "CL_INVALID_WORK_ITEM_SIZE" // -55
, "CL_INVALID_GLOBAL_OFFSET" // -56
, "CL_INVALID_EVENT_WAIT_LIST" // -57
, "CL_INVALID_EVENT" // -58
, "CL_INVALID_OPERATION" // -59
, "CL_INVALID_GL_OBJECT" // -60
, "CL_INVALID_BUFFER_SIZE" // -61
, "CL_INVALID_MIP_LEVEL" // -62
, "CL_INVALID_GLOBAL_WORK_SIZE" // -63
};
return strings[-error];
}

2396
src/clew/clew.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -24,7 +24,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("Apple")
createProject("AMD")
createProject("Intel")

View File

@@ -30,6 +30,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("Apple")
createProject("AMD")
createProject("Intel")

View File

@@ -35,6 +35,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("AMD")
createProject("Intel")
createProject("NVIDIA")

View File

@@ -667,7 +667,7 @@ int main( int argc, char** argv)
int result;
int devId = 0;
g_device = b3OpenCLUtils_getDevice(g_cxMainContext,devId);
b3OpenCLUtils_printDeviceInfo(g_device);
b3OpenCLUtils_printDeviceInfo(stdout, g_device);
// create a command-queue
g_cqCommandQueue = clCreateCommandQueue(g_cxMainContext, g_device, 0, &ciErrNum);
oclCHECKERROR(ciErrNum, CL_SUCCESS);

View File

@@ -34,6 +34,7 @@ function createProject(vendor)
end
end
createProject("clew")
createProject("AMD")
createProject("Intel")
createProject("NVIDIA")

41
test/clew/clewTest.cpp Normal file
View File

@@ -0,0 +1,41 @@
// clewTest.cpp : Defines the entry point for the console application.
//
#include "clew.h"
#include <stdio.h>
int main(int argc, char* argv[])
{
int result = -1;
#ifdef _WIN32
const char* cl = "OpenCL.dll";
#elif defined __APPLE__
const char* cl = "/System/Library/Frameworks/OpenCL.framework/Versions/Current/OpenCL";
#else//presumable Linux?
//linux (tested on Ubuntu 12.10 with Catalyst 13.4 beta drivers, not that there is no symbolic link from libOpenCL.so
const char* cl = "libOpenCL.so.1";
result = clewInit(cl);
if (result != CLEW_SUCCESS)
{
cl = "libOpenCL.so";
} else
{
clewExit();
}
#endif
result = clewInit(cl);
if (result!=CLEW_SUCCESS)
printf("clewInit failed with error code %d\n",result);
else
{
printf("clewInit succesfull using %s\n",cl);
//some test and then
clewExit();
}
return 0;
}

27
test/clew/premake4.lua Normal file
View File

@@ -0,0 +1,27 @@
project ("Test_clew")
language "C++"
kind "ConsoleApp"
targetdir "../../bin"
includedirs {"../../src/clew"}
if os.is("Windows") then
defines { "WIN32" }
links {"Ws2_32","Winmm"}
end
if os.is("Linux") then
links {"dl"}
end
if os.is("MacOSX") then
end
files {
"clewTest.cpp",
"../../src/clew/clew.c",
"../../src/clew/clew.h"
}