Skip to content

Commit 9290195

Browse files
committed
Remove unnecesary OpenCL kernel compilation to 3.0
1 parent cbb6f0c commit 9290195

File tree

2 files changed

+6
-50
lines changed

2 files changed

+6
-50
lines changed

samples/extensions/khr/externalmemory/main.c

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -354,36 +354,10 @@ int main(int argc, char* argv[])
354354
context, 1, (const char**)&kernel, &program_size, &error),
355355
error, ker);
356356

357-
// The Khronos extension showcased requires OpenCL 3.0 version.
358-
// Get number of versions supported.
359-
size_t versions_size = 0;
360-
OCLERROR_RET(clGetDeviceInfo(cl_device, CL_DEVICE_OPENCL_C_ALL_VERSIONS, 0,
361-
NULL, &versions_size),
362-
error, prg);
363-
size_t versions_count = versions_size / sizeof(cl_name_version);
364-
365-
// Get and check versions.
366-
cl_name_version* dev_versions = (cl_name_version*)malloc(versions_size);
367-
OCLERROR_RET(clGetDeviceInfo(cl_device, CL_DEVICE_OPENCL_C_ALL_VERSIONS,
368-
versions_size, dev_versions, NULL),
369-
error, prg);
370-
char compiler_options[1024] = "";
371-
for (cl_uint i = 0; i < versions_count; ++i)
372-
{
373-
if (opencl_version_is_major(&dev_versions[i], 3))
374-
{
375-
strcat(compiler_options, "-cl-std=CL3.0 ");
376-
}
377-
}
378-
379-
if (compiler_options[0] == '\0')
380-
{
381-
fprintf(stderr, "\nError: OpenCL version must be at least 3.0\n");
382-
exit(EXIT_FAILURE);
383-
}
384-
385-
OCLERROR_RET(cl_util_build_program(program, cl_device, compiler_options),
386-
error, prg);
357+
// Build OpenCL executable.
358+
OCLERROR_RET(
359+
cl_util_build_program(program, cl_device, NULL /*compiler_options*/),
360+
error, prg);
387361

388362
// Query maximum workgroup size (WGS) supported based on private mem
389363
// (registers) constraints.

samples/extensions/khr/externalmemory/main.cpp

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -271,26 +271,8 @@ int main(int argc, char* argv[])
271271
std::istreambuf_iterator<char>{} }
272272
};
273273

274-
// The Khronos extension showcased requires OpenCL 3.0 version.
275-
cl::string compiler_options = "";
276-
std::vector<cl_name_version> dev_versions =
277-
cl_device.getInfo<CL_DEVICE_OPENCL_C_ALL_VERSIONS>();
278-
for (cl_name_version dev_name_version : dev_versions)
279-
{
280-
if (opencl_version_is_major(dev_name_version, 3))
281-
{
282-
compiler_options += cl::string{ "-cl-std=CL3.0 " };
283-
}
284-
}
285-
286-
if (compiler_options.empty())
287-
{
288-
std::cerr << "\nError: OpenCL version must be at least 3.0"
289-
<< std::endl;
290-
exit(EXIT_FAILURE);
291-
}
292-
293-
cl_program.build(cl_device, compiler_options.c_str());
274+
// Build OpenCL executable.
275+
cl_program.build(cl_device);
294276

295277
// Query maximum workgroup size (WGS) supported based on private mem
296278
// (registers) constraints.

0 commit comments

Comments
 (0)