using namespace clover;
PUBLIC cl_int
-clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
+clGetDeviceIDs(cl_platform_id d_platform, cl_device_type device_type,
cl_uint num_entries, cl_device_id *devices,
cl_uint *num_devices) {
+ auto &platform = obj(d_platform);
std::vector<cl_device_id> devs;
if ((!num_entries && devices) ||
return CL_INVALID_VALUE;
// Collect matching devices
- for (device &dev : *platform) {
+ for (device &dev : platform) {
if (((device_type & CL_DEVICE_TYPE_DEFAULT) &&
- &dev == &platform->front()) ||
+ &dev == &platform.front()) ||
(device_type & dev.type()))
devs.push_back(&dev);
}
break;
case CL_DEVICE_PLATFORM:
- buf.as_scalar<cl_platform_id>() = &dev->platform;
+ buf.as_scalar<cl_platform_id>() = desc(dev->platform);
break;
case CL_DEVICE_HOST_UNIFIED_MEMORY:
}
PUBLIC cl_int
-clGetPlatformIDs(cl_uint num_entries, cl_platform_id *platforms,
- cl_uint *num_platforms) {
- if ((!num_entries && platforms) ||
- (!num_platforms && !platforms))
+clGetPlatformIDs(cl_uint num_entries, cl_platform_id *rd_platforms,
+ cl_uint *rnum_platforms) {
+ if ((!num_entries && rd_platforms) ||
+ (!rnum_platforms && !rd_platforms))
return CL_INVALID_VALUE;
- if (num_platforms)
- *num_platforms = 1;
- if (platforms)
- *platforms = &_clover_platform;
+ if (rnum_platforms)
+ *rnum_platforms = 1;
+ if (rd_platforms)
+ *rd_platforms = desc(_clover_platform);
return CL_SUCCESS;
}
PUBLIC cl_int
-clGetPlatformInfo(cl_platform_id platform, cl_platform_info param_name,
+clGetPlatformInfo(cl_platform_id d_platform, cl_platform_info param,
size_t size, void *r_buf, size_t *r_size) try {
property_buffer buf { r_buf, size, r_size };
- if (platform != &_clover_platform)
- return CL_INVALID_PLATFORM;
+ obj(d_platform);
- switch (param_name) {
+ switch (param) {
case CL_PLATFORM_PROFILE:
buf.as_string() = "FULL_PROFILE";
break;
namespace clover {
typedef struct _cl_device_id device;
- typedef struct _cl_platform_id platform;
+ struct platform;
class root_resource;
class hard_event;
}
class image;
class image2d;
class image3d;
- typedef struct _cl_platform_id platform;
+ class platform;
typedef struct _cl_program program;
typedef struct _cl_sampler sampler;
}
}
+struct _cl_platform_id :
+ public clover::descriptor<clover::platform, _cl_platform_id> {};
+
#endif
using namespace clover;
-_cl_platform_id::_cl_platform_id() {
+platform::platform() {
int n = pipe_loader_probe(NULL, 0);
std::vector<pipe_loader_device *> ldevs(n);
#include "core/device.hpp"
namespace clover {
- typedef struct _cl_platform_id platform;
-}
-
-struct _cl_platform_id {
-public:
- typedef std::vector<clover::device>::iterator iterator;
+ class platform : public _cl_platform_id {
+ public:
+ typedef std::vector<device>::iterator iterator;
- _cl_platform_id();
+ platform();
- ///
- /// Container of all compute devices that are available in the platform.
- ///
- /// @{
- iterator begin() {
- return devs.begin();
- }
+ ///
+ /// Container of all compute devices that are available in the platform.
+ ///
+ /// @{
+ iterator begin() {
+ return devs.begin();
+ }
- iterator end() {
- return devs.end();
- }
+ iterator end() {
+ return devs.end();
+ }
- clover::device &front() {
- return devs.front();
- }
+ device &front() {
+ return devs.front();
+ }
- clover::device &back() {
- return devs.back();
- }
- /// @}
+ device &back() {
+ return devs.back();
+ }
+ /// @}
-protected:
- std::vector<clover::device> devs;
-};
+ protected:
+ std::vector<device> devs;
+ };
+}
#endif