@@ -762,58 +762,102 @@ DPCTLKernelBundle_Copy(__dpctl_keep const DPCTLSyclKernelBundleRef KBRef)
762
762
}
763
763
}
764
764
765
+ using build_option_list_t = std::vector<std::string>;
766
+
765
767
__dpctl_give DPCTLBuildOptionListRef DPCTLBuildOptionList_Create ()
766
768
{
767
- return new DPCTLBuildOptionList;
769
+ auto BuildOptionList =
770
+ std::unique_ptr<build_option_list_t >(new build_option_list_t ());
771
+ auto *RetVal =
772
+ reinterpret_cast <DPCTLBuildOptionListRef>(BuildOptionList.get ());
773
+ BuildOptionList.release ();
774
+ return RetVal;
768
775
}
769
776
770
777
void DPCTLBuildOptionList_Delete (__dpctl_take DPCTLBuildOptionListRef Ref)
771
778
{
772
- delete Ref;
779
+ delete reinterpret_cast < build_option_list_t *>( Ref) ;
773
780
}
774
781
775
782
void DPCTLBuildOptionList_Append (__dpctl_keep DPCTLBuildOptionListRef Ref,
776
783
__dpctl_keep const char *Option)
777
784
{
778
- Ref-> options . emplace_back (Option);
785
+ reinterpret_cast < build_option_list_t *>( Ref)-> emplace_back (Option);
779
786
}
780
787
788
+ using kernel_name_list_t = std::vector<std::string>;
789
+
781
790
__dpctl_give DPCTLKernelNameListRef DPCTLKernelNameList_Create ()
782
791
{
783
- return new DPCTLKernelNameList;
792
+ auto KernelNameList =
793
+ std::unique_ptr<kernel_name_list_t >(new kernel_name_list_t ());
794
+ auto *RetVal =
795
+ reinterpret_cast <DPCTLKernelNameListRef>(KernelNameList.get ());
796
+ KernelNameList.release ();
797
+ return RetVal;
784
798
}
785
799
786
800
void DPCTLKernelNameList_Delete (__dpctl_take DPCTLKernelNameListRef Ref)
787
801
{
788
- delete Ref;
802
+ delete reinterpret_cast < kernel_name_list_t *>( Ref) ;
789
803
}
790
804
791
805
void DPCTLKernelNameList_Append (__dpctl_keep DPCTLKernelNameListRef Ref,
792
806
__dpctl_keep const char *Option)
793
807
{
794
- Ref-> names . emplace_back (Option);
808
+ reinterpret_cast < kernel_name_list_t *>( Ref)-> emplace_back (Option);
795
809
}
796
810
811
+ using virtual_header_list_t = std::vector<std::pair<std::string, std::string>>;
812
+
797
813
__dpctl_give DPCTLVirtualHeaderListRef DPCTLVirtualHeaderList_Create ()
798
814
{
799
- return new DPCTLVirtualHeaderList;
815
+ auto HeaderList =
816
+ std::unique_ptr<virtual_header_list_t >(new virtual_header_list_t ());
817
+ auto *RetVal =
818
+ reinterpret_cast <DPCTLVirtualHeaderListRef>(HeaderList.get ());
819
+ HeaderList.release ();
820
+ return RetVal;
800
821
}
801
822
802
823
void DPCTLVirtualHeaderList_Delete (__dpctl_take DPCTLVirtualHeaderListRef Ref)
803
824
{
804
- delete Ref;
825
+ delete reinterpret_cast < virtual_header_list_t *>( Ref) ;
805
826
}
806
827
807
828
void DPCTLVirtualHeaderList_Append (__dpctl_keep DPCTLVirtualHeaderListRef Ref,
808
829
__dpctl_keep const char *Name,
809
830
__dpctl_keep const char *Content)
810
831
{
811
832
auto Header = std::make_pair<std::string, std::string>(Name, Content);
812
- Ref-> headers . push_back (Header);
833
+ reinterpret_cast < virtual_header_list_t *>( Ref)-> push_back (Header);
813
834
}
814
835
815
836
namespace syclex = sycl::ext::oneapi::experimental;
816
837
838
+ #if defined(SYCL_EXT_ONEAPI_KERNEL_COMPILER) && \
839
+ defined (__SYCL_COMPILER_VERSION) && !defined(SUPPORTS_SYCL_COMPILATION)
840
+ // SYCL source code compilation is supported from 2025.1 onwards.
841
+ #if __SYCL_COMPILER_VERSION >= 20250317u
842
+ #define SUPPORTS_SYCL_COMPILATION 1
843
+ #else
844
+ #define SUPPORTS_SYCL_COMPILATION 0
845
+ #endif
846
+ #endif
847
+
848
+ #if (SUPPORTS_SYCL_COMPILATION > 0)
849
+ #ifndef __SYCL_COMPILER_VERSION
850
+ #error SYCL compiler version not defined
851
+ #else
852
+ // The property was renamed to `registered_names` after 2025.1
853
+ #if __SYCL_COMPILER_VERSION > 20250317u
854
+ using registered_names_property_t = syclex::registered_names;
855
+ #else
856
+ using registered_names_property_t = syclex::registered_kernel_names;
857
+ #endif
858
+ #endif
859
+ #endif
860
+
817
861
__dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource (
818
862
__dpctl_keep const DPCTLSyclContextRef Ctx,
819
863
__dpctl_keep const DPCTLSyclDeviceRef Dev,
@@ -822,15 +866,17 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
822
866
__dpctl_keep DPCTLKernelNameListRef Names,
823
867
__dpctl_keep DPCTLBuildOptionListRef BuildOptions)
824
868
{
825
- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
869
+ #if (SUPPORTS_SYCL_COMPILATION > 0)
826
870
context *SyclCtx = unwrap<context>(Ctx);
827
871
device *SyclDev = unwrap<device>(Dev);
828
872
if (!SyclDev->ext_oneapi_can_compile (syclex::source_language::sycl)) {
829
873
return nullptr ;
830
874
}
831
875
try {
832
876
syclex::include_files IncludeFiles;
833
- for (auto &Include : Headers->headers ) {
877
+ for (auto &Include :
878
+ *reinterpret_cast <virtual_header_list_t *>(Headers))
879
+ {
834
880
const auto &[Name, Content] = Include;
835
881
IncludeFiles.add (Name, Content);
836
882
}
@@ -840,12 +886,15 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
840
886
*SyclCtx, syclex::source_language::sycl, Src,
841
887
syclex::properties{IncludeFiles});
842
888
843
- syclex::registered_names RegisteredNames;
844
- for (const std::string &Name : Names->names ) {
889
+ registered_names_property_t RegisteredNames;
890
+ for (const std::string &Name :
891
+ *reinterpret_cast <kernel_name_list_t *>(Names))
892
+ {
845
893
RegisteredNames.add (Name);
846
894
}
847
895
848
- syclex::build_options Opts{BuildOptions->options };
896
+ syclex::build_options Opts{
897
+ *reinterpret_cast <build_option_list_t *>(BuildOptions)};
849
898
850
899
std::vector<sycl::device> Devices ({*SyclDev});
851
900
@@ -869,7 +918,7 @@ __dpctl_give DPCTLSyclKernelRef
869
918
DPCTLKernelBundle_GetSyclKernel (__dpctl_keep DPCTLSyclKernelBundleRef KBRef,
870
919
__dpctl_keep const char *KernelName)
871
920
{
872
- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
921
+ #if (SUPPORTS_SYCL_COMPILATION > 0)
873
922
try {
874
923
auto KernelBundle =
875
924
unwrap<sycl::kernel_bundle<bundle_state::executable>>(KBRef);
@@ -888,7 +937,7 @@ bool DPCTLKernelBundle_HasSyclKernel(__dpctl_keep DPCTLSyclKernelBundleRef
888
937
KBRef,
889
938
__dpctl_keep const char *KernelName)
890
939
{
891
- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
940
+ #if (SUPPORTS_SYCL_COMPILATION > 0)
892
941
try {
893
942
auto KernelBundle =
894
943
unwrap<sycl::kernel_bundle<bundle_state::executable>>(KBRef);
0 commit comments