Skip to content

Commit 985ee7e

Browse files
committed
update spirv prober to new device setup helpers
1 parent 3d8fee4 commit 985ee7e

2 files changed

Lines changed: 8 additions & 30 deletions

File tree

samples/spirv/01_spirvprobe/main.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,15 @@ bool do_test(
125125

126126
int main(int argc, char** argv)
127127
{
128+
bool verbose = false;
128129
int platformIndex = 0;
129130
int deviceIndex = 0;
130131

131132
bool build = false;
132133

133134
{
134135
popl::OptionParser op("Supported Options");
136+
op.add<popl::Switch, popl::Attribute::advanced>("v", "verbose", "Verbose Output", &verbose);
135137
op.add<popl::Value<int>>("p", "platform", "Platform Index", platformIndex, &platformIndex);
136138
op.add<popl::Value<int>>("d", "device", "Device Index", deviceIndex, &deviceIndex);
137139
op.add<popl::Switch>("b", "build", "Build the programs vs. dumping files", &build);
@@ -152,24 +154,11 @@ int main(int argc, char** argv)
152154
}
153155
}
154156

155-
std::vector<cl::Platform> platforms;
156-
cl::Platform::get(&platforms);
157-
158-
if (!checkPlatformIndex(platforms, platformIndex)) {
157+
cl::Device device;
158+
if (!setupDevice(device, platformIndex, deviceIndex, verbose)) {
159159
return -1;
160160
}
161161

162-
cl::Platform& platform = platforms[platformIndex];
163-
printf("Running on platform: %s\n",
164-
platform.getInfo<CL_PLATFORM_NAME>().c_str() );
165-
166-
std::vector<cl::Device> devices;
167-
platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
168-
169-
cl::Device& device = devices[deviceIndex];
170-
printf("Running on device: %s\n",
171-
device.getInfo<CL_DEVICE_NAME>().c_str() );
172-
173162
cl::Context context{device};
174163

175164
cl_version spvVersion = 0;

samples/spirv/01_spirvquerycheck/main.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,13 @@ bool do_test(
103103

104104
int main(int argc, char** argv)
105105
{
106+
bool verbose = false;
106107
int platformIndex = 0;
107108
int deviceIndex = 0;
108109

109110
{
110111
popl::OptionParser op("Supported Options");
112+
op.add<popl::Switch, popl::Attribute::advanced>("v", "verbose", "Verbose Output", &verbose);
111113
op.add<popl::Value<int>>("p", "platform", "Platform Index", platformIndex, &platformIndex);
112114
op.add<popl::Value<int>>("d", "device", "Device Index", deviceIndex, &deviceIndex);
113115

@@ -127,24 +129,11 @@ int main(int argc, char** argv)
127129
}
128130
}
129131

130-
std::vector<cl::Platform> platforms;
131-
cl::Platform::get(&platforms);
132-
133-
if (!checkPlatformIndex(platforms, platformIndex)) {
132+
cl::Device device;
133+
if (!setupDevice(device, platformIndex, deviceIndex, verbose)) {
134134
return -1;
135135
}
136136

137-
cl::Platform& platform = platforms[platformIndex];
138-
printf("Running on platform: %s\n",
139-
platform.getInfo<CL_PLATFORM_NAME>().c_str() );
140-
141-
std::vector<cl::Device> devices;
142-
platform.getDevices(CL_DEVICE_TYPE_ALL, &devices);
143-
144-
cl::Device& device = devices[deviceIndex];
145-
printf("Running on device: %s\n",
146-
device.getInfo<CL_DEVICE_NAME>().c_str() );
147-
148137
cl::Context context{device};
149138

150139
cl_version spvVersion = 0;

0 commit comments

Comments
 (0)