Skip to content

Commit 5b6212f

Browse files
committed
Add get_platform_matching method
1 parent 8d56a00 commit 5b6212f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

oclhelpers.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ std::vector<cl::Platform> get_platforms() {
1414
return platforms;
1515
}
1616

17+
cl::Platform get_platform_matching(std::string_view s) {
18+
auto platforms = get_platforms();
19+
for (auto &p : platforms) {
20+
auto pname = p.getInfo<CL_PLATFORM_NAME>();
21+
if (pname.find(s) != std::string::npos)
22+
return p;
23+
}
24+
}
25+
1726
cl::Platform get_default_platform() { return get_platforms()[0]; }
1827

1928
std::vector<cl::Device> get_devices(const cl::Platform &p, int type) {

oclhelpers.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class OCLHelpersException : public std::runtime_error {
2828

2929
std::vector<cl::Platform> get_platforms();
3030
cl::Platform get_default_platform();
31+
cl::Platform get_platform_matching(std::string_view s);
3132

3233
std::vector<cl::Device> get_gpus(const cl::Platform &p);
3334
std::vector<cl::Device> get_cpus(const cl::Platform &p);

0 commit comments

Comments
 (0)