Skip to content

[SYCL][UR][L0 v2] Remove duplicate devices when creating a context #19509

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

Merged
merged 1 commit into from
Jul 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion unified-runtime/source/adapters/level_zero/v2/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ populateP2PDevices(size_t maxDevices,
return p2pDevices;
}

static std::vector<ur_device_handle_t>
uniqueDevices(uint32_t numDevices, const ur_device_handle_t *phDevices) {
std::vector<ur_device_handle_t> devices(phDevices, phDevices + numDevices);
std::sort(devices.begin(), devices.end());
devices.erase(std::unique(devices.begin(), devices.end()), devices.end());
return devices;
}

ur_context_handle_t_::ur_context_handle_t_(ze_context_handle_t hContext,
uint32_t numDevices,
const ur_device_handle_t *phDevices,
bool ownZeContext)
: hContext(hContext, ownZeContext),
hDevices(phDevices, phDevices + numDevices),
hDevices(uniqueDevices(numDevices, phDevices)),
commandListCache(hContext,
{phDevices[0]->Platform->ZeCopyOffloadExtensionSupported,
phDevices[0]->Platform->ZeMutableCmdListExt.Supported}),
Expand Down