Java 类org.lwjgl.opencl.CLKernel 实例源码

项目:jglrEngine    文件:GPUProgramResource.java   
public void runKernel(String kernelName, GPUProgramObject[] args, int globalWorkSizeInt)
{
    if(!kernels.containsKey(kernelName))
    {
        preloadKernel(kernelName);
    }

    CLKernel kernel = kernels.get(kernelName);
    int index = 0;
    for(GPUProgramObject o : args)
    {
        o.apply(kernel, index++ );
    }

    final int dimensions = 1;
    PointerBuffer globalWorkSize = BufferUtils.createPointerBuffer(dimensions);
    globalWorkSize.put(0, globalWorkSizeInt);

    CL10.clEnqueueNDRangeKernel(clQueue, kernel, dimensions, null, globalWorkSize, null, null, null);

    CL10.clFinish(clQueue);
}
项目:jglrEngine    文件:GPUProgramObject.java   
public void apply(CLKernel kernel, int id)
{
    if(type.equals("int"))
    {
        kernel.setArg(id, (Integer)value);
    }
    else if(type.equals("float"))
    {
        kernel.setArg(id, (Float)value);
    }
    else if(type.equals("short"))
    {
        kernel.setArg(id, (Short)value);
    }
    else if(type.equals("long"))
    {
        kernel.setArg(id, (Long)value);
    }
    else if(type.equals("double"))
    {
        kernel.setArg(id, (Double)value);
    }
    else if(type.equals("byte"))
    {
        kernel.setArg(id, (Byte)value);
    }
    else if(type.equals("clmem"))
    {
        kernel.setArg(id, (CLMem)value);
    }
}
项目:jglrEngine    文件:GPUProgramResource.java   
public void preloadKernel(String kernelName)
{
    CLKernel k = CL10.clCreateKernel(clProgram, kernelName, null);
    kernels.put(kernelName, k);
    if(!k.isValid())
    {
        throw new RuntimeEngineException("Kernel " + kernelName + " not valid in clProgram " + res.getResourceLocation().getFullPath());
    }
}
项目:jglrEngine    文件:GPUProgramResource.java   
public void preloadKernel(String kernelName, GPUProgramObject[] args, int size)
{
    preloadKernel(kernelName);
    CLKernel kernel = kernels.get(kernelName);
    int index = 0;
    for(GPUProgramObject o : args)
    {
        o.apply(kernel, index++ );
    }

    PointerBuffer globalWorkSize = BufferUtils.createPointerBuffer(1);
    globalWorkSize.put(0, size);
}
项目:jglrEngine    文件:GPUProgramResource.java   
public void dispose()
{
    for(CLKernel kernel : kernels.values())
        CL10.clReleaseKernel(kernel);
    CL10.clReleaseProgram(clProgram);
}