File | Date | Author | Commit |
---|---|---|---|
C# | 2022-03-06 |
![]() |
[951177] Initial commit |
Excel | 2022-03-06 |
![]() |
[951177] Initial commit |
.gitignore | 2022-03-06 |
![]() |
[951177] Initial commit |
Readme.md | 2022-03-06 |
![]() |
[951177] Initial commit |
The wrapper allows to start OpenCl code on CPU and GPU devices from VBA.
The wrapper has simple implementation and divided in two independent parts:
-
ClooWrapperVBA.Configuration, to obtain configuration of available platforms and associated CPUs and GPUs.
ClooWrapperVBA.ProgramDevice, to compile and start OpenCl programs on CPUs and GPUs and obtain the results. It is also possible to start programs on CPUs and GPUs simultaneously (asynchronously). In asynchronous mode it is also possible to set the priority of execution.
The current version can be downloaded as:
* Installer for Windows. Installation path is "C:\Program Files (x86)\ClooWrapperVBA\".
*
Zip-file which contains the same content as the installer. The components must be registered using "register.bat". Please note, that the "register.bat" must be started with admin rights.
Directory "demo" contains the Excel table with all demos and VBscript file to check available platforms and devices even without Excel.
ClooWrapperVBA.Configuration:
ClooWrapperVBA.Configuration.Platform - contains information on the available platform.
ClooWrapperVBA.Configuration.Platform.Device - contains information on each device in available platforms. In total you can obtain 59 device-specific properties.
ClooWrapperVBA.ProgramDevice:
ClooWrapperVBA.ProgramDevice.Build - compiles sources for selected device.
ClooWrapperVBA.ProgramDevice.CreateKernel - Loads the function to execute.
ClooWrapperVBA.ProgramDevice.SetValueArgument_..., ClooWrapperVBA.ProgramDevice.SetMemoryArgument_... - Sets argument values and arrays of integers, floats and doubles of the function to execute.
ClooWrapperVBA.ProgramDevice.ExecuteSync - Execute function synchronously. Excel will move further only after execution was completed.
ClooWrapperVBA.ProgramDevice.ExecuteAsync - Start execution of the function asynchronously. The callback function will be called at the end of execution.
ClooWrapperVBA.ProgramDevice.ExecuteBackground - Start execution of the function asynchronously. After execution the flag "ClooWrapperVBA.ProgramDevice.ExecutionCompleted" is set to true.
ClooWrapperVBA.ProgramDevice.GetMemoryArgument_... - Read arguments (results) from the function.
"Asynchronous": For asynchronous execution example a matrix multiplication of two 2000x2000 matrices is used.
Good news: Yes! It is also possible to use the wrapper also from VBscript!
Bad news: You can obtain only configuration of the platforms and devices. The reason: VBscript uses variants for arrays. Of course it is possible to use object or ArrayList to set the arrays, but this will make the wrapper much complicated and is out of the target of the wrapper.
"MatrixToVector" and "VectorToMatrix" are used as expected from their names to load arrays to CPU/GPU and get the results of execution back to VBA in matrix form.
"deviceIndex" is a device index of devices at platform defined in "platformIndex". The devices corresponding to each "deviceIndex" can be of different type ("CPU"/"GPU").
Example: If your platform have 3 devices, one CPU and two GPUs, then the possible "deviceIndex" values are 0 (GPU), 1 (CPU) and 2 (GPU). The "deviceTypeIndex" in this configuration will be 0 and 1 for GPUs and 0 for CPU. You can obtain the sequence of devices using the Configuration.
To simplify usage from VBA, all devices can be added to the collection using function "CreateDeviceCollection". You can obtain the first CPU and first GPU using functions "GetFirstCpuDevice" and "GetFirstGpuDevice". The collection of all available devices is also very useful to run your code in asynchronous mode at all available devices.
During debugging Excel can crash because of simultaneous execution of the code in callback and "MainLoop" functions.
Writing out of the results to the cells in callback function can also cause an Excel crash.
globalWorkOffset, localWorkSize were not tested and were added analogously to globalWorkSize.