@@ -366,59 +366,50 @@ RT::PiProgram ProgramManager::createPIProgram(const RTDeviceBinaryImage &Img,
366
366
return Res;
367
367
}
368
368
369
- static void addEsimdImageCompileOptions (std::string &CompileOpts) {
370
- if (!CompileOpts.empty ())
371
- CompileOpts += " " ;
372
- CompileOpts += " -vc-codegen" ;
373
- }
374
-
375
- static void applyLinkOptionsFromImage (std::string &LinkOpts,
376
- const RTDeviceBinaryImage &Img) {
377
- if (!LinkOpts.empty ())
378
- LinkOpts += " " ;
379
- const char *TemporaryStr = Img.getLinkOptions ();
380
- if (TemporaryStr != nullptr )
381
- LinkOpts += std::string (TemporaryStr);
382
- }
383
-
384
- static void applyCompileOptionsFromImage (
385
- std::string &CompileOpts, const RTDeviceBinaryImage &Img,
386
- const pi_device_binary_property &isEsimdImage = nullptr ) {
387
- if (!CompileOpts.empty ())
388
- CompileOpts += " " ;
389
- const char *TemporaryStr = Img.getCompileOptions ();
390
- if (TemporaryStr != nullptr )
391
- CompileOpts += TemporaryStr;
392
- if (isEsimdImage) {
393
- addEsimdImageCompileOptions (CompileOpts);
369
+ static void appendLinkOptionsFromImage (std::string &LinkOpts,
370
+ const RTDeviceBinaryImage &Img) {
371
+ static const char *LinkOptsEnv = SYCLConfig<SYCL_PROGRAM_LINK_OPTIONS>::get ();
372
+ // Update only if link options are not overwritten by environment variable
373
+ if (!LinkOptsEnv) {
374
+ if (!LinkOpts.empty ())
375
+ LinkOpts += " " ;
376
+ const char *TemporaryStr = Img.getLinkOptions ();
377
+ if (TemporaryStr != nullptr )
378
+ LinkOpts += std::string (TemporaryStr);
394
379
}
395
380
}
396
381
397
- static void applyOptionsFromImage (std::string &CompileOpts,
398
- std::string &LinkOpts,
399
- const RTDeviceBinaryImage &Img) {
382
+ static void appendCompileOptionsFromImage (std::string &CompileOpts,
383
+ const RTDeviceBinaryImage &Img) {
400
384
// Build options are overridden if environment variables are present.
401
385
// Environment variables are not changed during program lifecycle so it
402
386
// is reasonable to use static here to read them only once.
403
387
static const char *CompileOptsEnv =
404
388
SYCLConfig<SYCL_PROGRAM_COMPILE_OPTIONS>::get ();
405
- static const char *LinkOptsEnv = SYCLConfig<SYCL_PROGRAM_LINK_OPTIONS>:: get ( );
389
+ pi_device_binary_property isEsimdImage = Img. getProperty ( " isEsimdImage " );
406
390
// Update only if compile options are not overwritten by environment
407
391
// variable
392
+ if (!CompileOptsEnv) {
393
+ if (!CompileOpts.empty ())
394
+ CompileOpts += " " ;
395
+ const char *TemporaryStr = Img.getCompileOptions ();
396
+ if (TemporaryStr != nullptr )
397
+ CompileOpts += std::string (TemporaryStr);
398
+ }
408
399
// The -vc-codegen option is always preserved for ESIMD kernels, regardless
409
400
// of the contents SYCL_PROGRAM_COMPILE_OPTIONS environment variable.
410
- pi_device_binary_property isEsimdImage = Img.getProperty (" isEsimdImage" );
411
- if (!CompileOptsEnv) {
412
- applyCompileOptionsFromImage (CompileOpts, Img, isEsimdImage);
413
- } else if (isEsimdImage &&
414
- pi::DeviceBinaryProperty (isEsimdImage).asUint32 ()) {
415
- addEsimdImageCompileOptions (CompileOpts);
401
+ if (isEsimdImage && pi::DeviceBinaryProperty (isEsimdImage).asUint32 ()) {
402
+ if (!CompileOpts.empty ())
403
+ CompileOpts += " " ;
404
+ CompileOpts += " -vc-codegen" ;
416
405
}
406
+ }
417
407
418
- // Update only if link options are not overwritten by environment variable
419
- if (!LinkOptsEnv) {
420
- applyLinkOptionsFromImage (LinkOpts, Img);
421
- }
408
+ static void applyOptionsFromImage (std::string &CompileOpts,
409
+ std::string &LinkOpts,
410
+ const RTDeviceBinaryImage &Img) {
411
+ appendCompileOptionsFromImage (CompileOpts, Img);
412
+ appendLinkOptionsFromImage (LinkOpts, Img);
422
413
}
423
414
424
415
static void applyOptionsFromEnvironment (std::string &CompileOpts,
@@ -1004,10 +995,9 @@ ProgramManager::ProgramPtr ProgramManager::build(
1004
995
1005
996
const detail::plugin &Plugin = Context->getPlugin ();
1006
997
if (LinkPrograms.empty () && !ForceLink) {
1007
- std::string Options = CompileOptions;
1008
- if (!LinkOptions.empty ()) {
1009
- Options += " " + LinkOptions;
1010
- }
998
+ std::string Options = LinkOptions.empty ()
999
+ ? CompileOptions
1000
+ : (CompileOptions + " " + LinkOptions);
1011
1001
RT::PiResult Error = Plugin.call_nocheck <PiApiKind::piProgramBuild>(
1012
1002
Program.get (), /* num devices =*/ 1 , &Device, Options.c_str (), nullptr ,
1013
1003
nullptr );
@@ -1693,12 +1683,12 @@ ProgramManager::compile(const device_image_plain &DeviceImage,
1693
1683
// TODO: Set spec constatns here.
1694
1684
1695
1685
// TODO: Handle zero sized Device list.
1696
-
1697
- const char *compileOptions =
1698
- InputImpl->get_bin_image_ref ()-> getCompileOptions ( );
1686
+ std::string CompileOptions;
1687
+ appendCompileOptionsFromImage (CompileOptions,
1688
+ *( InputImpl->get_bin_image_ref ()) );
1699
1689
RT::PiResult Error = Plugin.call_nocheck <PiApiKind::piProgramCompile>(
1700
1690
ObjectImpl->get_program_ref (), /* num devices=*/ Devs.size (),
1701
- PIDevices.data (), compileOptions ,
1691
+ PIDevices.data (), CompileOptions. c_str () ,
1702
1692
/* num_input_headers=*/ 0 , /* input_headers=*/ nullptr ,
1703
1693
/* header_include_names=*/ nullptr ,
1704
1694
/* pfn_notify=*/ nullptr , /* user_data*/ nullptr );
@@ -1731,8 +1721,8 @@ ProgramManager::link(const std::vector<device_image_plain> &DeviceImages,
1731
1721
for (const device_image_plain &DeviceImage : DeviceImages) {
1732
1722
const std::shared_ptr<device_image_impl> &InputImpl =
1733
1723
getSyclObjImpl (DeviceImage);
1734
- applyLinkOptionsFromImage (LinkOptionsStr,
1735
- *(InputImpl->get_bin_image_ref ()));
1724
+ appendLinkOptionsFromImage (LinkOptionsStr,
1725
+ *(InputImpl->get_bin_image_ref ()));
1736
1726
}
1737
1727
const context &Context = getSyclObjImpl (DeviceImages[0 ])->get_context ();
1738
1728
const ContextImplPtr ContextImpl = getSyclObjImpl (Context);
0 commit comments