Add ComputeManager; add SmoHooks for getting ClDevices, buffers
We added a new centralized OpenCL Compute manager. This can later be extended to support CUDA, SyCL, etc. SMO can be configured at build time to choose which API it will use for compute. Moreover, the ComputeMgr allows us to register buffers which are available to all cl_contexts.
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <mind.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
#include <marionette/marionette.h>
|
||||
#include <computeManager/computeManager.h>
|
||||
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
@@ -85,6 +86,36 @@ static OptionParser& OptionParser_getOptions()
|
||||
return OptionParser::getOptions();
|
||||
}
|
||||
|
||||
/* Local static functions to wrap ComputeManager methods for SmoCallbacks */
|
||||
static std::shared_ptr<smo::compute::ClBuffer>
|
||||
ComputeManager_createUseHostPtrBuffer(
|
||||
void* hostPtr, size_t size, cl_mem_flags flags
|
||||
)
|
||||
{
|
||||
return smo::compute::ComputeManager::getInstance().createUseHostPtrBuffer(
|
||||
hostPtr, size, flags);
|
||||
}
|
||||
|
||||
static void ComputeManager_releaseUseHostPtrBuffer(
|
||||
std::shared_ptr<smo::compute::ClBuffer> buffer
|
||||
)
|
||||
{
|
||||
smo::compute::ComputeManager::getInstance().releaseUseHostPtrBuffer(
|
||||
buffer);
|
||||
}
|
||||
|
||||
static std::shared_ptr<smo::compute::ComputeDevice> ComputeManager_getDevice()
|
||||
{
|
||||
return smo::compute::ComputeManager::getInstance().getDevice();
|
||||
}
|
||||
|
||||
static void ComputeManager_releaseDevice(
|
||||
std::shared_ptr<smo::compute::ComputeDevice> device
|
||||
)
|
||||
{
|
||||
smo::compute::ComputeManager::getInstance().releaseDevice(device);
|
||||
}
|
||||
|
||||
/* Hooks to be provided to stimBuffApiLibs, enabling them to call into Salmanoff
|
||||
* code.
|
||||
*/
|
||||
@@ -92,7 +123,13 @@ static SmoCallbacks smoCallbacks =
|
||||
{
|
||||
.searchForLibInSmoSearchPaths = searchForLibInSmoSearchPaths,
|
||||
.ComponentThread_getSelf = ComponentThread_getSelf,
|
||||
.OptionParser_getOptions = OptionParser_getOptions
|
||||
.OptionParser_getOptions = OptionParser_getOptions,
|
||||
.ComputeManager_createUseHostPtrBuffer =
|
||||
ComputeManager_createUseHostPtrBuffer,
|
||||
.ComputeManager_releaseUseHostPtrBuffer =
|
||||
ComputeManager_releaseUseHostPtrBuffer,
|
||||
.ComputeManager_getDevice = ComputeManager_getDevice,
|
||||
.ComputeManager_releaseDevice = ComputeManager_releaseDevice
|
||||
};
|
||||
|
||||
/* Static file-scope threading model object for senseApi libraries */
|
||||
|
||||
Reference in New Issue
Block a user