Use std::string for get_device_*_string helpers (#737)

* Use std::string for get_device_*_string helpers

Removes need to use BufferOwningPtr to avoid memory leaks.

* Rename get_device_info to get_device_info_string

Makes it more obvious that it should only be called for device queries
that return strings.

* Tokenize extensions in is_extension_available

Avoids the potential issue where one extension name is a prefix of
another.

* Throw exception when device info size is 0
This commit is contained in:
James Price
2020-04-16 14:27:40 -04:00
committed by GitHub
parent c911046f5b
commit 2ac3c2c1ef
3 changed files with 44 additions and 53 deletions

View File

@@ -19,6 +19,8 @@
// Configuration
#include "../config.hpp"
#include <string>
#include <CL/opencl.h>
#ifdef __cplusplus
@@ -28,14 +30,14 @@ extern "C" {
/* Determines if an extension is supported by a device. */
int is_extension_available(cl_device_id device, const char *extensionName);
/* Returns a newly allocated C string containing the supported extensions list for a device. */
char *alloc_and_get_device_extensions_string(cl_device_id device);
/* Returns a string containing the supported extensions list for a device. */
std::string get_device_extensions_string(cl_device_id device);
/* Returns a newly allocated C string containing the supported IL version(s) for a device. */
char *alloc_and_get_device_il_version_string(cl_device_id device);
/* Returns a string containing the supported IL version(s) for a device. */
std::string get_device_il_version_string(cl_device_id device);
/* Returns a newly allocated C string containing the supported OpenCL version for a device. */
char *alloc_and_get_device_version_string(cl_device_id device);
/* Returns a string containing the supported OpenCL version for a device. */
std::string get_device_version_string(cl_device_id device);
#ifdef __cplusplus
}