Remove btSoftBodySolver_CPU.*
Move btSoftBodySolverData.h to src/BulletMultiThreaded/GpuSoftBodySolvers/Shared/btSoftBodySolverData.h Attempt to re-enable MiniCL version of OpenCLClothDemo (cloth-capsule collision still broken) Add optional OpenCL acceleration to SerializeDemo (just for cloth)
This commit is contained in:
@@ -31,7 +31,7 @@ class btDX11SIMDAwareSoftBodySolver;
|
||||
|
||||
#include "BulletSoftBody/btSoftBodySolvers.h"
|
||||
#include "BulletSoftBody/btDefaultSoftBodySolver.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolver_CPU.h"
|
||||
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/DX11/btSoftBodySolver_DX11.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/DX11/btSoftBodySolver_DX11SIMDAware.h"
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ IF (USE_GLUT)
|
||||
LINK_LIBRARIES(
|
||||
OpenGLSupport
|
||||
BulletSoftBodySolvers_OpenCL_Mini
|
||||
BulletSoftBodySolvers_CPU
|
||||
MiniCL
|
||||
BulletMultiThreaded
|
||||
BulletSoftBody
|
||||
|
||||
@@ -18,15 +18,18 @@ subject to the following restrictions:
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef USE_MINICL
|
||||
#define USE_SIMDAWARE_SOLVER
|
||||
#ifndef __APPLE__
|
||||
//#define USE_SIMDAWARE_SOLVER
|
||||
#endif
|
||||
|
||||
#if !defined (__APPLE__)
|
||||
#define USE_GPU_SOLVER
|
||||
#if defined (_WIN32)
|
||||
#if defined (_WIN32) && !defined(USE_MINICL)
|
||||
#define USE_GPU_COPY //only tested on Windows
|
||||
#endif //_WIN32
|
||||
#endif //__APPLE__
|
||||
#endif //USE_MINICL
|
||||
#endif //_WIN32 && !USE_MINICL
|
||||
#endif //!__APPLE__
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -43,13 +46,7 @@ const int numFlags = 5;
|
||||
const int clothWidth = 40;
|
||||
const int clothHeight = 60;//60;
|
||||
float _windAngle = 1.0;//0.4;
|
||||
float _windStrength = 10.;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
float _windStrength = 0.;
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +54,6 @@ float _windStrength = 10.;
|
||||
#include "LinearMath/btHashMap.h"
|
||||
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
|
||||
#include "vectormath/vmInclude.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/CPU/btSoftBodySolver_CPU.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCLSIMDAware.h"
|
||||
#include "BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolverVertexBuffer_OpenGL.h"
|
||||
@@ -95,7 +91,6 @@ btCollisionDispatcher* m_dispatcher;
|
||||
btConstraintSolver* m_solver;
|
||||
btDefaultCollisionConfiguration* m_collisionConfiguration;
|
||||
|
||||
btCPUSoftBodySolver *g_cpuSolver = NULL;
|
||||
btOpenCLSoftBodySolver *g_openCLSolver = NULL;
|
||||
btOpenCLSoftBodySolverSIMDAware *g_openCLSIMDSolver = NULL;
|
||||
|
||||
@@ -368,9 +363,8 @@ void initBullet(void)
|
||||
#endif // #ifdef USE_GPU_COPY
|
||||
#endif
|
||||
#else
|
||||
g_cpuSolver = new btCPUSoftBodySolver;
|
||||
g_solver = g_cpuSolver;
|
||||
g_softBodyOutput = new btSoftBodySolverOutputCPUtoCPU;
|
||||
g_openCLSolver = new btOpenCLSoftBodySolver( g_cqCommandQue, g_cxMainContext );
|
||||
g_solver = g_openCLSolver;
|
||||
#endif
|
||||
|
||||
//m_collisionConfiguration = new btDefaultCollisionConfiguration();
|
||||
@@ -471,11 +465,11 @@ void initBullet(void)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USE_GPU_SOLVER
|
||||
//#ifdef USE_GPU_SOLVER
|
||||
createFlag( *g_openCLSolver, clothWidth, clothHeight, m_flags );
|
||||
#else
|
||||
createFlag( *g_cpuSolver, clothWidth, clothHeight, m_flags );
|
||||
#endif
|
||||
//#else
|
||||
|
||||
//#endif
|
||||
|
||||
// Create output buffer descriptions for ecah flag
|
||||
// These describe where the simulation should send output data to
|
||||
@@ -544,7 +538,7 @@ void doFlags()
|
||||
//debugDraw.setDebugMode(btIDebugDraw::DBG_DrawWireframe);
|
||||
//g_solver->copyBackToSoftBodies();
|
||||
|
||||
//m_dynamicsWorld->debugDrawWorld();
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
|
||||
}
|
||||
|
||||
@@ -607,8 +601,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
goGL();
|
||||
|
||||
if( g_cpuSolver )
|
||||
delete g_cpuSolver;
|
||||
if( g_openCLSolver )
|
||||
delete g_openCLSolver;
|
||||
if( g_openCLSIMDSolver )
|
||||
|
||||
131
Demos/SerializeDemo/AMD/CMakeLists.txt
Normal file
131
Demos/SerializeDemo/AMD/CMakeLists.txt
Normal file
@@ -0,0 +1,131 @@
|
||||
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL
|
||||
${AMD_OPENCL_INCLUDES}
|
||||
)
|
||||
|
||||
ADD_DEFINITIONS(-DDESERIALIZE_SOFT_BODIES)
|
||||
ADD_DEFINITIONS(-DUSE_AMD_OPENCL)
|
||||
ADD_DEFINITIONS(-DCL_PLATFORM_AMD)
|
||||
IF (CMAKE_CL_64)
|
||||
SET(CMAK_GLEW_LIBRARY
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew64.lib )
|
||||
ELSE(CMAKE_CL_64)
|
||||
SET(CMAK_GLEW_LIBRARY ${BULLET_PHYSICS_SOURCE_DIR}/Glut/glew32.lib )
|
||||
ENDIF(CMAKE_CL_64)
|
||||
|
||||
|
||||
IF (USE_GLUT)
|
||||
LINK_LIBRARIES(
|
||||
OpenGLSupport
|
||||
BulletWorldImporter
|
||||
BulletSoftBody
|
||||
BulletDynamics
|
||||
BulletCollision
|
||||
BulletFileLoader
|
||||
LinearMath
|
||||
BulletSoftBodySolvers_OpenCL_AMD
|
||||
BulletMultiThreaded
|
||||
${GLUT_glut_LIBRARY}
|
||||
${OPENGL_gl_LIBRARY}
|
||||
${OPENGL_glu_LIBRARY}
|
||||
${CMAK_GLEW_LIBRARY}
|
||||
${CMAKE_ATISTREAMSDK_LIBPATH}/OpenCL.lib
|
||||
)
|
||||
|
||||
IF (WIN32)
|
||||
ADD_EXECUTABLE(AppSerializeDemo_AMD
|
||||
../main.cpp
|
||||
../SerializeDemo.cpp
|
||||
../SerializeDemo.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/clew.c
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/clew.h
|
||||
|
||||
)
|
||||
ELSE()
|
||||
ADD_EXECUTABLE(AppSerializeDemo_AMD
|
||||
../main.cpp
|
||||
../SerializeDemo.cpp
|
||||
../SerializeDemo.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/clew.c
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/clew.h
|
||||
)
|
||||
ENDIF()
|
||||
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||
IF (WIN32)
|
||||
IF (CMAKE_CL_64)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET AppSerializeDemo_AMD
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/glut64.dll ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
ELSE(CMAKE_CL_64)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET AppSerializeDemo_AMD
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/GLUT32.DLL ${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
ENDIF(CMAKE_CL_64)
|
||||
ENDIF(WIN32)
|
||||
ENDIF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES)
|
||||
|
||||
ELSE (USE_GLUT)
|
||||
|
||||
LINK_LIBRARIES(
|
||||
OpenGLSupport
|
||||
BulletWorldImporter
|
||||
BulletSoftBody
|
||||
BulletDynamics
|
||||
BulletCollision
|
||||
BulletFileLoader
|
||||
LinearMath
|
||||
BulletSoftBodySolvers_OpenCL_AMD
|
||||
BulletMultiThreaded
|
||||
${OPENGL_gl_LIBRARY}
|
||||
${OPENGL_glu_LIBRARY}
|
||||
${CMAK_GLEW_LIBRARY}
|
||||
${CMAKE_ATISTREAMSDK_LIBPATH}/OpenCL.lib
|
||||
)
|
||||
|
||||
ADD_EXECUTABLE(AppSerializeDemo_AMD
|
||||
WIN32
|
||||
../../OpenGL/Win32AppMain.cpp
|
||||
../Win32SerializeDemo.cpp
|
||||
../SerializeDemo.cpp
|
||||
../SerializeDemo.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/msvc/bullet.rc
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.h
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclUtils.cpp
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/SharedOpenCL/btOclCommon.cpp
|
||||
)
|
||||
ENDIF (USE_GLUT)
|
||||
|
||||
IF (NOT INTERNAL_CREATE_DISTRIBUTABLE_MSVC_PROJECTFILES AND NOT INTERNAL_UPDATE_SERIALIZATION_STRUCTURES)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
TARGET AppSerializeDemo_AMD
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${BULLET_PHYSICS_SOURCE_DIR}/Demos/SerializeDemo/testFile.bullet ${CMAKE_CURRENT_BINARY_DIR}/testFile.bullet
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
|
||||
IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo_AMD PROPERTIES DEBUG_POSTFIX "_Debug")
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo_AMD PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo_AMD PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
|
||||
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
65
Demos/SerializeDemo/AMD/premake4.lua
Normal file
65
Demos/SerializeDemo/AMD/premake4.lua
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
hasCL = findOpenCL_AMD()
|
||||
|
||||
if (hasCL) then
|
||||
|
||||
project "AppOpenCLClothDemo_AMD"
|
||||
|
||||
defines { "USE_AMD_OPENCL","CL_PLATFORM_AMD"}
|
||||
|
||||
initOpenCL_AMD()
|
||||
|
||||
language "C++"
|
||||
|
||||
kind "ConsoleApp"
|
||||
targetdir "../../.."
|
||||
|
||||
libdirs {"../../../Glut"}
|
||||
|
||||
links {
|
||||
"LinearMath",
|
||||
"BulletCollision",
|
||||
"BulletDynamics",
|
||||
"BulletSoftBody",
|
||||
"BulletSoftBodySolvers_OpenCL_AMD",
|
||||
"opengl32"
|
||||
}
|
||||
|
||||
configuration "x64"
|
||||
links {
|
||||
"glut64",
|
||||
"glew64"
|
||||
}
|
||||
configuration "x32"
|
||||
links {
|
||||
"glut32",
|
||||
"glew32"
|
||||
}
|
||||
|
||||
configuration{}
|
||||
|
||||
|
||||
includedirs {
|
||||
"../../../src",
|
||||
"../../../Glut",
|
||||
"../../SharedOpenCL",
|
||||
"../../OpenGL"
|
||||
}
|
||||
|
||||
files {
|
||||
"../cl_cloth_demo.cpp",
|
||||
"../../SharedOpenCL/btOclUtils.h",
|
||||
"../../SharedOpenCL/btOclCommon.h",
|
||||
"../../SharedOpenCL/btOclUtils.cpp",
|
||||
"../../SharedOpenCL/btOclCommon.cpp",
|
||||
"../../OpenGL/GLDebugDrawer.cpp",
|
||||
"../../OpenGL/stb_image.cpp",
|
||||
"../../OpenGL/stb_image.h",
|
||||
"../gl_win.cpp",
|
||||
"../clstuff.cpp",
|
||||
"../clstuff.h",
|
||||
"../gl_win.h",
|
||||
"../cloth.h"
|
||||
}
|
||||
|
||||
end
|
||||
@@ -11,6 +11,10 @@ SET(GLUT_ROOT ${BULLET_PHYSICS_SOURCE_DIR}/Glut)
|
||||
# You shouldn't have to modify anything below this line
|
||||
########################################################
|
||||
|
||||
IF(BUILD_AMD_OPENCL_DEMOS)
|
||||
SUBDIRS(AMD)
|
||||
ENDIF()
|
||||
|
||||
INCLUDE_DIRECTORIES(
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/src
|
||||
${BULLET_PHYSICS_SOURCE_DIR}/Demos/OpenGL
|
||||
@@ -86,4 +90,6 @@ IF (INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo PROPERTIES DEBUG_POSTFIX "_Debug")
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo PROPERTIES MINSIZEREL_POSTFIX "_MinsizeRel")
|
||||
SET_TARGET_PROPERTIES(AppSerializeDemo PROPERTIES RELWITHDEBINFO_POSTFIX "_RelWithDebugInfo")
|
||||
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
ENDIF(INTERNAL_ADD_POSTFIX_EXECUTABLE_NAMES)
|
||||
|
||||
|
||||
|
||||
@@ -51,12 +51,26 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
#ifdef DESERIALIZE_SOFT_BODIES
|
||||
#include "BulletSoftBody/btSoftBodySolvers.h"
|
||||
|
||||
|
||||
#ifdef USE_AMD_OPENCL
|
||||
#include <BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCL.h>
|
||||
#include <BulletMultiThreaded/GpuSoftBodySolvers/OpenCL/btSoftBodySolver_OpenCLSIMDAware.h>
|
||||
extern cl_context g_cxMainContext;
|
||||
extern cl_device_id g_cdDevice;
|
||||
extern cl_command_queue g_cqCommandQue;
|
||||
#endif
|
||||
|
||||
btSoftBodySolver* fSoftBodySolver=0;
|
||||
|
||||
#include "BulletSoftBody/btSoftBodyHelpers.h"
|
||||
#include "BulletSoftBody/btSoftRigidDynamicsWorld.h"
|
||||
#include "BulletSoftBody/btSoftBodyRigidBodyCollisionConfiguration.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
void SerializeDemo::clientMoveAndDisplay()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -69,8 +83,27 @@ void SerializeDemo::clientMoveAndDisplay()
|
||||
{
|
||||
|
||||
m_dynamicsWorld->stepSimulation(ms / 1000000.f);
|
||||
//optional but useful: debug drawing
|
||||
|
||||
if (fSoftBodySolver)
|
||||
fSoftBodySolver->copyBackToSoftBodies();
|
||||
|
||||
m_dynamicsWorld->debugDrawWorld();
|
||||
|
||||
if (m_dynamicsWorld->getWorldType()==BT_SOFT_RIGID_DYNAMICS_WORLD)
|
||||
{
|
||||
//optional but useful: debug drawing
|
||||
btSoftRigidDynamicsWorld* softWorld = (btSoftRigidDynamicsWorld*)m_dynamicsWorld;
|
||||
|
||||
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
|
||||
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||
{
|
||||
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
|
||||
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderme();
|
||||
@@ -87,6 +120,22 @@ void SerializeDemo::displayCallback(void) {
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (m_dynamicsWorld->getWorldType()==BT_SOFT_RIGID_DYNAMICS_WORLD)
|
||||
{
|
||||
//optional but useful: debug drawing
|
||||
btSoftRigidDynamicsWorld* softWorld = (btSoftRigidDynamicsWorld*)m_dynamicsWorld;
|
||||
|
||||
for ( int i=0;i<softWorld->getSoftBodyArray().size();i++)
|
||||
{
|
||||
btSoftBody* psb=(btSoftBody*)softWorld->getSoftBodyArray()[i];
|
||||
if (softWorld->getDebugDrawer() && !(softWorld->getDebugDrawer()->getDebugMode() & (btIDebugDraw::DBG_DrawWireframe)))
|
||||
{
|
||||
btSoftBodyHelpers::DrawFrame(psb,softWorld->getDebugDrawer());
|
||||
btSoftBodyHelpers::Draw(psb,softWorld->getDebugDrawer(),softWorld->getDrawFlags());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
renderme();
|
||||
|
||||
//optional but useful: debug drawing to detect problems
|
||||
@@ -97,7 +146,12 @@ void SerializeDemo::displayCallback(void) {
|
||||
swapBuffers();
|
||||
}
|
||||
|
||||
|
||||
enum SolverType
|
||||
{
|
||||
kSolverAccelerationOpenCL_CPU = 1,
|
||||
kSolverAccelerationOpenCL_GPU = 2,
|
||||
kSolverAccelerationNone = 3
|
||||
};
|
||||
|
||||
|
||||
void SerializeDemo::setupEmptyDynamicsWorld()
|
||||
@@ -123,7 +177,62 @@ void SerializeDemo::setupEmptyDynamicsWorld()
|
||||
m_solver = sol;
|
||||
|
||||
#ifdef DESERIALIZE_SOFT_BODIES
|
||||
btSoftRigidDynamicsWorld* world = new btSoftRigidDynamicsWorld(m_dispatcher,m_broadphase,m_solver,m_collisionConfiguration);
|
||||
|
||||
|
||||
|
||||
#ifdef USE_AMD_OPENCL
|
||||
|
||||
int solverAccel = kSolverAccelerationOpenCL_GPU;
|
||||
|
||||
if ( 1 ) {
|
||||
switch (solverAccel)
|
||||
{
|
||||
case kSolverAccelerationOpenCL_GPU:
|
||||
{
|
||||
fSoftBodySolver
|
||||
= new btOpenCLSoftBodySolverSIMDAware( g_cqCommandQue,
|
||||
g_cxMainContext );
|
||||
// fSoftBodySolver = new btOpenCLSoftBodySolver( g_cqCommandQue, g_cxMainContext);
|
||||
|
||||
/*if (!fSoftBodySolver->checkInitialized())
|
||||
{
|
||||
btAssert(0);
|
||||
delete fSoftBodySolver;
|
||||
fSoftBodySolver = NULL;
|
||||
}
|
||||
*/
|
||||
|
||||
break;
|
||||
}
|
||||
case kSolverAccelerationOpenCL_CPU:
|
||||
{
|
||||
//fSoftBodySolver = new btCPUSoftBodySolver();
|
||||
break;
|
||||
};
|
||||
case kSolverAccelerationNone:
|
||||
default:
|
||||
{
|
||||
fSoftBodySolver = NULL;
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( solverAccel != kSolverAccelerationNone )
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
fSoftBodySolver = NULL;
|
||||
}
|
||||
#else
|
||||
|
||||
fSoftBodySolver = NULL;
|
||||
#endif
|
||||
|
||||
btSoftRigidDynamicsWorld* world = new btSoftRigidDynamicsWorld(m_dispatcher, m_broadphase, m_solver,
|
||||
m_collisionConfiguration, fSoftBodySolver);
|
||||
m_dynamicsWorld = world;
|
||||
//world->setDrawFlags(world->getDrawFlags()^fDrawFlags::Clusters);
|
||||
#else
|
||||
@@ -510,6 +619,7 @@ SerializeDemo::~SerializeDemo()
|
||||
|
||||
void SerializeDemo::initPhysics()
|
||||
{
|
||||
m_idle = true;
|
||||
setTexturing(true);
|
||||
setShadows(true);
|
||||
|
||||
|
||||
@@ -19,69 +19,93 @@ subject to the following restrictions:
|
||||
#include "btBulletDynamicsCommon.h"
|
||||
#include "LinearMath/btHashMap.h"
|
||||
|
||||
class OurValue
|
||||
{
|
||||
int m_uid;
|
||||
|
||||
public:
|
||||
OurValue(const btVector3& initialPos)
|
||||
:m_position(initialPos)
|
||||
{
|
||||
static int gUid=0;
|
||||
m_uid=gUid;
|
||||
gUid++;
|
||||
}
|
||||
|
||||
btVector3 m_position;
|
||||
int getUid() const
|
||||
{
|
||||
return m_uid;
|
||||
}
|
||||
};
|
||||
#ifdef USE_AMD_OPENCL
|
||||
|
||||
#ifdef _DEBUG
|
||||
bool bDebug = true;
|
||||
#else
|
||||
bool bDebug = false;
|
||||
#endif
|
||||
|
||||
|
||||
#include "btOclCommon.h"
|
||||
#include "btOclUtils.h"
|
||||
#include <LinearMath/btScalar.h>
|
||||
|
||||
cl_context g_cxMainContext;
|
||||
cl_device_id g_cdDevice;
|
||||
cl_command_queue g_cqCommandQue;
|
||||
|
||||
|
||||
// Returns true if OpenCL is initialized properly, false otherwise.
|
||||
bool initCL( void* glCtx, void* glDC )
|
||||
{
|
||||
int ciErrNum = 0;
|
||||
|
||||
#ifdef BT_USE_CLEW
|
||||
ciErrNum = clewInit( "OpenCL.dll" );
|
||||
if ( ciErrNum != CLEW_SUCCESS ) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(CL_PLATFORM_MINI_CL)
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
|
||||
#elif defined(CL_PLATFORM_AMD)
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||
#elif defined(CL_PLATFORM_NVIDIA)
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_GPU;
|
||||
#else
|
||||
cl_device_type deviceType = CL_DEVICE_TYPE_CPU;
|
||||
#endif
|
||||
|
||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_ALL, &ciErrNum);
|
||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_GPU, &ciErrNum);
|
||||
//g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_CPU, &ciErrNum);
|
||||
//try CL_DEVICE_TYPE_DEBUG for sequential, non-threaded execution, when using MiniCL on CPU, it gives a full callstack at the crash in the kernel
|
||||
//#ifdef USE_MINICL
|
||||
// g_cxMainContext = btOclCommon::createContextFromType(CL_DEVICE_TYPE_DEBUG, &ciErrNum);
|
||||
//#else
|
||||
g_cxMainContext = btOclCommon::createContextFromType(deviceType, &ciErrNum, glCtx, glDC);
|
||||
//#endif
|
||||
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
g_cdDevice = btOclGetMaxFlopsDev(g_cxMainContext);
|
||||
|
||||
if ( bDebug ) {
|
||||
btOclPrintDevInfo(g_cdDevice);
|
||||
}
|
||||
|
||||
// create a command-queue
|
||||
g_cqCommandQue = clCreateCommandQueue(g_cxMainContext, g_cdDevice, 0, &ciErrNum);
|
||||
oclCHECKERROR(ciErrNum, CL_SUCCESS);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif //#ifdef USE_AMD_OPENCL
|
||||
|
||||
|
||||
int main(int argc,char** argv)
|
||||
{
|
||||
GLDebugDrawer gDebugDrawer;
|
||||
#ifdef USE_AMD_OPENCL
|
||||
bool initialized = initCL(0,0);
|
||||
btAssert(initialized);
|
||||
#endif //USE_AMD_OPENCL
|
||||
|
||||
///testing the btHashMap
|
||||
btHashMap<btHashKey<OurValue>,OurValue> map;
|
||||
|
||||
OurValue value1(btVector3(2,3,4));
|
||||
btHashKey<OurValue> key1(value1.getUid());
|
||||
map.insert(key1,value1);
|
||||
|
||||
|
||||
OurValue value2(btVector3(5,6,7));
|
||||
btHashKey<OurValue> key2(value2.getUid());
|
||||
map.insert(key2,value2);
|
||||
|
||||
|
||||
{
|
||||
OurValue value3(btVector3(7,8,9));
|
||||
btHashKey<OurValue> key3(value3.getUid());
|
||||
map.insert(key3,value3);
|
||||
}
|
||||
|
||||
|
||||
map.remove(key2);
|
||||
|
||||
// const OurValue* ourPtr = map.find(key1);
|
||||
// for (int i=0;i<map.size();i++)
|
||||
// {
|
||||
// OurValue* tmp = map.getAtIndex(i);
|
||||
// //printf("tmp value=%f,%f,%f\n",tmp->m_position.getX(),tmp->m_position.getY(),tmp->m_position.getZ());
|
||||
// }
|
||||
|
||||
SerializeDemo ccdDemo;
|
||||
ccdDemo.initPhysics();
|
||||
ccdDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||
SerializeDemo serializeDemo;
|
||||
serializeDemo.initPhysics();
|
||||
serializeDemo.getDynamicsWorld()->setDebugDrawer(&gDebugDrawer);
|
||||
|
||||
|
||||
#ifdef CHECK_MEMORY_LEAKS
|
||||
ccdDemo.exitPhysics();
|
||||
serializeDemo.exitPhysics();
|
||||
#else
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.org",&ccdDemo);
|
||||
return glutmain(argc, argv,640,480,"Bullet Physics Demo. http://bulletphysics.org",&serializeDemo);
|
||||
#endif
|
||||
|
||||
//default glut doesn't return from mainloop
|
||||
|
||||
Binary file not shown.
@@ -18,7 +18,7 @@ subject to the following restrictions:
|
||||
#include "btOclCommon.h"
|
||||
|
||||
|
||||
static const char* spPlatformVendor =
|
||||
static char* spPlatformVendor =
|
||||
#if defined(CL_PLATFORM_MINI_CL)
|
||||
"MiniCL, SCEA";
|
||||
#elif defined(CL_PLATFORM_INTEL)
|
||||
@@ -37,6 +37,7 @@ static const char* spPlatformVendor =
|
||||
#endif //_WIN32
|
||||
#endif
|
||||
|
||||
|
||||
cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLContext, void* pGLDC )
|
||||
{
|
||||
cl_uint numPlatforms;
|
||||
@@ -91,8 +92,9 @@ cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int*
|
||||
0,
|
||||
0
|
||||
};
|
||||
#ifndef CL_PLATFORM_MINI_CL
|
||||
#ifndef CL_PLATFORM_MINI_CL
|
||||
#ifdef _WIN32
|
||||
#ifndef BT_USE_CLEW
|
||||
// If we have a gl context then enable interop
|
||||
if( pGLContext )
|
||||
{
|
||||
@@ -101,7 +103,8 @@ cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int*
|
||||
cps[4] = CL_WGL_HDC_KHR;
|
||||
cps[5] = (cl_context_properties)pGLDC;
|
||||
}
|
||||
#endif
|
||||
#endif // DONT_USE_CLEW
|
||||
#endif //_WIN32
|
||||
#endif //CL_PLATFORM_MINI_CL
|
||||
|
||||
/* Use NULL for backward compatibility */
|
||||
@@ -115,3 +118,4 @@ cl_context btOclCommon::createContextFromType(cl_device_type deviceType, cl_int*
|
||||
return retContext;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,20 +16,7 @@ subject to the following restrictions:
|
||||
#ifndef BTOCLCOMMON_H
|
||||
#define BTOCLCOMMON_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
#ifdef USE_MINICL
|
||||
#include <MiniCL/cl.h>
|
||||
#else
|
||||
#include <OpenCL/cl.h>
|
||||
#endif
|
||||
#else
|
||||
#ifdef USE_MINICL
|
||||
#include <MiniCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif
|
||||
#endif //__APPLE__
|
||||
|
||||
#include "btOclUtils.h"
|
||||
|
||||
class btOclCommon
|
||||
{
|
||||
@@ -38,8 +25,9 @@ public:
|
||||
// to have to understand GL types.
|
||||
// It is a HGLRC in _WIN32 or a GLXContext otherwise.
|
||||
static cl_context createContextFromType(cl_device_type deviceType, cl_int* pErrNum, void* pGLCtx = 0, void* pGLDC = 0);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif // BTOCLCOMMON_H
|
||||
#endif // BTOCLCOMMON_H
|
||||
|
||||
@@ -13,11 +13,14 @@ subject to the following restrictions:
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define myprintf printf
|
||||
|
||||
|
||||
|
||||
#include "btOclUtils.h"
|
||||
@@ -56,92 +59,6 @@ cl_device_id btOclGetDev(cl_context cxMainContext, unsigned int nr)
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//! Gets the id of device with maximal FLOPS from the context
|
||||
//!
|
||||
//! @return the id
|
||||
//! @param cxMainContext OpenCL context
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
cl_device_id btOclGetMaxFlopsDev(cl_context cxMainContext)
|
||||
{
|
||||
size_t szParmDataBytes;
|
||||
cl_device_id* cdDevices;
|
||||
|
||||
// get the list of GPU devices associated with context
|
||||
clGetContextInfo(cxMainContext, CL_CONTEXT_DEVICES, 0, NULL, &szParmDataBytes);
|
||||
cdDevices = (cl_device_id*) malloc(szParmDataBytes);
|
||||
size_t device_count = szParmDataBytes / sizeof(cl_device_id);
|
||||
|
||||
clGetContextInfo(cxMainContext, CL_CONTEXT_DEVICES, szParmDataBytes, cdDevices, NULL);
|
||||
|
||||
cl_device_id max_flops_device = cdDevices[0];
|
||||
int max_flops = 0;
|
||||
|
||||
size_t current_device = 0;
|
||||
|
||||
// CL_DEVICE_MAX_COMPUTE_UNITS
|
||||
cl_uint compute_units;
|
||||
clGetDeviceInfo(cdDevices[current_device], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL);
|
||||
|
||||
// CL_DEVICE_MAX_CLOCK_FREQUENCY
|
||||
cl_uint clock_frequency;
|
||||
clGetDeviceInfo(cdDevices[current_device], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_frequency), &clock_frequency, NULL);
|
||||
|
||||
cl_device_type device_type;
|
||||
clGetDeviceInfo(cdDevices[current_device], CL_DEVICE_TYPE, sizeof(device_type), &device_type, NULL);
|
||||
|
||||
int SIMDmultiplier = 1;
|
||||
|
||||
if( device_type == CL_DEVICE_TYPE_CPU )
|
||||
{
|
||||
// For simplicity assume that the CPU is running single SSE instructions
|
||||
// This will of course depend on the kernel
|
||||
SIMDmultiplier = 4;
|
||||
} else if( device_type == CL_DEVICE_TYPE_GPU ) {
|
||||
// Approximation to GPU compute power
|
||||
// As long as this beats the CPU number that's the important thing, really
|
||||
#if defined(CL_PLATFORM_INTEL)
|
||||
// SSE - 4, AVX1,2 - 8 : TODO: detect AVX?
|
||||
SIMDmultiplier = 4;
|
||||
#elif defined(CL_PLATFORM_AMD)
|
||||
// 16 processing elements, 5 ALUs each
|
||||
SIMDmultiplier = 80;
|
||||
#elif defined(CL_PLATFORM_NVIDIA)
|
||||
// 8 processing elements, dual issue - pre-Fermi at least
|
||||
SIMDmultiplier = 16;
|
||||
#else
|
||||
SIMDmultiplier = 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
max_flops = compute_units * clock_frequency * SIMDmultiplier;
|
||||
++current_device;
|
||||
|
||||
while( current_device < device_count )
|
||||
{
|
||||
// CL_DEVICE_MAX_COMPUTE_UNITS
|
||||
cl_uint compute_units;
|
||||
clGetDeviceInfo(cdDevices[current_device], CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL);
|
||||
|
||||
// CL_DEVICE_MAX_CLOCK_FREQUENCY
|
||||
cl_uint clock_frequency;
|
||||
clGetDeviceInfo(cdDevices[current_device], CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_frequency), &clock_frequency, NULL);
|
||||
|
||||
int flops = compute_units * clock_frequency;
|
||||
if( flops > max_flops )
|
||||
{
|
||||
max_flops = flops;
|
||||
max_flops_device = cdDevices[current_device];
|
||||
}
|
||||
++current_device;
|
||||
}
|
||||
|
||||
free(cdDevices);
|
||||
|
||||
return max_flops_device;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//! Loads a Program file and prepends the cPreamble to the code.
|
||||
@@ -221,140 +138,139 @@ cl_device_id btOclGetFirstDev(cl_context cxMainContext)
|
||||
void btOclPrintDevInfo(cl_device_id device)
|
||||
{
|
||||
char device_string[1024];
|
||||
bool nv_device_attibute_query = false;
|
||||
|
||||
// CL_DEVICE_NAME
|
||||
clGetDeviceInfo(device, CL_DEVICE_NAME, sizeof(device_string), &device_string, NULL);
|
||||
printf(" CL_DEVICE_NAME: \t\t\t%s\n", device_string);
|
||||
myprintf(" CL_DEVICE_NAME: \t\t\t%s\n", device_string);
|
||||
|
||||
// CL_DEVICE_VENDOR
|
||||
clGetDeviceInfo(device, CL_DEVICE_VENDOR, sizeof(device_string), &device_string, NULL);
|
||||
printf(" CL_DEVICE_VENDOR: \t\t\t%s\n", device_string);
|
||||
myprintf(" CL_DEVICE_VENDOR: \t\t\t%s\n", device_string);
|
||||
|
||||
// CL_DRIVER_VERSION
|
||||
clGetDeviceInfo(device, CL_DRIVER_VERSION, sizeof(device_string), &device_string, NULL);
|
||||
printf(" CL_DRIVER_VERSION: \t\t\t%s\n", device_string);
|
||||
myprintf(" CL_DRIVER_VERSION: \t\t\t%s\n", device_string);
|
||||
|
||||
// CL_DEVICE_INFO
|
||||
cl_device_type type;
|
||||
clGetDeviceInfo(device, CL_DEVICE_TYPE, sizeof(type), &type, NULL);
|
||||
if( type & CL_DEVICE_TYPE_CPU )
|
||||
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU");
|
||||
myprintf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_CPU");
|
||||
if( type & CL_DEVICE_TYPE_GPU )
|
||||
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU");
|
||||
myprintf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_GPU");
|
||||
if( type & CL_DEVICE_TYPE_ACCELERATOR )
|
||||
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR");
|
||||
myprintf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_ACCELERATOR");
|
||||
if( type & CL_DEVICE_TYPE_DEFAULT )
|
||||
printf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
|
||||
myprintf(" CL_DEVICE_TYPE:\t\t\t%s\n", "CL_DEVICE_TYPE_DEFAULT");
|
||||
|
||||
// CL_DEVICE_MAX_COMPUTE_UNITS
|
||||
cl_uint compute_units;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_COMPUTE_UNITS, sizeof(compute_units), &compute_units, NULL);
|
||||
printf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", compute_units);
|
||||
myprintf(" CL_DEVICE_MAX_COMPUTE_UNITS:\t\t%u\n", compute_units);
|
||||
|
||||
// CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS
|
||||
size_t workitem_dims;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, sizeof(workitem_dims), &workitem_dims, NULL);
|
||||
printf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%d\n", workitem_dims);
|
||||
myprintf(" CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS:\t%u\n", workitem_dims);
|
||||
|
||||
// CL_DEVICE_MAX_WORK_ITEM_SIZES
|
||||
size_t workitem_size[3];
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_ITEM_SIZES, sizeof(workitem_size), &workitem_size, NULL);
|
||||
printf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%d / %d / %d \n", workitem_size[0], workitem_size[1], workitem_size[2]);
|
||||
myprintf(" CL_DEVICE_MAX_WORK_ITEM_SIZES:\t%u / %u / %u \n", workitem_size[0], workitem_size[1], workitem_size[2]);
|
||||
|
||||
// CL_DEVICE_MAX_WORK_GROUP_SIZE
|
||||
size_t workgroup_size;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_WORK_GROUP_SIZE, sizeof(workgroup_size), &workgroup_size, NULL);
|
||||
printf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%d\n", workgroup_size);
|
||||
myprintf(" CL_DEVICE_MAX_WORK_GROUP_SIZE:\t%u\n", workgroup_size);
|
||||
|
||||
// CL_DEVICE_MAX_CLOCK_FREQUENCY
|
||||
cl_uint clock_frequency;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_CLOCK_FREQUENCY, sizeof(clock_frequency), &clock_frequency, NULL);
|
||||
printf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", clock_frequency);
|
||||
myprintf(" CL_DEVICE_MAX_CLOCK_FREQUENCY:\t%u MHz\n", clock_frequency);
|
||||
|
||||
// CL_DEVICE_ADDRESS_BITS
|
||||
cl_uint addr_bits;
|
||||
clGetDeviceInfo(device, CL_DEVICE_ADDRESS_BITS, sizeof(addr_bits), &addr_bits, NULL);
|
||||
printf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", addr_bits);
|
||||
myprintf(" CL_DEVICE_ADDRESS_BITS:\t\t%u\n", addr_bits);
|
||||
|
||||
// CL_DEVICE_MAX_MEM_ALLOC_SIZE
|
||||
cl_ulong max_mem_alloc_size;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(max_mem_alloc_size), &max_mem_alloc_size, NULL);
|
||||
printf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(max_mem_alloc_size / (1024 * 1024)));
|
||||
myprintf(" CL_DEVICE_MAX_MEM_ALLOC_SIZE:\t\t%u MByte\n", (unsigned int)(max_mem_alloc_size / (1024 * 1024)));
|
||||
|
||||
// CL_DEVICE_GLOBAL_MEM_SIZE
|
||||
cl_ulong mem_size;
|
||||
clGetDeviceInfo(device, CL_DEVICE_GLOBAL_MEM_SIZE, sizeof(mem_size), &mem_size, NULL);
|
||||
printf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(mem_size / (1024 * 1024)));
|
||||
myprintf(" CL_DEVICE_GLOBAL_MEM_SIZE:\t\t%u MByte\n", (unsigned int)(mem_size / (1024 * 1024)));
|
||||
|
||||
// CL_DEVICE_ERROR_CORRECTION_SUPPORT
|
||||
cl_bool error_correction_support;
|
||||
clGetDeviceInfo(device, CL_DEVICE_ERROR_CORRECTION_SUPPORT, sizeof(error_correction_support), &error_correction_support, NULL);
|
||||
printf(" CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", error_correction_support == CL_TRUE ? "yes" : "no");
|
||||
myprintf(" CL_DEVICE_ERROR_CORRECTION_SUPPORT:\t%s\n", error_correction_support == CL_TRUE ? "yes" : "no");
|
||||
|
||||
// CL_DEVICE_LOCAL_MEM_TYPE
|
||||
cl_device_local_mem_type local_mem_type;
|
||||
clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_TYPE, sizeof(local_mem_type), &local_mem_type, NULL);
|
||||
printf(" CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", local_mem_type == 1 ? "local" : "global");
|
||||
myprintf(" CL_DEVICE_LOCAL_MEM_TYPE:\t\t%s\n", local_mem_type == 1 ? "local" : "global");
|
||||
|
||||
// CL_DEVICE_LOCAL_MEM_SIZE
|
||||
clGetDeviceInfo(device, CL_DEVICE_LOCAL_MEM_SIZE, sizeof(mem_size), &mem_size, NULL);
|
||||
printf(" CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(mem_size / 1024));
|
||||
myprintf(" CL_DEVICE_LOCAL_MEM_SIZE:\t\t%u KByte\n", (unsigned int)(mem_size / 1024));
|
||||
|
||||
// CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, sizeof(mem_size), &mem_size, NULL);
|
||||
printf(" CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(mem_size / 1024));
|
||||
myprintf(" CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE:\t%u KByte\n", (unsigned int)(mem_size / 1024));
|
||||
|
||||
// CL_DEVICE_QUEUE_PROPERTIES
|
||||
cl_command_queue_properties queue_properties;
|
||||
clGetDeviceInfo(device, CL_DEVICE_QUEUE_PROPERTIES, sizeof(queue_properties), &queue_properties, NULL);
|
||||
if( queue_properties & 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");
|
||||
myprintf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE");
|
||||
if( queue_properties & CL_QUEUE_PROFILING_ENABLE )
|
||||
printf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE");
|
||||
myprintf(" CL_DEVICE_QUEUE_PROPERTIES:\t\t%s\n", "CL_QUEUE_PROFILING_ENABLE");
|
||||
|
||||
// CL_DEVICE_IMAGE_SUPPORT
|
||||
cl_bool image_support;
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE_SUPPORT, sizeof(image_support), &image_support, NULL);
|
||||
printf(" CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", image_support);
|
||||
myprintf(" CL_DEVICE_IMAGE_SUPPORT:\t\t%u\n", image_support);
|
||||
|
||||
// CL_DEVICE_MAX_READ_IMAGE_ARGS
|
||||
cl_uint max_read_image_args;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_READ_IMAGE_ARGS, sizeof(max_read_image_args), &max_read_image_args, NULL);
|
||||
printf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", max_read_image_args);
|
||||
myprintf(" CL_DEVICE_MAX_READ_IMAGE_ARGS:\t%u\n", max_read_image_args);
|
||||
|
||||
// CL_DEVICE_MAX_WRITE_IMAGE_ARGS
|
||||
cl_uint max_write_image_args;
|
||||
clGetDeviceInfo(device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, sizeof(max_write_image_args), &max_write_image_args, NULL);
|
||||
printf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", max_write_image_args);
|
||||
myprintf(" CL_DEVICE_MAX_WRITE_IMAGE_ARGS:\t%u\n", max_write_image_args);
|
||||
|
||||
// CL_DEVICE_IMAGE2D_MAX_WIDTH, CL_DEVICE_IMAGE2D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_WIDTH, CL_DEVICE_IMAGE3D_MAX_HEIGHT, CL_DEVICE_IMAGE3D_MAX_DEPTH
|
||||
size_t szMaxDims[5];
|
||||
printf("\n CL_DEVICE_IMAGE <dim>");
|
||||
myprintf("\n CL_DEVICE_IMAGE <dim>\n");
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_WIDTH, sizeof(size_t), &szMaxDims[0], NULL);
|
||||
printf("\t\t\t2D_MAX_WIDTH\t %d\n", szMaxDims[0]);
|
||||
myprintf("\t\t\t2D_MAX_WIDTH\t %u\n", szMaxDims[0]);
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE2D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[1], NULL);
|
||||
printf("\t\t\t\t\t2D_MAX_HEIGHT\t %d\n", szMaxDims[1]);
|
||||
myprintf("\t\t\t\t\t2D_MAX_HEIGHT\t %u\n", szMaxDims[1]);
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_WIDTH, sizeof(size_t), &szMaxDims[2], NULL);
|
||||
printf("\t\t\t\t\t3D_MAX_WIDTH\t %d\n", szMaxDims[2]);
|
||||
myprintf("\t\t\t\t\t3D_MAX_WIDTH\t %u\n", szMaxDims[2]);
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_HEIGHT, sizeof(size_t), &szMaxDims[3], NULL);
|
||||
printf("\t\t\t\t\t3D_MAX_HEIGHT\t %d\n", szMaxDims[3]);
|
||||
myprintf("\t\t\t\t\t3D_MAX_HEIGHT\t %u\n", szMaxDims[3]);
|
||||
clGetDeviceInfo(device, CL_DEVICE_IMAGE3D_MAX_DEPTH, sizeof(size_t), &szMaxDims[4], NULL);
|
||||
printf("\t\t\t\t\t3D_MAX_DEPTH\t %d\n", szMaxDims[4]);
|
||||
myprintf("\t\t\t\t\t3D_MAX_DEPTH\t %u\n", szMaxDims[4]);
|
||||
|
||||
// CL_DEVICE_EXTENSIONS: get device extensions, and if any then parse & log the string onto separate lines
|
||||
clGetDeviceInfo(device, CL_DEVICE_EXTENSIONS, sizeof(device_string), &device_string, NULL);
|
||||
if (device_string != 0)
|
||||
{
|
||||
printf("\n CL_DEVICE_EXTENSIONS:%s\n",device_string);
|
||||
myprintf("\n CL_DEVICE_EXTENSIONS:%s\n",device_string);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf(" CL_DEVICE_EXTENSIONS: None\n");
|
||||
myprintf(" CL_DEVICE_EXTENSIONS: None\n");
|
||||
}
|
||||
|
||||
// CL_DEVICE_PREFERRED_VECTOR_WIDTH_<type>
|
||||
printf(" CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>\t");
|
||||
myprintf(" CL_DEVICE_PREFERRED_VECTOR_WIDTH_<t>\t\n");
|
||||
cl_uint vec_width [6];
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, sizeof(cl_uint), &vec_width[0], NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, sizeof(cl_uint), &vec_width[1], NULL);
|
||||
@@ -362,6 +278,7 @@ void btOclPrintDevInfo(cl_device_id device)
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, sizeof(cl_uint), &vec_width[3], NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, sizeof(cl_uint), &vec_width[4], NULL);
|
||||
clGetDeviceInfo(device, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, sizeof(cl_uint), &vec_width[5], NULL);
|
||||
printf("CHAR %u, SHORT %u, INT %u, FLOAT %u, DOUBLE %u\n\n\n",
|
||||
myprintf("CHAR %u, SHORT %u, INT %u, FLOAT %u, DOUBLE %u\n\n",
|
||||
vec_width[0], vec_width[1], vec_width[2], vec_width[3], vec_width[4]);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,17 @@ subject to the following restrictions:
|
||||
|
||||
#ifdef USE_MINICL
|
||||
#include <MiniCL/cl.h>
|
||||
#else //USE_MINICL
|
||||
#ifdef BT_USE_CLEW
|
||||
#include "clew.h"
|
||||
#else
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif __APPLE__
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifdef __APPLE__
|
||||
#include <OpenCL/cl.h>
|
||||
#else
|
||||
#include <CL/cl.h>
|
||||
#endif //__APPLE__
|
||||
#endif //BT_USE_CLEW
|
||||
#endif //USE_MINICL
|
||||
|
||||
|
||||
//#define oclCHECKERROR(a, b) btAssert((a) == (b))
|
||||
@@ -35,7 +37,6 @@ subject to the following restrictions:
|
||||
|
||||
void btOclPrintDevInfo(cl_device_id device);
|
||||
cl_device_id btOclGetDev(cl_context cxMainContext, unsigned int nr);
|
||||
cl_device_id btOclGetMaxFlopsDev(cl_context cxMainContext);
|
||||
char* btOclLoadProgSource(const char* cFilename, const char* cPreamble, size_t* szFinalLength);
|
||||
cl_device_id btOclGetFirstDev(cl_context cxMainContext);
|
||||
#endif //BT_OCL_UTILS_H
|
||||
|
||||
313
Demos/SharedOpenCL/clew.c
Normal file
313
Demos/SharedOpenCL/clew.c
Normal file
@@ -0,0 +1,313 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// 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)
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
#ifndef USE_MINICL
|
||||
#include "clew.h"
|
||||
|
||||
//! \file clew.c
|
||||
//! \brief OpenCL run-time loader source
|
||||
|
||||
#ifndef CLCC_GENERATE_DOCUMENTATION
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#define VC_EXTRALEAN
|
||||
#define NOMINMAX
|
||||
#include <windows.h>
|
||||
|
||||
typedef HMODULE CLCC_DYNLIB_HANDLE;
|
||||
|
||||
#define CLCC_DYNLIB_OPEN LoadLibrary
|
||||
#define CLCC_DYNLIB_CLOSE FreeLibrary
|
||||
#define CLCC_DYNLIB_IMPORT GetProcAddress
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
|
||||
typedef void* CLCC_DYNLIB_HANDLE;
|
||||
|
||||
#define CLCC_DYNLIB_OPEN(path) dlopen(path, RTLD_NOW | RTLD_GLOBAL)
|
||||
#define CLCC_DYNLIB_CLOSE dlclose
|
||||
#define CLCC_DYNLIB_IMPORT dlsym
|
||||
#endif
|
||||
#else
|
||||
//typedef implementation_defined CLCC_DYNLIB_HANDLE;
|
||||
//#define CLCC_DYNLIB_OPEN(path) implementation_defined
|
||||
//#define CLCC_DYNLIB_CLOSE implementation_defined
|
||||
//#define CLCC_DYNLIB_IMPORT implementation_defined
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
//! \brief module handle
|
||||
static CLCC_DYNLIB_HANDLE module = NULL;
|
||||
|
||||
// Variables holding function entry points
|
||||
#ifndef CLCC_GENERATE_DOCUMENTATION
|
||||
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;
|
||||
PFNCLSETCOMMANDQUEUEPROPERTY __clewSetCommandQueueProperty = NULL;
|
||||
PFNCLCREATEBUFFER __clewCreateBuffer = NULL;
|
||||
PFNCLCREATEIMAGE2D __clewCreateImage2D = NULL;
|
||||
PFNCLCREATEIMAGE3D __clewCreateImage3D = NULL;
|
||||
PFNCLRETAINMEMOBJECT __clewRetainMemObject = NULL;
|
||||
PFNCLRELEASEMEMOBJECT __clewReleaseMemObject = NULL;
|
||||
PFNCLGETSUPPORTEDIMAGEFORMATS __clewGetSupportedImageFormats = NULL;
|
||||
PFNCLGETMEMOBJECTINFO __clewGetMemObjectInfo = NULL;
|
||||
PFNCLGETIMAGEINFO __clewGetImageInfo = 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;
|
||||
PFNCLRETAINEVENT __clewRetainEvent = NULL;
|
||||
PFNCLRELEASEEVENT __clewReleaseEvent = NULL;
|
||||
PFNCLGETEVENTPROFILINGINFO __clewGetEventProfilingInfo = NULL;
|
||||
PFNCLFLUSH __clewFlush = NULL;
|
||||
PFNCLFINISH __clewFinish = NULL;
|
||||
PFNCLENQUEUEREADBUFFER __clewEnqueueReadBuffer = NULL;
|
||||
PFNCLENQUEUEWRITEBUFFER __clewEnqueueWriteBuffer = NULL;
|
||||
PFNCLENQUEUECOPYBUFFER __clewEnqueueCopyBuffer = NULL;
|
||||
PFNCLENQUEUEREADIMAGE __clewEnqueueReadImage = NULL;
|
||||
PFNCLENQUEUEWRITEIMAGE __clewEnqueueWriteImage = NULL;
|
||||
PFNCLENQUEUECOPYIMAGE __clewEnqueueCopyImage = 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;
|
||||
#endif // CLCC_GENERATE_DOCUMENTATION
|
||||
|
||||
|
||||
//! \brief Unloads OpenCL dynamic library, should not be called directly
|
||||
static void clewExit(void)
|
||||
{
|
||||
if (module != NULL)
|
||||
{
|
||||
// Ignore errors
|
||||
CLCC_DYNLIB_CLOSE(module);
|
||||
module = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//! \param path path to dynamic library to load
|
||||
//! \return CLEW_ERROR_OPEN_FAILED if the library could not be opened
|
||||
//! CLEW_ERROR_ATEXIT_FAILED if atexit(clewExit) failed
|
||||
//! CLEW_SUCCESS when the library was succesfully loaded
|
||||
int clewInit(const char* path)
|
||||
{
|
||||
int error = 0;
|
||||
|
||||
// Check if already initialized
|
||||
if (module != NULL)
|
||||
{
|
||||
return CLEW_SUCCESS;
|
||||
}
|
||||
|
||||
// Load library
|
||||
module = CLCC_DYNLIB_OPEN(path);
|
||||
|
||||
// Check for errors
|
||||
if (module == NULL)
|
||||
{
|
||||
return CLEW_ERROR_OPEN_FAILED;
|
||||
}
|
||||
|
||||
// Set unloading
|
||||
error = atexit(clewExit);
|
||||
|
||||
if (error)
|
||||
{
|
||||
// Failure queing atexit, shutdown with error
|
||||
CLCC_DYNLIB_CLOSE(module);
|
||||
module = NULL;
|
||||
|
||||
return CLEW_ERROR_ATEXIT_FAILED;
|
||||
}
|
||||
|
||||
// Determine function entry-points
|
||||
__clewGetPlatformIDs = (PFNCLGETPLATFORMIDS )CLCC_DYNLIB_IMPORT(module, "clGetPlatformIDs");
|
||||
__clewGetPlatformInfo = (PFNCLGETPLATFORMINFO )CLCC_DYNLIB_IMPORT(module, "clGetPlatformInfo");
|
||||
__clewGetDeviceIDs = (PFNCLGETDEVICEIDS )CLCC_DYNLIB_IMPORT(module, "clGetDeviceIDs");
|
||||
__clewGetDeviceInfo = (PFNCLGETDEVICEINFO )CLCC_DYNLIB_IMPORT(module, "clGetDeviceInfo");
|
||||
__clewCreateContext = (PFNCLCREATECONTEXT )CLCC_DYNLIB_IMPORT(module, "clCreateContext");
|
||||
__clewCreateContextFromType = (PFNCLCREATECONTEXTFROMTYPE )CLCC_DYNLIB_IMPORT(module, "clCreateContextFromType");
|
||||
__clewRetainContext = (PFNCLRETAINCONTEXT )CLCC_DYNLIB_IMPORT(module, "clRetainContext");
|
||||
__clewReleaseContext = (PFNCLRELEASECONTEXT )CLCC_DYNLIB_IMPORT(module, "clReleaseContext");
|
||||
__clewGetContextInfo = (PFNCLGETCONTEXTINFO )CLCC_DYNLIB_IMPORT(module, "clGetContextInfo");
|
||||
__clewCreateCommandQueue = (PFNCLCREATECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clCreateCommandQueue");
|
||||
__clewRetainCommandQueue = (PFNCLRETAINCOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clRetainCommandQueue");
|
||||
__clewReleaseCommandQueue = (PFNCLRELEASECOMMANDQUEUE )CLCC_DYNLIB_IMPORT(module, "clReleaseCommandQueue");
|
||||
__clewGetCommandQueueInfo = (PFNCLGETCOMMANDQUEUEINFO )CLCC_DYNLIB_IMPORT(module, "clGetCommandQueueInfo");
|
||||
__clewSetCommandQueueProperty = (PFNCLSETCOMMANDQUEUEPROPERTY )CLCC_DYNLIB_IMPORT(module, "clSetCommandQueueProperty");
|
||||
__clewCreateBuffer = (PFNCLCREATEBUFFER )CLCC_DYNLIB_IMPORT(module, "clCreateBuffer");
|
||||
__clewCreateImage2D = (PFNCLCREATEIMAGE2D )CLCC_DYNLIB_IMPORT(module, "clCreateImage2D");
|
||||
__clewCreateImage3D = (PFNCLCREATEIMAGE3D )CLCC_DYNLIB_IMPORT(module, "clCreateImage3D");
|
||||
__clewRetainMemObject = (PFNCLRETAINMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clRetainMemObject");
|
||||
__clewReleaseMemObject = (PFNCLRELEASEMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clReleaseMemObject");
|
||||
__clewGetSupportedImageFormats = (PFNCLGETSUPPORTEDIMAGEFORMATS )CLCC_DYNLIB_IMPORT(module, "clGetSupportedImageFormats");
|
||||
__clewGetMemObjectInfo = (PFNCLGETMEMOBJECTINFO )CLCC_DYNLIB_IMPORT(module, "clGetMemObjectInfo");
|
||||
__clewGetImageInfo = (PFNCLGETIMAGEINFO )CLCC_DYNLIB_IMPORT(module, "clGetImageInfo");
|
||||
__clewCreateSampler = (PFNCLCREATESAMPLER )CLCC_DYNLIB_IMPORT(module, "clCreateSampler");
|
||||
__clewRetainSampler = (PFNCLRETAINSAMPLER )CLCC_DYNLIB_IMPORT(module, "clRetainSampler");
|
||||
__clewReleaseSampler = (PFNCLRELEASESAMPLER )CLCC_DYNLIB_IMPORT(module, "clReleaseSampler");
|
||||
__clewGetSamplerInfo = (PFNCLGETSAMPLERINFO )CLCC_DYNLIB_IMPORT(module, "clGetSamplerInfo");
|
||||
__clewCreateProgramWithSource = (PFNCLCREATEPROGRAMWITHSOURCE )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithSource");
|
||||
__clewCreateProgramWithBinary = (PFNCLCREATEPROGRAMWITHBINARY )CLCC_DYNLIB_IMPORT(module, "clCreateProgramWithBinary");
|
||||
__clewRetainProgram = (PFNCLRETAINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clRetainProgram");
|
||||
__clewReleaseProgram = (PFNCLRELEASEPROGRAM )CLCC_DYNLIB_IMPORT(module, "clReleaseProgram");
|
||||
__clewBuildProgram = (PFNCLBUILDPROGRAM )CLCC_DYNLIB_IMPORT(module, "clBuildProgram");
|
||||
__clewUnloadCompiler = (PFNCLUNLOADCOMPILER )CLCC_DYNLIB_IMPORT(module, "clUnloadCompiler");
|
||||
__clewGetProgramInfo = (PFNCLGETPROGRAMINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramInfo");
|
||||
__clewGetProgramBuildInfo = (PFNCLGETPROGRAMBUILDINFO )CLCC_DYNLIB_IMPORT(module, "clGetProgramBuildInfo");
|
||||
__clewCreateKernel = (PFNCLCREATEKERNEL )CLCC_DYNLIB_IMPORT(module, "clCreateKernel");
|
||||
__clewCreateKernelsInProgram = (PFNCLCREATEKERNELSINPROGRAM )CLCC_DYNLIB_IMPORT(module, "clCreateKernelsInProgram");
|
||||
__clewRetainKernel = (PFNCLRETAINKERNEL )CLCC_DYNLIB_IMPORT(module, "clRetainKernel");
|
||||
__clewReleaseKernel = (PFNCLRELEASEKERNEL )CLCC_DYNLIB_IMPORT(module, "clReleaseKernel");
|
||||
__clewSetKernelArg = (PFNCLSETKERNELARG )CLCC_DYNLIB_IMPORT(module, "clSetKernelArg");
|
||||
__clewGetKernelInfo = (PFNCLGETKERNELINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelInfo");
|
||||
__clewGetKernelWorkGroupInfo = (PFNCLGETKERNELWORKGROUPINFO )CLCC_DYNLIB_IMPORT(module, "clGetKernelWorkGroupInfo");
|
||||
__clewWaitForEvents = (PFNCLWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clWaitForEvents");
|
||||
__clewGetEventInfo = (PFNCLGETEVENTINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventInfo");
|
||||
__clewRetainEvent = (PFNCLRETAINEVENT )CLCC_DYNLIB_IMPORT(module, "clRetainEvent");
|
||||
__clewReleaseEvent = (PFNCLRELEASEEVENT )CLCC_DYNLIB_IMPORT(module, "clReleaseEvent");
|
||||
__clewGetEventProfilingInfo = (PFNCLGETEVENTPROFILINGINFO )CLCC_DYNLIB_IMPORT(module, "clGetEventProfilingInfo");
|
||||
__clewFlush = (PFNCLFLUSH )CLCC_DYNLIB_IMPORT(module, "clFlush");
|
||||
__clewFinish = (PFNCLFINISH )CLCC_DYNLIB_IMPORT(module, "clFinish");
|
||||
__clewEnqueueReadBuffer = (PFNCLENQUEUEREADBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadBuffer");
|
||||
__clewEnqueueWriteBuffer = (PFNCLENQUEUEWRITEBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteBuffer");
|
||||
__clewEnqueueCopyBuffer = (PFNCLENQUEUECOPYBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBuffer");
|
||||
__clewEnqueueReadImage = (PFNCLENQUEUEREADIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueReadImage");
|
||||
__clewEnqueueWriteImage = (PFNCLENQUEUEWRITEIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueWriteImage");
|
||||
__clewEnqueueCopyImage = (PFNCLENQUEUECOPYIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImage");
|
||||
__clewEnqueueCopyImageToBuffer = (PFNCLENQUEUECOPYIMAGETOBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyImageToBuffer");
|
||||
__clewEnqueueCopyBufferToImage = (PFNCLENQUEUECOPYBUFFERTOIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueCopyBufferToImage");
|
||||
__clewEnqueueMapBuffer = (PFNCLENQUEUEMAPBUFFER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapBuffer");
|
||||
__clewEnqueueMapImage = (PFNCLENQUEUEMAPIMAGE )CLCC_DYNLIB_IMPORT(module, "clEnqueueMapImage");
|
||||
__clewEnqueueUnmapMemObject = (PFNCLENQUEUEUNMAPMEMOBJECT )CLCC_DYNLIB_IMPORT(module, "clEnqueueUnmapMemObject");
|
||||
__clewEnqueueNDRangeKernel = (PFNCLENQUEUENDRANGEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNDRangeKernel");
|
||||
__clewEnqueueTask = (PFNCLENQUEUETASK )CLCC_DYNLIB_IMPORT(module, "clEnqueueTask");
|
||||
__clewEnqueueNativeKernel = (PFNCLENQUEUENATIVEKERNEL )CLCC_DYNLIB_IMPORT(module, "clEnqueueNativeKernel");
|
||||
__clewEnqueueMarker = (PFNCLENQUEUEMARKER )CLCC_DYNLIB_IMPORT(module, "clEnqueueMarker");
|
||||
__clewEnqueueWaitForEvents = (PFNCLENQUEUEWAITFOREVENTS )CLCC_DYNLIB_IMPORT(module, "clEnqueueWaitForEvents");
|
||||
__clewEnqueueBarrier = (PFNCLENQUEUEBARRIER )CLCC_DYNLIB_IMPORT(module, "clEnqueueBarrier");
|
||||
__clewGetExtensionFunctionAddress = (PFNCLGETEXTENSIONFUNCTIONADDRESS )CLCC_DYNLIB_IMPORT(module, "clGetExtensionFunctionAddress");
|
||||
|
||||
return CLEW_SUCCESS;
|
||||
}
|
||||
|
||||
//! \param error CL error code
|
||||
//! \return a string representation of the error code
|
||||
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];
|
||||
}
|
||||
#endif
|
||||
1316
Demos/SharedOpenCL/clew.h
Normal file
1316
Demos/SharedOpenCL/clew.h
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user