From 8231dd9aedc78728848a6babd07f20829d2a05ef Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Mon, 5 Aug 2024 14:26:39 +0100 Subject: [PATCH] [SYCL] Switch NativePrograms back to using multimap 4f86ab replaced `insert` with `[]` in order to fix a pointer re-use issue, however that was not the correct fix. Instead, a multimap was incorrectly converted to a regular map during the PI->UR conversion. This change reverts the rest of 4f86ab (besides the test, which is still valid), and converts NativePrograms back to a multimap. --- sycl/source/detail/program_manager/program_manager.cpp | 6 +++--- sycl/source/detail/program_manager/program_manager.hpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index fefcb2fa39f5f..7de12004dd572 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -229,7 +229,7 @@ ProgramManager::createURProgram(const RTDeviceBinaryImage &Img, { std::lock_guard Lock(MNativeProgramsMutex); // associate the UR program with the image it was created for - NativePrograms[Res] = &Img; + NativePrograms.insert({Res, &Img}); } Ctx->addDeviceGlobalInitializer(Res, {Device}, &Img); @@ -840,7 +840,7 @@ ur_program_handle_t ProgramManager::getBuiltURProgram( { std::lock_guard Lock(MNativeProgramsMutex); - NativePrograms[BuiltProgram.get()] = &Img; + NativePrograms.insert({BuiltProgram.get(), &Img}); for (RTDeviceBinaryImage *LinkedImg : DeviceImagesToLink) { NativePrograms.insert({BuiltProgram.get(), LinkedImg}); } @@ -2500,7 +2500,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, { std::lock_guard Lock(MNativeProgramsMutex); - NativePrograms[BuiltProgram.get()] = &Img; + NativePrograms.insert({BuiltProgram.get(), &Img}); } ContextImpl->addDeviceGlobalInitializer(BuiltProgram.get(), Devs, &Img); diff --git a/sycl/source/detail/program_manager/program_manager.hpp b/sycl/source/detail/program_manager/program_manager.hpp index f973e8043b769..cfedb33879460 100644 --- a/sycl/source/detail/program_manager/program_manager.hpp +++ b/sycl/source/detail/program_manager/program_manager.hpp @@ -398,7 +398,7 @@ class ProgramManager { // the underlying program disposed of), so the map can't be used in any way // other than binary image lookup with known live UrProgram as the key. // NOTE: access is synchronized via the MNativeProgramsMutex - std::unordered_map + std::unordered_multimap NativePrograms; /// Protects NativePrograms that can be changed by class' methods.