Skip to content

Commit 64d1380

Browse files
committed
apply comments and fix test.
Signed-off-by: Vlad Romanov <[email protected]>
1 parent 16a24b0 commit 64d1380

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

sycl/source/detail/platform_impl.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ struct DevDescT {
5959
const char *devDriverVer = nullptr;
6060
int devDriverVerSize = 0;
6161

62-
const char *pltName = nullptr;
63-
int pltNameSize = 0;
62+
const char *platformName = nullptr;
63+
int platformNameSize = 0;
6464

65-
const char *pltVer = nullptr;
66-
int pltVerSize = 0;
65+
const char *platformVer = nullptr;
66+
int platformVerSize = 0;
6767
};
6868

6969
static std::vector<DevDescT> getWhiteListDesc() {
@@ -76,7 +76,7 @@ static std::vector<DevDescT> getWhiteListDesc() {
7676
std::vector<DevDescT> decDescs;
7777
const char devNameStr[] = "DeviceName";
7878
const char driverVerStr[] = "DriverVersion";
79-
const char pltNameStr[] = "PlatformName";
79+
const char platformNameStr[] = "PlatformName";
8080
const char platformVerStr[] = "PlatformVersion";
8181
decDescs.emplace_back();
8282
while ('\0' != *str) {
@@ -88,13 +88,14 @@ static std::vector<DevDescT> getWhiteListDesc() {
8888
valuePtr = &decDescs.back().devName;
8989
size = &decDescs.back().devNameSize;
9090
str += sizeof(devNameStr) - 1;
91-
} else if (0 == strncmp(pltNameStr, str, sizeof(pltNameStr) - 1)) {
92-
valuePtr = &decDescs.back().pltName;
93-
size = &decDescs.back().pltNameSize;
94-
str += sizeof(pltNameStr) - 1;
91+
} else if (0 ==
92+
strncmp(platformNameStr, str, sizeof(platformNameStr) - 1)) {
93+
valuePtr = &decDescs.back().platformName;
94+
size = &decDescs.back().platformNameSize;
95+
str += sizeof(platformNameStr) - 1;
9596
} else if (0 == strncmp(platformVerStr, str, sizeof(platformVerStr) - 1)) {
96-
valuePtr = &decDescs.back().pltVer;
97-
size = &decDescs.back().pltVerSize;
97+
valuePtr = &decDescs.back().platformVer;
98+
size = &decDescs.back().platformVerSize;
9899
str += sizeof(platformVerStr) - 1;
99100
} else if (0 == strncmp(driverVerStr, str, sizeof(driverVerStr) - 1)) {
100101
valuePtr = &decDescs.back().devDriverVer;
@@ -149,31 +150,34 @@ static void filterWhiteList(vector_class<RT::PiDevice> &pi_devices,
149150
if (whiteList.empty())
150151
return;
151152

152-
const string_class pltName =
153+
const string_class platformName =
153154
sycl::detail::get_platform_info<string_class, info::platform::name>::get(
154155
pi_platform);
155156

156-
const string_class pltVer = sycl::detail::get_platform_info<
157+
const string_class platformVer = sycl::detail::get_platform_info<
157158
string_class, info::platform::version>::get(pi_platform);
158159

159160
int insertIDx = 0;
160161
for (RT::PiDevice dev : pi_devices) {
161162
const string_class devName =
162-
sycl::detail::get_device_info<string_class, info::device::name>::get(dev);
163+
sycl::detail::get_device_info<string_class, info::device::name>::get(
164+
dev);
163165

164166
const string_class devDriverVer =
165167
sycl::detail::get_device_info<string_class,
166168
info::device::driver_version>::get(dev);
167169

168170
for (const DevDescT &desc : whiteList) {
169-
if (nullptr != desc.pltName &&
170-
!std::regex_match(
171-
pltName, std::regex(std::string(desc.pltName, desc.pltNameSize))))
171+
if (nullptr != desc.platformName &&
172+
!std::regex_match(platformName,
173+
std::regex(std::string(desc.platformName,
174+
desc.platformNameSize))))
172175
continue;
173176

174-
if (nullptr != desc.pltVer &&
177+
if (nullptr != desc.platformVer &&
175178
!std::regex_match(
176-
pltVer, std::regex(std::string(desc.pltVer, desc.pltVerSize))))
179+
platformVer,
180+
std::regex(std::string(desc.platformVer, desc.platformVerSize))))
177181
continue;
178182

179183
if (nullptr != desc.devName &&

sycl/test/config/white_list.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@
1717

1818
using namespace cl;
1919

20-
static void replaceEscapeCharacters(std::string &Str) {
21-
// As a stringwill be used as regexp pattern, we need to get rid of symbols
22-
// that can be treated in a special way. Replace common special symbols with
23-
// '.' which matches to any character
20+
static void replaceSpecialCharacters(std::string &Str) {
21+
//Replace common special symbols with '.' which matches to any character
2422
std::replace_if(Str.begin(), Str.end(),
2523
[](const char Sym) { return '(' == Sym || ')' == Sym; }, '.');
2624
}
@@ -33,10 +31,11 @@ int main() {
3331
if (!Plt.is_host()) {
3432

3533
std::string Name = Plt.get_info<sycl::info::platform::name>();
36-
const std::string Ver =
37-
Plt.get_info<sycl::info::platform::version>();
38-
39-
replaceEscapeCharacters(Name);
34+
std::string Ver = Plt.get_info<sycl::info::platform::version>();
35+
// As a string will be used as regexp pattern, we need to get rid of
36+
// symbols that can be treated in a special way.
37+
replaceSpecialCharacters(Name);
38+
replaceSpecialCharacters(Ver);
4039

4140
std::cout << "SYCL_DEVICE_WHITE_LIST=PlatformName:{{" << Name
4241
<< "}},PlatformVersion:{{" << Ver << "}}";
@@ -52,10 +51,12 @@ int main() {
5251
if (!Plt.is_host()) {
5352
const sycl::device Dev = Plt.get_devices().at(0);
5453
std::string Name = Dev.get_info<sycl::info::device::name>();
55-
const std::string Ver =
56-
Dev.get_info<sycl::info::device::driver_version>();
54+
std::string Ver = Dev.get_info<sycl::info::device::driver_version>();
5755

58-
replaceEscapeCharacters(Name);
56+
// As a string will be used as regexp pattern, we need to get rid of
57+
// symbols that can be treated in a special way.
58+
replaceSpecialCharacters(Name);
59+
replaceSpecialCharacters(Ver);
5960

6061
std::cout << "SYCL_DEVICE_WHITE_LIST=DeviceName:{{" << Name
6162
<< "}},DriverVersion:{{" << Ver << "}}";

0 commit comments

Comments
 (0)