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 interfaceOpenCLDevice.DeviceComparitorstatic interfaceOpenCLDevice.DeviceSelectorstatic classOpenCLDevice.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 IOpenCLDeviceConfiguratorconfiguratorprivate longdeviceIdprivate longglobalMemSizeprivate longlocalMemSizeprivate static java.util.logging.Loggerloggerprivate intmaxComputeUnitsprivate longmaxMemAllocSizeprivate java.lang.Stringnameprivate OpenCLPlatformplatformprivate booleansharedMemoryprivate java.lang.StringshortDescriptionprivate java.util.concurrent.atomic.AtomicBooleanunderConfiguration-
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)voidconfigure()Called by the underlying Aparapi OpenCL platform, upon device detection.java.util.List<OpenCLArgDescriptor>getArgs(java.lang.reflect.Method m)longgetDeviceId()longgetGlobalMemSize()longgetLocalMemSize()intgetMaxComputeUnits()longgetMaxMemAllocSize()java.lang.StringgetName()OpenCLPlatformgetOpenCLPlatform()java.lang.StringgetShortDescription()private static booleanisReservedInterfaceMethod(java.lang.reflect.Method _methods)booleanisSharedMemory()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 OpenCLDeviceselect(OpenCLDevice.DeviceComparitor _deviceComparitor)static OpenCLDeviceselect(OpenCLDevice.DeviceComparitor _deviceComparitor, Device.TYPE _type)static OpenCLDeviceselect(OpenCLDevice.DeviceSelector _deviceSelector)static voidsetConfigurator(IOpenCLDeviceConfigurator _configurator)Statically assigns a new configurator for all OpenCL devices detected after the assignment.voidsetGlobalMemSize(long _globalMemSize)voidsetLocalMemSize(long _localMemSize)voidsetMaxComputeUnits(int _maxComputeUnits)voidsetMaxMemAllocSize(long _maxMemAllocSize)voidsetMaxWorkItemSize(int _dim, int _value)voidsetName(java.lang.String name)voidsetSharedMemory(boolean _sharedMemory)Configure if device has the memory shared with the host memory.private java.lang.StringstreamToString(java.io.InputStream _inputStream)java.lang.StringtoString()-
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:
getDeviceIdin 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:
getShortDescriptionin 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:
toStringin classjava.lang.Object
-
-