Package com.aparapi.device
Class OpenCLDevice
- java.lang.Object
-
- com.aparapi.device.Device
-
- com.aparapi.device.OpenCLDevice
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
OpenCLDevice.DeviceComparitor
static interface
OpenCLDevice.DeviceSelector
static class
OpenCLDevice.OpenCLInvocationHandler<T extends OpenCL<T>>
-
Nested classes/interfaces inherited from class com.aparapi.device.Device
Device.TYPE
-
-
Field Summary
Fields Modifier and Type Field Description private static IOpenCLDeviceConfigurator
configurator
private long
deviceId
private long
globalMemSize
private long
localMemSize
private static java.util.logging.Logger
logger
private int
maxComputeUnits
private long
maxMemAllocSize
private java.lang.String
name
private OpenCLPlatform
platform
private boolean
sharedMemory
private java.lang.String
shortDescription
private java.util.concurrent.atomic.AtomicBoolean
underConfiguration
-
Fields inherited from class com.aparapi.device.Device
maxWorkGroupSize, maxWorkItemDimensions, maxWorkItemSize, type
-
-
Constructor Summary
Constructors Constructor Description OpenCLDevice(OpenCLPlatform _platform, long _deviceId, Device.TYPE _type)
Minimal constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends OpenCL<T>>
Tbind(java.lang.Class<T> _interface)
<T extends OpenCL<T>>
Tbind(java.lang.Class<T> _interface, java.io.InputStream _inputStream)
<T extends OpenCL<T>>
Tbind(java.lang.Class<T> _interface, java.lang.String _source)
void
configure()
Called by the underlying Aparapi OpenCL platform, upon device detection.java.util.List<OpenCLArgDescriptor>
getArgs(java.lang.reflect.Method m)
long
getDeviceId()
long
getGlobalMemSize()
long
getLocalMemSize()
int
getMaxComputeUnits()
long
getMaxMemAllocSize()
java.lang.String
getName()
OpenCLPlatform
getOpenCLPlatform()
java.lang.String
getShortDescription()
private static boolean
isReservedInterfaceMethod(java.lang.reflect.Method _methods)
boolean
isSharedMemory()
Retrieves the shared memory flagstatic java.util.List<OpenCLDevice>
listDevices(Device.TYPE type)
List OpenCLDevices of a given TYPE, or all OpenCLDevices if type == null.static OpenCLDevice
select(OpenCLDevice.DeviceComparitor _deviceComparitor)
static OpenCLDevice
select(OpenCLDevice.DeviceComparitor _deviceComparitor, Device.TYPE _type)
static OpenCLDevice
select(OpenCLDevice.DeviceSelector _deviceSelector)
static void
setConfigurator(IOpenCLDeviceConfigurator _configurator)
Statically assigns a new configurator for all OpenCL devices detected after the assignment.void
setGlobalMemSize(long _globalMemSize)
void
setLocalMemSize(long _localMemSize)
void
setMaxComputeUnits(int _maxComputeUnits)
void
setMaxMemAllocSize(long _maxMemAllocSize)
void
setMaxWorkItemSize(int _dim, int _value)
void
setName(java.lang.String name)
void
setSharedMemory(boolean _sharedMemory)
Configure if device has the memory shared with the host memory.private java.lang.String
streamToString(java.io.InputStream _inputStream)
java.lang.String
toString()
-
Methods inherited from class com.aparapi.device.Device
best, bestACC, bestGPU, compareTo, createRange, createRange, createRange2D, createRange2D, createRange3D, createRange3D, equals, first, firstCPU, firstGPU, getMaxWorkGroupSize, getMaxWorkItemDimensions, getMaxWorkItemSize, getType, hashCode, setMaxWorkGroupSize, setMaxWorkItemDimensions, setMaxWorkItemSize, setType
-
-
-
-
Field Detail
-
logger
private static java.util.logging.Logger logger
-
configurator
private static IOpenCLDeviceConfigurator configurator
-
platform
private final OpenCLPlatform platform
-
deviceId
private final long deviceId
-
maxComputeUnits
private int maxComputeUnits
-
localMemSize
private long localMemSize
-
globalMemSize
private long globalMemSize
-
maxMemAllocSize
private long maxMemAllocSize
-
sharedMemory
private boolean sharedMemory
-
shortDescription
private java.lang.String shortDescription
-
name
private java.lang.String name
-
underConfiguration
private java.util.concurrent.atomic.AtomicBoolean underConfiguration
-
-
Constructor Detail
-
OpenCLDevice
public OpenCLDevice(OpenCLPlatform _platform, long _deviceId, Device.TYPE _type)
Minimal constructor- Parameters:
_platform
-_deviceId
-_type
-
-
-
Method Detail
-
setConfigurator
public static void setConfigurator(IOpenCLDeviceConfigurator _configurator)
Statically assigns a new configurator for all OpenCL devices detected after the assignment.- Parameters:
_configurator
- the configurator instance
-
getOpenCLPlatform
public OpenCLPlatform getOpenCLPlatform()
-
getMaxComputeUnits
public int getMaxComputeUnits()
-
setMaxComputeUnits
public void setMaxComputeUnits(int _maxComputeUnits)
-
getLocalMemSize
public long getLocalMemSize()
-
setLocalMemSize
public void setLocalMemSize(long _localMemSize)
-
getMaxMemAllocSize
public long getMaxMemAllocSize()
-
setMaxMemAllocSize
public void setMaxMemAllocSize(long _maxMemAllocSize)
-
getGlobalMemSize
public long getGlobalMemSize()
-
setGlobalMemSize
public void setGlobalMemSize(long _globalMemSize)
-
setMaxWorkItemSize
public void setMaxWorkItemSize(int _dim, int _value)
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
-
configure
public void configure()
Called by the underlying Aparapi OpenCL platform, upon device detection.
-
getDeviceId
public long getDeviceId()
- Specified by:
getDeviceId
in classDevice
-
setSharedMemory
public void setSharedMemory(boolean _sharedMemory)
Configure if device has the memory shared with the host memory.
Note1: For discrete GPU devices having dedicated memory, thus not shared with host, this should be set to false. This can result in significant kernel execution speed-ups for such HW configurations. Aparapi is unable to detect this property automatically for all devices, unless the client application provides a configurator (#IOpenCLDeviceConfigurator
).
Note2: By default devices are initialized has having shared memory - to maintain backwards compatibility - unless Aparapi can unequivocally identify the device.- Parameters:
_sharedMemory
-- true, if OpenCL device has the memory shared with the host memory
- false, if OpenCL device is a discrete unit, having dedicated memory, thus not shared with host
-
isSharedMemory
public boolean isSharedMemory()
Retrieves the shared memory flag- Returns:
- true, if OpenCL device has the memory shared with the host memory
- false, if OpenCL device is a discrete unit, having dedicated memory, thus not shared with host
-
getShortDescription
public java.lang.String getShortDescription()
- Specified by:
getShortDescription
in classDevice
-
getArgs
public java.util.List<OpenCLArgDescriptor> getArgs(java.lang.reflect.Method m)
-
isReservedInterfaceMethod
private static boolean isReservedInterfaceMethod(java.lang.reflect.Method _methods)
-
streamToString
private java.lang.String streamToString(java.io.InputStream _inputStream)
-
bind
public <T extends OpenCL<T>> T bind(java.lang.Class<T> _interface, java.io.InputStream _inputStream)
-
bind
public <T extends OpenCL<T>> T bind(java.lang.Class<T> _interface)
-
bind
public <T extends OpenCL<T>> T bind(java.lang.Class<T> _interface, java.lang.String _source)
-
listDevices
public static java.util.List<OpenCLDevice> listDevices(Device.TYPE type)
List OpenCLDevices of a given TYPE, or all OpenCLDevices if type == null.
-
select
public static OpenCLDevice select(OpenCLDevice.DeviceSelector _deviceSelector)
-
select
public static OpenCLDevice select(OpenCLDevice.DeviceComparitor _deviceComparitor)
-
select
public static OpenCLDevice select(OpenCLDevice.DeviceComparitor _deviceComparitor, Device.TYPE _type)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-