Platforms to show: All Mac Windows Linux Cross-Platform

Back to OpenCLMBS module.

OpenCLMBS.AllDeviceCount(types as Int64) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries number of devices with given types.
Example
dim c as Integer = OpenCLMBS.AllDeviceCount(CLDeviceMBS.kDeviceTypeCPU)
dim g as Integer = OpenCLMBS.AllDeviceCount(CLDeviceMBS.kDeviceTypeGPU)
MsgBox str(c)+" CPU and "+str(g)+" GPU"

types: A bitfield that identifies the type of OpenCL device. The device_type can be used to query specific OpenCL devices or all OpenCL devices available. The valid values for device_type are specified in the following table.

cl_device_typeDescription
kDeviceTypeCPUAn OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU.
kDeviceTypeGPUAn OpenCL device that is a GPU. By this we mean that the device can also be used to accelerate a 3D API such as OpenGL or DirectX.
kDeviceTypeAcceleratorDedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe.
kDeviceTypeDefaultThe default OpenCL device in the system.
kDeviceTypeAllAll OpenCL devices available in the system.

Lasterror is set.

OpenCLMBS.AllDevices(types as Int64) as CLDeviceMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries devices with given types.
Example
dim Devices(-1) as CLDeviceMBS = OpenCLMBS.AllDevices(CLDeviceMBS.kDeviceTypeAll)

for each p as CLDeviceMBS in Devices
MsgBox p.Name
next

types: A bitfield that identifies the type of OpenCL device. The device_type can be used to query specific OpenCL devices or all OpenCL devices available. The valid values for device_type are specified in the following table.

cl_device_typeDescription
kDeviceTypeCPUAn OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU.
kDeviceTypeGPUAn OpenCL device that is a GPU. By this we mean that the device can also be used to accelerate a 3D API such as OpenGL or DirectX.
kDeviceTypeAcceleratorDedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe.
kDeviceTypeDefaultThe default OpenCL device in the system.
kDeviceTypeAllAll OpenCL devices available in the system.

Lasterror is set.

OpenCLMBS.GetExtensionFunctionAddress(name as string) as ptr

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Returns the address of the extension function named by funcname.

The function GetExtensionFunctionAddress returns the address of the extension function named by funcname. The pointer returned should be cast to a function pointer type matching the extension function's definition defined in the appropriate extension specification and header file. A return value of nil indicates that the specified function does not exist for the implementation. A non-nil return value for GetExtensionFunctionAddress does not guarantee that an extension function is actually supported. The application must also make a corresponding query using CLPlatformMBS.Extensions or CLDeviceMBS.Extensions to determine if an extension is supported by the OpenCL implementation.

GetExtensionFunctionAddress may not be queried for core (non-extension) functions in OpenCL. For functions that are queryable with clGetExtensionFunctionAddress, implementations may choose to also export those functions statically from the object libraries implementing those functions. However, portable applications cannot rely on this behavior.

Since there is no way to qualify the query with a device, the function pointer returned must work for all implementations of that extension on different devices. The behavior of calling a device extension function on a device not supporting that extension is undefined.

OpenCLMBS.GetPictureImageFormat(pic as picture, byref RowPitch as Integer) as CLImageFormatMBS

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries the image format this picture would need when creating a storage object with CLMemMBS.
Example
dim p as new Picture(100,100,32)
dim rowbytes as Integer
dim format as CLImageFormatMBS = OpenCLMBS.GetPictureImageFormat(p, rowbytes)

MsgBox hex(format.ImageChannelOrder)+" "+hex(format.ImageChannelDataType)+" "+str(rowbytes)
// shows 10B7 and 10D2 and 416 on Mac OS X Carbon

As Xojo uses 4 bytes per pixel on Mac and Windows, the plugin returns ARGB (or other byte order). The alpha channel is not used as Xojo stores

Some examples using this method:

OpenCLMBS.isAvailable as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Whether OpenCL is available.
Example
if not OpenCLMBS.isAvailable then
if TargetMachO and TargetX86 then
MsgBox "OpenCL not available. Please install Mac OS X 10.6 to use it."
else
MsgBox "OpenCL not available. You need a Mac with Intel processor running Mac OS X 10.6."
end if
end if

Should return true on Mac OS X 10.6 and false everywhere else.

OpenCLMBS.PlatformCount as Int64

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Queries number of platforms available.
Example
MsgBox str(OpenCLMBS.PlatformCount)

Typically you have two with modern Macs as you get both CPU and GPU listed.
Lasterror is set.

OpenCLMBS.Platforms as CLPlatformMBS()

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Obtain the list of platforms available.
Example
dim Platforms(-1) as CLPlatformMBS = OpenCLMBS.Platforms

for each p as CLPlatformMBS in Platforms
MsgBox p.Name
next

Lasterror is set.

Some examples using this method:

OpenCLMBS.UnloadCompiler

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Allows the implementation to release the resources allocated by the OpenCL compiler.
Example
OpenCLMBS.UnloadCompiler
MsgBox OpenCLMBS.LastErrorMessage

This is a hint from the application and does not guarantee that the compiler will not be used in the future or that the compiler will actually be unloaded by the implementation. Calls to BuildProgram after UnloadCompiler will reload the compiler, if necessary, to build the appropriate program executable.
Lasterror is set.

OpenCLMBS.WaitForEvents(events() as CLEventMBS)

Type Topic Plugin Version macOS Windows Linux iOS Targets
method OpenCL MBS MacFrameworks Plugin 11.1 ✅ Yes ❌ No ❌ No ✅ Yes All
Waits on the host thread for commands identified by event objects to complete.

events: The events specified in event_list act as synchronization points.

Waits on the host thread for commands identified by event objects in event_list to complete. A command is considered complete if its execution status is kCommandExecutionStatusComplete or a negative value.

Lasterror is set.

The items on this page are in the following plugins: MBS MacFrameworks Plugin.


The biggest plugin in space...