diff options
Diffstat (limited to 'src/clpp11.hpp')
-rw-r--r-- | src/clpp11.hpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/clpp11.hpp b/src/clpp11.hpp index 29f81cf8..e0b8cbe9 100644 --- a/src/clpp11.hpp +++ b/src/clpp11.hpp @@ -164,6 +164,10 @@ class Platform { platform_ = platforms[platform_id]; } + // Methods to retrieve platform information + std::string Name() const { return GetInfoString(CL_PLATFORM_NAME); } + std::string Vendor() const { return GetInfoString(CL_PLATFORM_VENDOR); } + // Returns the number of devices on this platform size_t NumDevices() const { auto result = cl_uint{0}; @@ -175,6 +179,17 @@ class Platform { const cl_platform_id& operator()() const { return platform_; } private: cl_platform_id platform_; + + // Private helper functions + std::string GetInfoString(const cl_device_info info) const { + auto bytes = size_t{0}; + CheckError(clGetPlatformInfo(platform_, info, 0, nullptr, &bytes)); + auto result = std::string{}; + result.resize(bytes); + CheckError(clGetPlatformInfo(platform_, info, bytes, &result[0], nullptr)); + result.resize(strlen(result.c_str())); // Removes any trailing '\0'-characters + return result; + } }; // Retrieves a vector with all platforms |