clover: Switch platform objects to the new model.

Tested-by: Tom Stellard <thomas.stellard@amd.com>
This commit is contained in:
Francisco Jerez 2013-09-16 18:26:04 -07:00
parent bff60c894a
commit 49a49e0742
7 changed files with 52 additions and 51 deletions

View file

@ -27,9 +27,10 @@
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) ||
@ -37,9 +38,9 @@ clGetDeviceIDs(cl_platform_id platform, cl_device_type device_type,
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);
}
@ -254,7 +255,7 @@ clGetDeviceInfo(cl_device_id dev, cl_device_info param,
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:

View file

@ -30,29 +30,28 @@ namespace {
}
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;

View file

@ -32,7 +32,7 @@
namespace clover {
typedef struct _cl_device_id device;
typedef struct _cl_platform_id platform;
struct platform;
class root_resource;
class hard_event;
}

View file

@ -42,7 +42,7 @@ namespace clover {
class image;
class image2d;
class image3d;
typedef struct _cl_platform_id platform;
class platform;
typedef struct _cl_program program;
typedef struct _cl_sampler sampler;

View file

@ -179,4 +179,7 @@ namespace clover {
}
}
struct _cl_platform_id :
public clover::descriptor<clover::platform, _cl_platform_id> {};
#endif

View file

@ -24,7 +24,7 @@
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);

View file

@ -29,38 +29,36 @@
#include "core/device.hpp"
namespace clover {
typedef struct _cl_platform_id platform;
class platform : public _cl_platform_id {
public:
typedef std::vector<device>::iterator iterator;
platform();
///
/// Container of all compute devices that are available in the platform.
///
/// @{
iterator begin() {
return devs.begin();
}
iterator end() {
return devs.end();
}
device &front() {
return devs.front();
}
device &back() {
return devs.back();
}
/// @}
protected:
std::vector<device> devs;
};
}
struct _cl_platform_id {
public:
typedef std::vector<clover::device>::iterator iterator;
_cl_platform_id();
///
/// Container of all compute devices that are available in the platform.
///
/// @{
iterator begin() {
return devs.begin();
}
iterator end() {
return devs.end();
}
clover::device &front() {
return devs.front();
}
clover::device &back() {
return devs.back();
}
/// @}
protected:
std::vector<clover::device> devs;
};
#endif