@@ -1068,23 +1068,24 @@ struct _pi_program : _pi_object {
10681068 // Construct a program in IL or Native state.
10691069 _pi_program (pi_context Context, const void *Input, size_t Length, state St)
10701070 : State(St), Context(Context), Code(new uint8_t [Length]),
1071- CodeLength (Length), ZeModule(nullptr ), HasImports( false ) ,
1072- HasImportsAndIsLinked(false ), ZeBuildLog(nullptr ) {
1071+ CodeLength (Length), ZeModule(nullptr ), OwnZeModule{ true } ,
1072+ HasImports ( false ), HasImportsAndIsLinked(false ), ZeBuildLog(nullptr ) {
10731073
10741074 std::memcpy (Code.get (), Input, Length);
10751075 }
10761076
10771077 // Construct a program in either Object or Exe state.
1078- _pi_program (pi_context Context, ze_module_handle_t ZeModule, state St,
1079- bool HasImports = false )
1080- : State(St), Context(Context), ZeModule(ZeModule), HasImports(HasImports),
1078+ _pi_program (pi_context Context, ze_module_handle_t ZeModule, bool OwnZeModule,
1079+ state St, bool HasImports = false )
1080+ : State(St), Context(Context),
1081+ ZeModule(ZeModule), OwnZeModule{OwnZeModule}, HasImports(HasImports),
10811082 HasImportsAndIsLinked (false ), ZeBuildLog(nullptr ) {}
10821083
10831084 // Construct a program in LinkedExe state.
10841085 _pi_program (pi_context Context, std::vector<LinkedReleaser> &&Inputs,
10851086 ze_module_build_log_handle_t ZeLog)
10861087 : State(LinkedExe), Context(Context), ZeModule(nullptr ),
1087- HasImports(false ), HasImportsAndIsLinked(false ),
1088+ OwnZeModule( true ), HasImports(false ), HasImportsAndIsLinked(false ),
10881089 LinkedPrograms(std::move(Inputs)), ZeBuildLog(ZeLog) {}
10891090
10901091 ~_pi_program ();
@@ -1103,7 +1104,13 @@ struct _pi_program : _pi_object {
11031104
11041105 // Used for programs in Object or Exe state.
11051106 ze_module_handle_t ZeModule; // Level Zero module handle.
1106- bool HasImports; // Tells if module imports any symbols.
1107+
1108+ // Indicates if we own the ZeModule or it came from interop that
1109+ // asked to not transfer the ownership to SYCL RT.
1110+ bool OwnZeModule;
1111+
1112+ // Tells if module imports any symbols.
1113+ bool HasImports;
11071114
11081115 // Used for programs in Object state. Tells if this module imports any
11091116 // symbols AND it is linked into some other program that has state LinkedExe.
0 commit comments