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:
@@ -6,9 +6,12 @@
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <preprocessor.h>
|
||||
#include <user/deviceAttachmentSpec.h>
|
||||
#include <callback.h>
|
||||
#define CL_TARGET_OPENCL_VERSION 120
|
||||
#include <CL/cl.h>
|
||||
|
||||
class OptionParser;
|
||||
|
||||
@@ -16,6 +19,11 @@ namespace smo {
|
||||
|
||||
class ComponentThread;
|
||||
|
||||
namespace compute {
|
||||
class ClBuffer;
|
||||
class ComputeDevice;
|
||||
} // namespace compute
|
||||
|
||||
namespace stim_buff {
|
||||
|
||||
/**
|
||||
@@ -92,6 +100,38 @@ struct SmoCallbacks
|
||||
* equivalent to calling OptionParser::getOptions().
|
||||
*/
|
||||
OptionParser& (*OptionParser_getOptions)(void);
|
||||
|
||||
/**
|
||||
* @brief Create a USE_HOST_PTR buffer on all OpenCL contexts
|
||||
* @param hostPtr Host pointer to the memory
|
||||
* @param size Size of the buffer in bytes
|
||||
* @param flags Additional OpenCL memory flags
|
||||
* @return Shared pointer to ClBuffer managing buffers on all devices
|
||||
*/
|
||||
std::shared_ptr<smo::compute::ClBuffer>
|
||||
(*ComputeManager_createUseHostPtrBuffer)(
|
||||
void* hostPtr, size_t size, cl_mem_flags flags);
|
||||
|
||||
/**
|
||||
* @brief Release USE_HOST_PTR buffers from all contexts
|
||||
* @param buffer Shared pointer to ClBuffer to release
|
||||
*/
|
||||
void (*ComputeManager_releaseUseHostPtrBuffer)(
|
||||
std::shared_ptr<smo::compute::ClBuffer> buffer);
|
||||
|
||||
/**
|
||||
* @brief Get a compute device
|
||||
* @return Shared pointer to ComputeDevice, or nullptr if no devices available
|
||||
*/
|
||||
std::shared_ptr<smo::compute::ComputeDevice>
|
||||
(*ComputeManager_getDevice)(void);
|
||||
|
||||
/**
|
||||
* @brief Release a compute device
|
||||
* @param device Shared pointer to ComputeDevice to release
|
||||
*/
|
||||
void (*ComputeManager_releaseDevice)(
|
||||
std::shared_ptr<smo::compute::ComputeDevice> device);
|
||||
};
|
||||
|
||||
struct Sal_Mgmt_LibOps
|
||||
|
||||
Reference in New Issue
Block a user