33package com.jogamp.opencl.impl;
35import java.nio.IntBuffer;
37import com.jogamp.common.nio.AbstractBuffer;
38import com.jogamp.common.nio.PointerBuffer;
39import com.jogamp.opencl.llb.CL;
40import com.jogamp.opencl.spi.CLAccessorFactory;
41import com.jogamp.opencl.spi.CLInfoAccessor;
42import com.jogamp.opencl.spi.CLPlatformInfoAccessor;
43import java.nio.Buffer;
45import static com.jogamp.opencl.CLException.*;
55 return new CLDeviceInfoAccessor(cl,
id);
60 return new CLTLPlatformInfoAccessor(cl,
id);
66 private final long ID;
68 private CLDeviceInfoAccessor(
final CL cl,
final long id) {
74 public int getInfo(
final int name,
final long valueSize,
final Buffer value,
final PointerBuffer valueSizeRet) {
80 private final static class CLTLPlatformInfoAccessor
extends CLTLInfoAccessor implements CLPlatformInfoAccessor {
82 private final long ID;
85 private CLTLPlatformInfoAccessor(
final CL cl,
final long id) {
91 public int getInfo(
final int name,
final long valueSize,
final Buffer value,
final PointerBuffer valueSizeRet) {
96 public long[] getDeviceIDs(
final long type) {
98 final IntBuffer buffer =
getBB(4).asIntBuffer();
99 int ret = cl.clGetDeviceIDs(ID, type, 0,
null, buffer);
100 final int count = buffer.get(0);
103 if(ret == CL.CL_DEVICE_NOT_FOUND || count == 0) {
106 checkForError(ret,
"error while enumerating devices");
108 final PointerBuffer deviceIDs = PointerBuffer.wrap(
getBB(count*AbstractBuffer.POINTER_SIZE));
109 ret = cl.clGetDeviceIDs(ID, type, count, deviceIDs,
null);
110 checkForError(ret,
"error while enumerating devices");
112 final long[] ids =
new long[count];
113 for (
int i = 0; i < ids.length; i++) {
114 ids[i] = deviceIDs.get(i);
CLInfoAccessor createDeviceInfoAccessor(final CL cl, final long id)
CLPlatformInfoAccessor createPlatformInfoAccessor(final CL cl, final long id)
Internal utility for common OpenCL clGetFooInfo calls.
ByteBuffer getBB(final int minCapacity)
Java bindings to OpenCL, the Open Computing Language.
int clGetDeviceInfo(long device, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetDeviceInfo}(cl_device_id device,...
int clGetPlatformInfo(long platform, int param_name, long param_value_size, Buffer param_value, PointerBuffer param_value_size_ret)
Interface to C language function: cl_int {@native clGetPlatformInfo}(cl_platform_id platform,...
Implementations of this interface are factories responsible for creating CLAccessors.
Internal utility for common OpenCL clGetFooInfo calls.