|
11 | 11 |
|
12 | 12 | #include "common.hpp"
|
13 | 13 | #include "device.hpp"
|
14 |
| -#ifdef UR_ADAPTER_LEVEL_ZERO_V2 |
15 |
| -#include "v2/context.hpp" |
16 |
| -#else |
17 |
| -#include "context.hpp" |
18 |
| -#endif |
19 | 14 |
|
20 | 15 | struct ur_program_handle_t_ : _ur_object {
|
21 | 16 | // ur_program_handle_t_() {}
|
@@ -73,70 +68,32 @@ struct ur_program_handle_t_ : _ur_object {
|
73 | 68 |
|
74 | 69 | // Construct a program in IL.
|
75 | 70 | ur_program_handle_t_(state St, ur_context_handle_t Context, const void *Input,
|
76 |
| - size_t Length) |
77 |
| - : Context{Context}, NativeProperties{nullptr}, OwnZeModule{true}, |
78 |
| - AssociatedDevices(Context->getDevices()), |
79 |
| - SpirvCode{new uint8_t[Length]}, SpirvCodeLength{Length} { |
80 |
| - std::memcpy(SpirvCode.get(), Input, Length); |
81 |
| - // All devices have the program in IL state. |
82 |
| - for (auto &Device : Context->getDevices()) { |
83 |
| - DeviceData &PerDevData = DeviceDataMap[Device->ZeDevice]; |
84 |
| - PerDevData.State = St; |
85 |
| - } |
86 |
| - } |
| 71 | + size_t Length); |
87 | 72 |
|
88 | 73 | // Construct a program in NATIVE for multiple devices.
|
89 | 74 | ur_program_handle_t_(state St, ur_context_handle_t Context,
|
90 | 75 | const uint32_t NumDevices,
|
91 | 76 | const ur_device_handle_t *Devices,
|
92 | 77 | const ur_program_properties_t *Properties,
|
93 |
| - const uint8_t **Inputs, const size_t *Lengths) |
94 |
| - : Context{Context}, NativeProperties(Properties), OwnZeModule{true}, |
95 |
| - AssociatedDevices(Devices, Devices + NumDevices) { |
96 |
| - for (uint32_t I = 0; I < NumDevices; ++I) { |
97 |
| - DeviceData &PerDevData = DeviceDataMap[Devices[I]->ZeDevice]; |
98 |
| - PerDevData.State = St; |
99 |
| - PerDevData.Binary = std::make_pair( |
100 |
| - std::unique_ptr<uint8_t[]>(new uint8_t[Lengths[I]]), Lengths[I]); |
101 |
| - std::memcpy(PerDevData.Binary.first.get(), Inputs[I], Lengths[I]); |
102 |
| - } |
103 |
| - } |
| 78 | + const uint8_t **Inputs, const size_t *Lengths); |
104 | 79 |
|
105 |
| - ur_program_handle_t_(ur_context_handle_t Context) |
106 |
| - : Context{Context}, NativeProperties{nullptr}, OwnZeModule{true}, |
107 |
| - AssociatedDevices(Context->getDevices()) {} |
| 80 | + ur_program_handle_t_(ur_context_handle_t Context); |
108 | 81 |
|
109 | 82 | // Construct a program in Exe or Invalid state.
|
110 | 83 | ur_program_handle_t_(state, ur_context_handle_t Context,
|
111 |
| - ze_module_handle_t InteropZeModule) |
112 |
| - : Context{Context}, NativeProperties{nullptr}, OwnZeModule{true}, |
113 |
| - AssociatedDevices({Context->getDevices()[0]}), InteropZeModule{ |
114 |
| - InteropZeModule} {} |
| 84 | + ze_module_handle_t InteropZeModule); |
115 | 85 |
|
116 | 86 | // Construct a program in Exe state (interop).
|
117 | 87 | // TODO: Currently it is not possible to get the device associated with the
|
118 | 88 | // interop module, API must be changed to either get that info from the user
|
119 | 89 | // or new API need to be added to L0 to fetch that info. Consider it
|
120 | 90 | // associated with the first device in the context.
|
121 | 91 | ur_program_handle_t_(state, ur_context_handle_t Context,
|
122 |
| - ze_module_handle_t InteropZeModule, bool OwnZeModule) |
123 |
| - : Context{Context}, NativeProperties{nullptr}, OwnZeModule{OwnZeModule}, |
124 |
| - AssociatedDevices({Context->getDevices()[0]}), InteropZeModule{ |
125 |
| - InteropZeModule} { |
126 |
| - // TODO: Currently it is not possible to understand the device associated |
127 |
| - // with provided ZeModule. So we can't set the state on that device to Exe. |
128 |
| - } |
| 92 | + ze_module_handle_t InteropZeModule, bool OwnZeModule); |
129 | 93 |
|
130 | 94 | // Construct a program in Invalid state with a custom error message.
|
131 | 95 | ur_program_handle_t_(state St, ur_context_handle_t Context,
|
132 |
| - const std::string &ErrorMessage) |
133 |
| - : Context{Context}, NativeProperties{nullptr}, OwnZeModule{true}, |
134 |
| - ErrorMessage{ErrorMessage}, AssociatedDevices(Context->getDevices()) { |
135 |
| - for (auto &Device : Context->getDevices()) { |
136 |
| - DeviceData &PerDevData = DeviceDataMap[Device->ZeDevice]; |
137 |
| - PerDevData.State = St; |
138 |
| - } |
139 |
| - } |
| 96 | + const std::string &ErrorMessage); |
140 | 97 |
|
141 | 98 | ~ur_program_handle_t_();
|
142 | 99 | void ur_release_program_resources(bool deletion);
|
|
0 commit comments