Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion sycl/source/backend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ make_kernel_bundle(ur_native_handle_t NativeHandle,
sizeof(ur_device_handle_t) * NumDevices, ProgramDevices.data(), nullptr);

for (auto &Dev : ProgramDevices) {
ur_program_binary_type_t BinaryType;
ur_program_binary_type_t BinaryType = UR_PROGRAM_BINARY_TYPE_NONE;
Adapter.call<UrApiKind::urProgramGetBuildInfo>(
UrProgram, Dev, UR_PROGRAM_BUILD_INFO_BINARY_TYPE,
sizeof(ur_program_binary_type_t), &BinaryType, nullptr);
Expand Down
6 changes: 5 additions & 1 deletion sycl/source/detail/adapter_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@ template <typename URResource> class Managed {
if (!R)
return;

Adapter->call<Release>(R);
try {
Adapter->call<Release>(R);
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~Managed", e);
}
}

Managed retain() {
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/context_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ std::vector<ur_event_handle_t> context_impl::initializeDeviceGlobals(
}
// Write the pointer to the device global and store the event in the
// initialize events list.
ur_event_handle_t InitEvent;
ur_event_handle_t InitEvent = nullptr;
void *const &USMPtr = DeviceGlobalUSM.getPtr();
Adapter.call<UrApiKind::urEnqueueDeviceGlobalVariableWrite>(
QueueImpl.getHandleRef(), NativePrg,
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/detail/device_binary_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,10 @@ mergeDeviceRequirements(const std::vector<const RTDeviceBinaryImage *> &Imgs) {
size_t Pos = 0;
do {
const size_t NextPos = Contents.find(';', Pos);
if (NextPos == std::string::npos) {
Set.emplace(Contents.substr(Pos));
break;
}
if (NextPos != Pos)
Set.emplace(Contents.substr(Pos, NextPos - Pos));
Pos = NextPos + 1;
Expand Down
37 changes: 21 additions & 16 deletions sycl/source/detail/device_global_map_entry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ inline namespace _V1 {
namespace detail {

DeviceGlobalUSMMem::~DeviceGlobalUSMMem() {
// removeAssociatedResources is expected to have cleaned up both the pointer
// and the event. When asserts are enabled the values are set, so we check
// these here.
auto ContextImplPtr = MAllocatingContext.lock();
if (ContextImplPtr) {
if (MPtr != nullptr) {
detail::usm::freeInternal(MPtr, ContextImplPtr.get());
MPtr = nullptr;
try {
// removeAssociatedResources is expected to have cleaned up both the pointer
// and the event. When asserts are enabled the values are set, so we check
// these here.
auto ContextImplPtr = MAllocatingContext.lock();
if (ContextImplPtr) {
if (MPtr != nullptr) {
detail::usm::freeInternal(MPtr, ContextImplPtr.get());
MPtr = nullptr;
}
if (MInitEvent != nullptr) {
ContextImplPtr->getAdapter().call<UrApiKind::urEventRelease>(
MInitEvent);
MInitEvent = nullptr;
}
}
if (MInitEvent != nullptr) {
ContextImplPtr->getAdapter().call<UrApiKind::urEventRelease>(MInitEvent);
MInitEvent = nullptr;
}
}

assert(MPtr == nullptr && "MPtr has not been cleaned up.");
assert(MInitEvent == nullptr && "MInitEvent has not been cleaned up.");
assert(MPtr == nullptr && "MPtr has not been cleaned up.");
assert(MInitEvent == nullptr && "MInitEvent has not been cleaned up.");
} catch (std::exception &e) {
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~DeviceGlobalUSMMem", e);
}
}

OwnedUrEvent DeviceGlobalUSMMem::getInitEvent(adapter_impl &Adapter) {
Expand Down Expand Up @@ -80,7 +85,7 @@ DeviceGlobalMapEntry::getOrAllocateDeviceGlobalUSM(queue_impl &QueueImpl) {
// Initialize here and save the event.
{
std::lock_guard<std::mutex> Lock(NewAlloc.MInitEventMutex);
ur_event_handle_t InitEvent;
ur_event_handle_t InitEvent = nullptr;
if (MDeviceGlobalPtr) {
// C++ guarantees members appear in memory in the order they are declared,
// so since the member variable that contains the initial contents of the
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/device_image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class device_image_impl
updateSpecConstSymMap();
}

device_image_impl(const std::string &Src, context Context,
device_image_impl(const std::string &Src, const context &Context,
devices_range Devices, syclex::source_language Lang,
include_pairs_t &&IncludePairsVec, private_tag)
: MBinImage(Src), MContext(Context),
Expand Down
4 changes: 2 additions & 2 deletions sycl/source/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
return {Error};
return {Result};
} else {
ur_ret_t Result;
ur_ret_t Result{};
ur_result_t Error = getAdapter().call_nocheck<UrApiKind::urDeviceGetInfo>(
getHandleRef(), Desc, sizeof(Result), &Result, nullptr);
if (Error == UR_RESULT_SUCCESS)
Expand Down Expand Up @@ -220,7 +220,7 @@ class device_impl : public std::enable_shared_from_this<device_impl> {
getHandleRef(), Desc, ResultSize, Result.data(), nullptr);
return Result;
} else {
ur_ret_t Result;
ur_ret_t Result{};
getAdapter().call<UrApiKind::urDeviceGetInfo>(
getHandleRef(), Desc, sizeof(Result), &Result, nullptr);
return Result;
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/event_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ class event_impl {
ur_exp_command_buffer_sync_point_t getSyncPoint() const { return MSyncPoint; }

void setCommandGraph(
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph) {
const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl>
&Graph) {
MGraph = Graph;
}

Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/memory_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ void *MemoryManager::allocateMemSubBuffer(context_impl *TargetContext,
ur_result_t Error = UR_RESULT_SUCCESS;
ur_buffer_region_t Region = {UR_STRUCTURE_TYPE_BUFFER_REGION, nullptr, Offset,
SizeInBytes};
ur_mem_handle_t NewMem;
ur_mem_handle_t NewMem = nullptr;
adapter_impl &Adapter = TargetContext->getAdapter();
Error = Adapter.call_nocheck<UrApiKind::urMemBufferPartition>(
ur::cast<ur_mem_handle_t>(ParentMemObj), UR_MEM_FLAG_READ_WRITE,
Expand Down
4 changes: 4 additions & 0 deletions sycl/source/detail/program_manager/program_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,10 @@ ProgramManager::collectDeviceImageDepsForImportedSymbols(
throw exception(make_error_code(errc::feature_not_supported),
"Cannot resolve external symbols, linking is unsupported "
"for the backend");

// Access to m_ExportedSymbolImages must be guarded by m_KernelIDsMutex.
std::lock_guard<std::mutex> KernelIDsGuard(m_KernelIDsMutex);

while (!WorkList.empty()) {
std::string Symbol = WorkList.front();
WorkList.pop();
Expand Down
8 changes: 4 additions & 4 deletions sycl/source/detail/queue_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ EventImplPtr queue_impl::submit_kernel_scheduler_bypass(
ResultEvent->setEnqueued();
// connect returned event with dependent events
if (!isInOrder()) {
// DepEvents is not used anymore, so can move.
ResultEvent->getPreparedDepsEvents() = std::move(DepEvents);
// ResultEvent is local for current thread, no need to lock.
ResultEvent->cleanDepEventsThroughOneLevelUnlocked();
Expand Down Expand Up @@ -581,7 +580,7 @@ EventImplPtr queue_impl::submit_kernel_direct_impl(
KData.validateAndSetKernelLaunchProperties(Props, hasCommandGraph(),
getDeviceImpl());

auto SubmitKernelFunc = [&](detail::CG::StorageInitHelper &CGData,
auto SubmitKernelFunc = [&](detail::CG::StorageInitHelper &&CGData,
bool SchedulerBypass) -> EventImplPtr {
if (SchedulerBypass) {
// No need to copy/move the kernel function, so we set
Expand Down Expand Up @@ -693,7 +692,8 @@ queue_impl::submit_direct(bool CallerNeedsEvent,
MNoLastEventMode.store(isInOrder() && SchedulerBypass,
std::memory_order_relaxed);

EventImplPtr EventImpl = SubmitCommandFunc(CGData, SchedulerBypass);
EventImplPtr EventImpl =
SubmitCommandFunc(std::move(CGData), SchedulerBypass);

// Sync with the last event for in order queue. For scheduler-bypass flow,
// the ordering is done at the layers below the SYCL runtime,
Expand All @@ -708,7 +708,7 @@ queue_impl::submit_direct(bool CallerNeedsEvent,
Deps.UnenqueuedCmdEvents.push_back(EventImpl);
}

return CallerNeedsEvent ? EventImpl : nullptr;
return CallerNeedsEvent ? std::move(EventImpl) : nullptr;
}

template <typename HandlerFuncT>
Expand Down
6 changes: 4 additions & 2 deletions sycl/source/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
bool CallerNeedsEvent);

void setCommandGraphUnlocked(
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph) {
const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl>
&Graph) {
MGraph = Graph;
MExtGraphDeps.reset();

Expand All @@ -614,7 +615,8 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
}

void setCommandGraph(
std::shared_ptr<ext::oneapi::experimental::detail::graph_impl> Graph) {
const std::shared_ptr<ext::oneapi::experimental::detail::graph_impl>
&Graph) {
std::lock_guard<std::mutex> Lock(MMutex);
setCommandGraphUnlocked(Graph);
}
Expand Down