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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user