我有这段代码(Java / LWJGL)来创建我的 OpenCL 程序。
try
{
CL.create();
} catch (LWJGLException e1)
{
e1.printStackTrace();
}
platform = CLPlatform.getPlatforms().get(0);
devices = platform.getDevices(CL_DEVICE_TYPE_GPU);
try
{
context = CLContext.create(platform, devices, null, null, null);
} catch (LWJGLException e)
{
e.printStackTrace();
}
queue = clCreateCommandQueue(context, devices.get(0), CL_QUEUE_PROFILING_ENABLE, null);
program = clCreateProgramWithSource(context, source, null);
checkCLError(clBuildProgram(program, devices.get(0), "", null));
kernel = clCreateKernel(program, "main", null);
使用此 OpenCL 内核,它可以正常工作并且不会引发任何错误:
kernel void main(
global const float *hitboxes,
global const float *positions,
global const float *rotations,
global const float *velocities,
global const float *colliders,
global const float *weights,
global float *answerPos,
global float *answerRot,
global float *answerVel
)
{
int id = get_global_id(0);
}
但是,如果我向主方法或其他方法/结构添加任何代码,它会在
clBuildProgram
方法中抛出“CL_OUT_OF_HOST_MEMORY”。有人能告诉我为什么吗?我有另一个OpenCL程序(也是LWJGL),基本上是一样的。除了它有效。
我也遇到了类似的问题。 不过我的很愚蠢——我忘记在主函数原型中添加
__kernel
前缀,所以程序没有入口点。