@@ -66,9 +66,26 @@ bool DeviceGlobalMapEntry::isProfileCounter() {
66
66
return MUniqueId.substr (0 , CounterPrefix.size ()) == CounterPrefix;
67
67
}
68
68
69
+ #ifdef _MSC_VER
70
+ extern " C" void
71
+ __sycl_increment_profile_counters (std::uint64_t FnHash, std::size_t NumCounters,
72
+ const std::uint64_t *Increments);
73
+ extern " C" void
74
+ __sycl_increment_profile_counters_default (std::uint64_t FnHash,
75
+ std::size_t NumCounters,
76
+ const std::uint64_t *Increments) {
77
+ (void )FnHash;
78
+ (void )NumCounters;
79
+ (void )Increments;
80
+ }
81
+ #pragma comment( \
82
+ linker, \
83
+ " /alternatename:__sycl_increment_profile_counters=__sycl_increment_profile_counters_default" )
84
+ #else
69
85
extern " C" void __attribute__ ((weak))
70
86
__sycl_increment_profile_counters(std::uint64_t FnHash, std::size_t NumCounters,
71
87
const std::uint64_t *Increments);
88
+ #endif
72
89
73
90
void DeviceGlobalMapEntry::cleanupProfileCounter (context_impl *CtxImpl) {
74
91
std::lock_guard<std::mutex> Lock{MDeviceToUSMPtrMapMutex};
@@ -139,30 +156,30 @@ DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM(queue_impl &QueueImpl) {
139
156
std::lock_guard<std::mutex> Lock (NewAlloc.MInitEventMutex );
140
157
ur_event_handle_t InitEvent;
141
158
if (MDeviceGlobalPtr) {
142
- // C++ guarantees members appear in memory in the order they are declared,
143
- // so since the member variable that contains the initial contents of the
144
- // device_global is right after the usm_ptr member variable we can do
145
- // some pointer arithmetic to memcopy over this value to the usm_ptr. This
146
- // value inside of the device_global will be zero-initialized if it was
147
- // not given a value on construction.
159
+ // C++ guarantees members appear in memory in the order they are
160
+ // declared, so since the member variable that contains the initial
161
+ // contents of the device_global is right after the usm_ptr member
162
+ // variable we can do some pointer arithmetic to memcopy over this
163
+ // value to the usm_ptr. This value inside of the device_global will
164
+ // be zero-initialized if it was not given a value on construction.
148
165
MemoryManager::copy_usm (
149
166
reinterpret_cast <const void *>(
150
167
reinterpret_cast <uintptr_t >(MDeviceGlobalPtr) +
151
168
sizeof (MDeviceGlobalPtr)),
152
169
QueueImpl, MDeviceGlobalTSize, NewAlloc.MPtr ,
153
170
std::vector<ur_event_handle_t >{}, &InitEvent);
154
171
} else {
155
- // For SYCLBIN device globals we do not have a host pointer to copy from,
156
- // so instead we fill the USM memory with 0's.
172
+ // For SYCLBIN device globals we do not have a host pointer to copy
173
+ // from, so instead we fill the USM memory with 0's.
157
174
MemoryManager::fill_usm (NewAlloc.MPtr , QueueImpl, MDeviceGlobalTSize,
158
175
{static_cast <unsigned char >(0 )}, {}, &InitEvent);
159
176
}
160
177
NewAlloc.MInitEvent = InitEvent;
161
178
}
162
179
163
180
// Only device globals with host variables need to be registered with the
164
- // context. The rest will be managed by their kernel bundles and cleaned up
165
- // accordingly.
181
+ // context. The rest will be managed by their kernel bundles and cleaned
182
+ // up accordingly.
166
183
if (MDeviceGlobalPtr)
167
184
CtxImpl.addAssociatedDeviceGlobal (MDeviceGlobalPtr);
168
185
return NewAlloc;
@@ -194,29 +211,29 @@ DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM(const context &Context) {
194
211
NewAlloc.MAllocatingContext = CtxImpl.shared_from_this ();
195
212
196
213
if (MDeviceGlobalPtr) {
197
- // C++ guarantees members appear in memory in the order they are declared,
198
- // so since the member variable that contains the initial contents of the
199
- // device_global is right after the usm_ptr member variable we can do
200
- // some pointer arithmetic to memcopy over this value to the usm_ptr. This
201
- // value inside of the device_global will be zero-initialized if it was not
202
- // given a value on construction.
214
+ // C++ guarantees members appear in memory in the order they are
215
+ // declared, so since the member variable that contains the initial
216
+ // contents of the device_global is right after the usm_ptr member
217
+ // variable we can do some pointer arithmetic to memcopy over this value
218
+ // to the usm_ptr. This value inside of the device_global will be
219
+ // zero-initialized if it was not given a value on construction.
203
220
MemoryManager::context_copy_usm (
204
221
reinterpret_cast <const void *>(
205
222
reinterpret_cast <uintptr_t >(MDeviceGlobalPtr) +
206
223
sizeof (MDeviceGlobalPtr)),
207
224
&CtxImpl, MDeviceGlobalTSize, NewAlloc.MPtr );
208
225
} else {
209
- // For SYCLBIN device globals we do not have a host pointer to copy from,
210
- // so instead we fill the USM memory with 0's.
226
+ // For SYCLBIN device globals we do not have a host pointer to copy
227
+ // from, so instead we fill the USM memory with 0's.
211
228
std::vector<unsigned char > ImmBuff (MDeviceGlobalTSize,
212
229
static_cast <unsigned char >(0 ));
213
230
MemoryManager::context_copy_usm (ImmBuff.data (), &CtxImpl,
214
231
MDeviceGlobalTSize, NewAlloc.MPtr );
215
232
}
216
233
217
234
// Only device globals with host variables need to be registered with the
218
- // context. The rest will be managed by their kernel bundles and cleaned up
219
- // accordingly.
235
+ // context. The rest will be managed by their kernel bundles and cleaned
236
+ // up accordingly.
220
237
if (MDeviceGlobalPtr)
221
238
CtxImpl.addAssociatedDeviceGlobal (MDeviceGlobalPtr);
222
239
return NewAlloc;
0 commit comments