-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Cache devices so they actually compare == when they should. #2092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
…e it involves control characters Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This semantics is simpler to the user.
Note that triSYCL uses weak pointers instead of shared pointers because otherwise the devices might never been released...
https://github.com/triSYCL/triSYCL/blob/master/include/triSYCL/detail/cache.hpp
Note to self: Update this to also fix platforms (same place, same issue). |
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
I think I've addressed all your points, @romanovvlad. Good suggestions. |
sycl/source/detail/context_impl.cpp
Outdated
MDevices.emplace_back(createSyclObjFromImpl<device>( | ||
std::make_shared<device_impl>(Dev, Plugin))); | ||
if (!DeviceIds.empty()) { | ||
auto Platform = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto Platform = | |
std::shared_ptr<detail::platform_impl> Platform = |
sycl/source/detail/context_impl.cpp
Outdated
if (!DeviceIds.empty()) { | ||
auto Platform = | ||
platform_impl::getPlatformFromPiDevice(DeviceIds[0], Plugin); | ||
for (auto Dev : DeviceIds) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (auto Dev : DeviceIds) { | |
for (RT::PiDevice Dev : DeviceIds) { |
sycl/source/detail/device_info.hpp
Outdated
@@ -406,8 +407,10 @@ template <> struct get_device_info<device, info::device::parent_device> { | |||
"No parent for device because it is not a subdevice", | |||
PI_INVALID_DEVICE); | |||
|
|||
// Get the platform of this device | |||
auto Platform = platform_impl::getPlatformFromPiDevice(dev, Plugin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto Platform = platform_impl::getPlatformFromPiDevice(dev, Plugin); | |
std::shared_ptr<detail::platform_impl> Platform = platform_impl::getPlatformFromPiDevice(dev, Plugin); |
sycl/source/detail/platform_impl.cpp
Outdated
static PlatformImplPtr HostImpl; | ||
static std::once_flag HostImplInit; | ||
|
||
std::call_once(HostImplInit, | ||
[]() { HostImpl = std::make_shared<platform_impl>(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static PlatformImplPtr HostImpl; | |
static std::once_flag HostImplInit; | |
std::call_once(HostImplInit, | |
[]() { HostImpl = std::make_shared<platform_impl>(); }); | |
static PlatformImplPtr HostImpl = std::make_shared<platform_impl>();; |
sycl/source/detail/platform_impl.cpp
Outdated
|
||
PlatformImplPtr Result; | ||
{ | ||
const std::lock_guard<std::mutex> guard(PlatformMapMutex); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const std::lock_guard<std::mutex> guard(PlatformMapMutex); | |
const std::lock_guard<std::mutex> Guard(PlatformMapMutex); |
sycl/source/detail/platform_impl.cpp
Outdated
const std::lock_guard<std::mutex> Guard(MDeviceMapMutex); | ||
|
||
// If we've already seen this device, return the impl | ||
for (const auto &Device : MDeviceCache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (const auto &Device : MDeviceCache) { | |
for (const std::shared_ptr<device_impl>&Device : MDeviceCache) { |
sycl/source/detail/platform_impl.cpp
Outdated
} | ||
|
||
// Otherwise make the impl | ||
auto Result = std::make_shared<device_impl>(PiDevice, PlatformImpl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto Result = std::make_shared<device_impl>(PiDevice, PlatformImpl); | |
std::shared_ptr<detail::device_impl> Result = std::make_shared<device_impl>(PiDevice, PlatformImpl); |
sycl/source/detail/platform_impl.cpp
Outdated
std::make_shared<device_impl>( | ||
PiDevice, std::make_shared<platform_impl>(*this))); | ||
}); | ||
auto PlatformImpl = getOrMakePlatformImpl(MPlatform, *MPlugin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto PlatformImpl = getOrMakePlatformImpl(MPlatform, *MPlugin); | |
PlatformImplPtr PlatformImpl = getOrMakePlatformImpl(MPlatform, *MPlugin); |
sycl/source/detail/platform_impl.hpp
Outdated
@@ -14,6 +14,8 @@ | |||
#include <detail/platform_info.hpp> | |||
#include <detail/plugin.hpp> | |||
|
|||
#include <map> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you do not need this header anymore.
@@ -39,8 +39,8 @@ TEST(PiMockTest, ConstructFromQueue) { | |||
detail::getSyclObjImpl(Mock.getPlatform())->getPlugin().getPiPlugin(); | |||
EXPECT_EQ(&MockedQueuePiPlugin, &PiMockPlugin) | |||
<< "The mocked object and the PiMock instance must share the same plugin"; | |||
ASSERT_FALSE(&NormalPiPlugin == &MockedQueuePiPlugin) | |||
<< "Normal and mock platforms must not share the same plugin"; | |||
EXPECT_EQ(&NormalPiPlugin, &MockedQueuePiPlugin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it breaks design of the plugin mock.
@AGindinson Could you please comment?
Signed-off-by: James Brodman <[email protected]>
Signed-off-by: James Brodman <[email protected]>
No clue what's up with the interop task test on windows |
@alexbatashev, I see this failure second time. Please, revert #2342 and investigate this failure. |
The -opaque-pointers flag is no longer supported. Original commit: KhronosGroup/SPIRV-LLVM-Translator@ff8c3e7
Platform device enumeration was creating new device impls every time for the same devices. This was making it impossible for devices that really should compare equal to compare equal.
Example:
queue q1;
queue q2;
Each q uses the default selector to select the same device - yet they would not compare equal.
Signed-off-by: James Brodman [email protected]