Skip to content

Commit 5e3f259

Browse files
committed
[SYCL] Refactor spec constant loop
1 parent 83efbcf commit 5e3f259

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

sycl/source/detail/device_image_impl.hpp

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -278,39 +278,38 @@ class device_image_impl {
278278
Descriptors.size());
279279
unsigned LocalOffset = 0;
280280
while (It != End) {
281+
unsigned int ID = It[0];
282+
unsigned int CompositeOffset = It[1];
283+
unsigned int Size = It[2];
284+
281285
if (MBinImage->supportsSpecConstants()) {
282286
// Make sure that alignment is correct in blob.
283-
const unsigned OffsetFromLast = /*Offset*/ It[1] - LocalOffset;
287+
const unsigned OffsetFromLast = CompositeOffset - LocalOffset;
284288
BlobOffset += OffsetFromLast;
285289

286-
// Composites may have a special padding element at the end which
287-
// should not have a descriptor. These padding elements all have max
288-
// ID value.
289-
if (It[0] != std::numeric_limits<std::uint32_t>::max()) {
290-
// The map is not locked here because updateSpecConstSymMap() is
291-
// only supposed to be called from c'tor.
292-
MSpecConstSymMap[std::string{SCName}].push_back(
293-
SpecConstDescT{/*ID*/ It[0], /*CompositeOffset*/ It[1],
294-
/*Size*/ It[2], BlobOffset});
295-
}
296-
297-
LocalOffset += OffsetFromLast + /*Size*/ It[2];
290+
LocalOffset += OffsetFromLast + Size;
298291
} else {
299292
// For emulated specialization constants the CompositeOffset is used
300293
// to indicate necessary padding to ensure correct alignment.
301-
BlobOffset += /* CompositeOffset */ It[1];
294+
BlobOffset += CompositeOffset;
302295

303-
// The map is not locked here because updateSpecConstSymMap() is
304-
// only supposed to be called from c'tor.
305296
// Now that we've handled the padding we can set the
306297
// CompositeOffset to 0, so that emulated and native spec constants
307298
// can be handled the same going forward.
299+
CompositeOffset = 0;
300+
}
301+
302+
// Composites may have a special padding element at the end which
303+
// should not have a descriptor. These padding elements all have max
304+
// ID value.
305+
if (ID != std::numeric_limits<std::uint32_t>::max()) {
306+
// The map is not locked here because updateSpecConstSymMap() is
307+
// only supposed to be called from c'tor.
308308
MSpecConstSymMap[std::string{SCName}].push_back(
309-
SpecConstDescT{/*ID*/ It[0], /*CompositeOffset*/ 0,
310-
/*Size*/ It[2], BlobOffset});
309+
SpecConstDescT{ID, CompositeOffset, Size, BlobOffset});
311310
}
312311

313-
BlobOffset += /*Size*/ It[2];
312+
BlobOffset += Size;
314313
It += NumElements;
315314
}
316315
}

0 commit comments

Comments
 (0)