The kernel in the .cl file is also compiled by the native C++ cpu compiler, when using MiniCL. When you want to debug the kernel using MiniCL, and want to put breakpoints, it is best to: 1) enabled the define #define DEBUG_MINICL_KERNELS 1 in Bullet/src/BulletMultiThreaded/MiniCL.cpp 2) temporarily remove the stringify lines in the .cl kernel, because it prevents the debugger from finding the right line.
60 lines
1.9 KiB
Common Lisp
60 lines
1.9 KiB
Common Lisp
|
|
#ifndef GUID_ARG
|
|
#define GUID_ARG
|
|
#endif
|
|
|
|
|
|
#ifndef MSTRINGIFY
|
|
#define MSTRINGIFY(A) A
|
|
#endif
|
|
|
|
|
|
MSTRINGIFY(
|
|
|
|
/*
|
|
Bullet Continuous Collision Detection and Physics Library, http://bulletphysics.org
|
|
Copyright (C) 2006 - 2009 Sony Computer Entertainment Inc.
|
|
|
|
This software is provided 'as-is', without any express or implied warranty.
|
|
In no event will the authors be held liable for any damages arising from the use of this software.
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it freely,
|
|
subject to the following restrictions:
|
|
|
|
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
|
|
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
|
3. This notice may not be removed or altered from any source distribution.
|
|
*/
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////
|
|
// OpenCL Kernel Function for element by element vector addition
|
|
__kernel void VectorAdd(__global const float8* a, __global const float8* b, __global float8* c GUID_ARG)
|
|
{
|
|
// get oct-float index into global data array
|
|
int iGID = get_global_id(0);
|
|
if (iGID>=100000)
|
|
return;
|
|
|
|
// read inputs into registers
|
|
float8 f8InA = a[iGID];
|
|
float8 f8InB = b[iGID];
|
|
float8 f8Out = (float8)0.0f;
|
|
|
|
|
|
// add the vector elements
|
|
f8Out.s0 = f8InA.s0 + f8InB.s0;
|
|
f8Out.s1 = f8InA.s1 + f8InB.s1;
|
|
f8Out.s2 = f8InA.s2 + f8InB.s2;
|
|
f8Out.s3 = f8InA.s3 + f8InB.s3;
|
|
f8Out.s4 = f8InA.s4 + f8InB.s4;
|
|
f8Out.s5 = f8InA.s5 + f8InB.s5;
|
|
f8Out.s6 = f8InA.s6 + f8InB.s6;
|
|
f8Out.s7 = f8InA.s7 + f8InB.s7;
|
|
|
|
// write back out to GMEM
|
|
c[get_global_id(0)] = f8Out;
|
|
}
|
|
|
|
); |