Skip to content

Commit 9d74846

Browse files
authored
[SYCL] Add handling of SYCL_PROGRAM_(LINK/COMPILE)_OPTIONS in the program methods (#3061)
Signed-off-by: mdimakov <[email protected]>
1 parent f75b439 commit 9d74846

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

sycl/source/detail/config.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ CONFIG(SYCL_BE, 16, __SYCL_BE)
1717
CONFIG(SYCL_PI_TRACE, 16, __SYCL_PI_TRACE)
1818
CONFIG(SYCL_DEVICELIB_NO_FALLBACK, 1, __SYCL_DEVICELIB_NO_FALLBACK)
1919
CONFIG(SYCL_DEVICE_FILTER, 1024, __SYCL_DEVICE_FILTER)
20+
CONFIG(SYCL_PROGRAM_LINK_OPTIONS, 64, __SYCL_PROGRAM_LINK_OPTIONS)
21+
CONFIG(SYCL_PROGRAM_COMPILE_OPTIONS, 64, __SYCL_PROGRAM_COMPILE_OPTIONS)

sycl/source/detail/program_impl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <CL/sycl/detail/pi.h>
1212
#include <CL/sycl/kernel.hpp>
1313
#include <CL/sycl/property_list.hpp>
14+
#include <detail/config.hpp>
1415
#include <detail/kernel_impl.hpp>
1516
#include <detail/program_impl.hpp>
1617
#include <detail/spec_constant_impl.hpp>
@@ -291,9 +292,13 @@ void program_impl::link(string_class LinkOptions) {
291292
check_device_feature_support<info::device::is_linker_available>(MDevices);
292293
vector_class<RT::PiDevice> Devices(get_pi_devices());
293294
const detail::plugin &Plugin = getPlugin();
295+
const char *LinkOpts = SYCLConfig<SYCL_PROGRAM_LINK_OPTIONS>::get();
296+
if (!LinkOpts) {
297+
LinkOpts = LinkOptions.c_str();
298+
}
294299
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramLink>(
295-
MContext->getHandleRef(), Devices.size(), Devices.data(),
296-
LinkOptions.c_str(), 1, &MProgram, nullptr, nullptr, &MProgram);
300+
MContext->getHandleRef(), Devices.size(), Devices.data(), LinkOpts,
301+
/*num_input_programs*/ 1, &MProgram, nullptr, nullptr, &MProgram);
297302
Plugin.checkPiResult<compile_program_error>(Err);
298303
MLinkOptions = LinkOptions;
299304
MBuildOptions = LinkOptions;
@@ -363,8 +368,12 @@ void program_impl::compile(const string_class &Options) {
363368
check_device_feature_support<info::device::is_compiler_available>(MDevices);
364369
vector_class<RT::PiDevice> Devices(get_pi_devices());
365370
const detail::plugin &Plugin = getPlugin();
371+
const char *CompileOpts = SYCLConfig<SYCL_PROGRAM_COMPILE_OPTIONS>::get();
372+
if (!CompileOpts) {
373+
CompileOpts = Options.c_str();
374+
}
366375
RT::PiResult Err = Plugin.call_nocheck<PiApiKind::piProgramCompile>(
367-
MProgram, Devices.size(), Devices.data(), Options.c_str(), 0, nullptr,
376+
MProgram, Devices.size(), Devices.data(), CompileOpts, 0, nullptr,
368377
nullptr, nullptr, nullptr);
369378

370379
if (Err != PI_SUCCESS) {

0 commit comments

Comments
 (0)