Skip to content

Commit 8d70601

Browse files
committed
Address reviews
1 parent 330eb76 commit 8d70601

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,17 +1866,19 @@ void ProgramManager::addImages(sycl_device_binaries DeviceBinary) {
18661866

18671867
m_BinImg2KernelIDs[Img.get()].reset(new std::vector<kernel_id>);
18681868

1869-
sycl_offload_entry EntriesIt;
1869+
sycl_offload_entry EntriesIt = EntriesB;
1870+
// Assuming that there isn't a mix of new and old offload entry types in the
1871+
// image.
1872+
bool isNewOffloadEntryType = EntriesIt->IsNewOffloadEntryType();
18701873
auto IncrementEntriesIt = [&]() {
1871-
if (EntriesIt->IsNewOffloadEntryType())
1874+
if (isNewOffloadEntryType)
18721875
return reinterpret_cast<sycl_offload_entry>(
18731876
reinterpret_cast<sycl_offload_entry_new>(EntriesIt) + 1);
18741877
else
18751878
return EntriesIt + 1;
18761879
};
18771880

1878-
for (EntriesIt = EntriesB; EntriesIt != EntriesE;
1879-
EntriesIt = IncrementEntriesIt()) {
1881+
for (; EntriesIt != EntriesE; EntriesIt = IncrementEntriesIt()) {
18801882

18811883
auto name = EntriesIt->GetName();
18821884

@@ -2028,18 +2030,20 @@ void ProgramManager::removeImages(sycl_device_binaries DeviceBinary) {
20282030
// Acquire lock to modify maps for kernel bundles
20292031
std::lock_guard<std::mutex> KernelIDsGuard(m_KernelIDsMutex);
20302032

2031-
sycl_offload_entry EntriesIt;
2033+
sycl_offload_entry EntriesIt = EntriesB;
2034+
// Assuming that there isn't a mix of new and old offload entry types in the
2035+
// image.
2036+
bool isNewOffloadEntryType = EntriesIt->IsNewOffloadEntryType();
20322037
auto IncrementEntriesIt = [&]() {
2033-
if (EntriesIt->IsNewOffloadEntryType())
2038+
if (isNewOffloadEntryType)
20342039
return reinterpret_cast<sycl_offload_entry>(
20352040
reinterpret_cast<sycl_offload_entry_new>(EntriesIt) + 1);
20362041
else
20372042
return EntriesIt + 1;
20382043
};
20392044

20402045
// Unmap the unique kernel IDs for the offload entries
2041-
for (EntriesIt = EntriesB; EntriesIt != EntriesE;
2042-
EntriesIt = IncrementEntriesIt()) {
2046+
for (; EntriesIt != EntriesE; EntriesIt = IncrementEntriesIt()) {
20432047

20442048
// Drop entry for service kernel
20452049
if (std::strstr(EntriesIt->GetName(), "__sycl_service_kernel__")) {

0 commit comments

Comments
 (0)