2
0
mirror of https://github.com/boostorg/compute.git synced 2026-02-19 14:22:12 +00:00

Add device::platform() method

This commit is contained in:
Kyle Lutz
2014-12-13 11:25:11 -08:00
parent a29f453687
commit 2bab2c5ee7
8 changed files with 26 additions and 20 deletions

View File

@@ -12,6 +12,7 @@
#define BOOST_COMPUTE_DETAIL_VENDOR_HPP
#include <boost/compute/device.hpp>
#include <boost/compute/platform.hpp>
namespace boost {
namespace compute {
@@ -26,11 +27,7 @@ inline bool is_nvidia_device(const device &device)
// returns true if the device is an amd cpu or gpu
inline bool is_amd_device(const device &device)
{
platform device_platform(
device.get_info<cl_platform_id>(CL_DEVICE_PLATFORM)
);
return device_platform.vendor() == "Advanced Micro Devices, Inc.";
return device.platform().vendor() == "Advanced Micro Devices, Inc.";
}
} // end detail namespace

View File

@@ -26,6 +26,8 @@
namespace boost {
namespace compute {
class platform;
/// \class device
/// \brief A compute device.
///
@@ -155,6 +157,13 @@ public:
return get_info<cl_device_type>(CL_DEVICE_TYPE);
}
#ifdef BOOST_COMPUTE_DOXYGEN_INVOKED
/// Returns the platform for the device.
platform platform() const;
#else
boost::compute::platform platform() const;
#endif
/// Returns the name of the device.
std::string name() const
{

View File

@@ -222,6 +222,11 @@ BOOST_COMPUTE_DETAIL_DEFINE_GET_INFO_SPECIALIZATIONS(platform,
((std::string, CL_PLATFORM_EXTENSIONS))
)
inline boost::compute::platform device::platform() const
{
return boost::compute::platform(get_info<CL_DEVICE_PLATFORM>());
}
} // end compute namespace
} // end boost namespace

View File

@@ -508,7 +508,7 @@ public:
std::string hash;
{
device d(context.get_device());
platform p(d.get_info<cl_platform_id>(CL_DEVICE_PLATFORM));
platform p = d.platform();
std::ostringstream src;
src << "// " << p.name() << " v" << p.version() << "\n"

View File

@@ -219,7 +219,7 @@ private:
if (device.type() != device::cpu)
continue;
if (platform && !matches(device_platform(device).name(), platform))
if (platform && !matches(device.platform().name(), platform))
continue;
if (vendor && !matches(device.vendor(), vendor))
@@ -247,12 +247,6 @@ private:
return devices_[0];
}
/// \internal_
static platform device_platform(const device &device)
{
return platform(device.get_info<cl_platform_id>(CL_DEVICE_PLATFORM));
}
/// \internal_
static bool matches(const std::string &str, const std::string &pattern)
{