@@ -762,58 +762,102 @@ DPCTLKernelBundle_Copy(__dpctl_keep const DPCTLSyclKernelBundleRef KBRef)
762762 }
763763}
764764
765+ using build_option_list_t = std::vector<std::string>;
766+
765767__dpctl_give DPCTLBuildOptionListRef DPCTLBuildOptionList_Create ()
766768{
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;
768775}
769776
770777void DPCTLBuildOptionList_Delete (__dpctl_take DPCTLBuildOptionListRef Ref)
771778{
772- delete Ref;
779+ delete reinterpret_cast < build_option_list_t *>( Ref) ;
773780}
774781
775782void DPCTLBuildOptionList_Append (__dpctl_keep DPCTLBuildOptionListRef Ref,
776783 __dpctl_keep const char *Option)
777784{
778- Ref-> options . emplace_back (Option);
785+ reinterpret_cast < build_option_list_t *>( Ref)-> emplace_back (Option);
779786}
780787
788+ using kernel_name_list_t = std::vector<std::string>;
789+
781790__dpctl_give DPCTLKernelNameListRef DPCTLKernelNameList_Create ()
782791{
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;
784798}
785799
786800void DPCTLKernelNameList_Delete (__dpctl_take DPCTLKernelNameListRef Ref)
787801{
788- delete Ref;
802+ delete reinterpret_cast < kernel_name_list_t *>( Ref) ;
789803}
790804
791805void DPCTLKernelNameList_Append (__dpctl_keep DPCTLKernelNameListRef Ref,
792806 __dpctl_keep const char *Option)
793807{
794- Ref-> names . emplace_back (Option);
808+ reinterpret_cast < kernel_name_list_t *>( Ref)-> emplace_back (Option);
795809}
796810
811+ using virtual_header_list_t = std::vector<std::pair<std::string, std::string>>;
812+
797813__dpctl_give DPCTLVirtualHeaderListRef DPCTLVirtualHeaderList_Create ()
798814{
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;
800821}
801822
802823void DPCTLVirtualHeaderList_Delete (__dpctl_take DPCTLVirtualHeaderListRef Ref)
803824{
804- delete Ref;
825+ delete reinterpret_cast < virtual_header_list_t *>( Ref) ;
805826}
806827
807828void DPCTLVirtualHeaderList_Append (__dpctl_keep DPCTLVirtualHeaderListRef Ref,
808829 __dpctl_keep const char *Name,
809830 __dpctl_keep const char *Content)
810831{
811832 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);
813834}
814835
815836namespace syclex = sycl::ext::oneapi::experimental;
816837
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+
817861__dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource (
818862 __dpctl_keep const DPCTLSyclContextRef Ctx,
819863 __dpctl_keep const DPCTLSyclDeviceRef Dev,
@@ -822,15 +866,17 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
822866 __dpctl_keep DPCTLKernelNameListRef Names,
823867 __dpctl_keep DPCTLBuildOptionListRef BuildOptions)
824868{
825- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
869+ #if (SUPPORTS_SYCL_COMPILATION > 0)
826870 context *SyclCtx = unwrap<context>(Ctx);
827871 device *SyclDev = unwrap<device>(Dev);
828872 if (!SyclDev->ext_oneapi_can_compile (syclex::source_language::sycl)) {
829873 return nullptr ;
830874 }
831875 try {
832876 syclex::include_files IncludeFiles;
833- for (auto &Include : Headers->headers ) {
877+ for (auto &Include :
878+ *reinterpret_cast <virtual_header_list_t *>(Headers))
879+ {
834880 const auto &[Name, Content] = Include;
835881 IncludeFiles.add (Name, Content);
836882 }
@@ -840,12 +886,15 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
840886 *SyclCtx, syclex::source_language::sycl, Src,
841887 syclex::properties{IncludeFiles});
842888
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+ {
845893 RegisteredNames.add (Name);
846894 }
847895
848- syclex::build_options Opts{BuildOptions->options };
896+ syclex::build_options Opts{
897+ *reinterpret_cast <build_option_list_t *>(BuildOptions)};
849898
850899 std::vector<sycl::device> Devices ({*SyclDev});
851900
@@ -869,7 +918,7 @@ __dpctl_give DPCTLSyclKernelRef
869918DPCTLKernelBundle_GetSyclKernel (__dpctl_keep DPCTLSyclKernelBundleRef KBRef,
870919 __dpctl_keep const char *KernelName)
871920{
872- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
921+ #if (SUPPORTS_SYCL_COMPILATION > 0)
873922 try {
874923 auto KernelBundle =
875924 unwrap<sycl::kernel_bundle<bundle_state::executable>>(KBRef);
@@ -888,7 +937,7 @@ bool DPCTLKernelBundle_HasSyclKernel(__dpctl_keep DPCTLSyclKernelBundleRef
888937 KBRef,
889938 __dpctl_keep const char *KernelName)
890939{
891- #ifdef SYCL_EXT_ONEAPI_KERNEL_COMPILER
940+ #if (SUPPORTS_SYCL_COMPILATION > 0)
892941 try {
893942 auto KernelBundle =
894943 unwrap<sycl::kernel_bundle<bundle_state::executable>>(KBRef);
0 commit comments