Skip to content

Commit 9b114ae

Browse files
committed
Merge branch 'sycl' into sean/async-alloc-maxSize-ifdef
2 parents 3c57bf3 + a8d7f08 commit 9b114ae

File tree

9 files changed

+37
-13
lines changed

9 files changed

+37
-13
lines changed

llvm/cmake/modules/AddSecurityFlags.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ macro(add_link_option_ext flag name)
3131
endif()
3232
endmacro()
3333

34-
function(append_common_extra_security_flags)
34+
macro(append_common_extra_security_flags)
3535
if( LLVM_ON_UNIX )
3636
# Fortify Source (strongly recommended):
3737
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -70,7 +70,7 @@ function(append_common_extra_security_flags)
7070
CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS
7171
CMAKE_SHARED_LINKER_FLAGS)
7272
endif()
73-
endfunction()
73+
endmacro()
7474

7575
if ( EXTRA_SECURITY_FLAGS )
7676
if (EXTRA_SECURITY_FLAGS STREQUAL "none")

sycl/include/sycl/handler.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ class HandlerAccess;
213213
class HostTask;
214214

215215
using EventImplPtr = std::shared_ptr<event_impl>;
216+
using DeviceImplPtr = std::shared_ptr<device_impl>;
216217

217218
template <typename RetType, typename Func, typename Arg>
218219
static Arg member_ptr_helper(RetType (Func::*)(Arg) const);
@@ -249,6 +250,7 @@ template <typename Type> struct get_kernel_wrapper_name_t {
249250
};
250251

251252
__SYCL_EXPORT device getDeviceFromHandler(handler &);
253+
const DeviceImplPtr &getDeviceImplFromHandler(handler &);
252254

253255
// Checks if a device_global has any registered kernel usage.
254256
__SYCL_EXPORT bool isDeviceGlobalUsedInKernel(const void *DeviceGlobalPtr);
@@ -3481,6 +3483,8 @@ class __SYCL_EXPORT handler {
34813483
typename PropertyListT>
34823484
friend class accessor;
34833485
friend device detail::getDeviceFromHandler(handler &);
3486+
friend const detail::DeviceImplPtr &
3487+
detail::getDeviceImplFromHandler(handler &);
34843488

34853489
template <typename DataT, int Dimensions, access::mode AccessMode,
34863490
access::target AccessTarget, access::placeholder IsPlaceholder>

sycl/source/detail/cg.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ class CGAsyncAlloc : public CG {
686686
ur_event_handle_t event, CG::StorageInitHelper CGData,
687687
detail::code_location loc = {})
688688
: CG(CGType::AsyncAlloc, std::move(CGData), std::move(loc)), MSize(size),
689-
MMemPool(MemPool), MEvent(event) {}
689+
MMemPool(std::move(MemPool)), MEvent(event) {}
690690

691691
std::shared_ptr<ext::oneapi::experimental::detail::memory_pool_impl>
692692
getMemPool() const {

sycl/source/detail/context_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ void context_impl::verifyProps(const property_list &Props) const {
567567
std::shared_ptr<sycl::ext::oneapi::experimental::detail::memory_pool_impl>
568568
context_impl::get_default_memory_pool(const context &Context,
569569
const device &Device,
570-
const usm::alloc &Kind) {
570+
[[maybe_unused]] const usm::alloc &Kind) {
571571

572572
assert(Kind == usm::alloc::device);
573573

sycl/source/detail/graph_impl.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,12 @@ class graph_impl : public std::enable_shared_from_this<graph_impl> {
919919
/// @return Context associated with graph.
920920
sycl::context getContext() const { return MContext; }
921921

922+
/// Query for the device_impl tied to this graph.
923+
/// @return device_impl shared ptr reference associated with graph.
924+
const DeviceImplPtr &getDeviceImplPtr() const {
925+
return getSyclObjImpl(MDevice);
926+
}
927+
922928
/// Query for the device tied to this graph.
923929
/// @return Device associated with graph.
924930
sycl::device getDevice() const { return MDevice; }

sycl/source/detail/handler_impl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ class handler_impl {
207207
/// potential logging.
208208
/// Event computed from async alloc which is passed through for processing.
209209
std::shared_ptr<ext::oneapi::experimental::detail::memory_pool_impl> MMemPool;
210-
size_t MAllocSize;
211-
ur_event_handle_t MAsyncAllocEvent;
210+
size_t MAllocSize = 0;
211+
ur_event_handle_t MAsyncAllocEvent = nullptr;
212212

213213
// Allocation ptr to be freed asynchronously.
214214
void *MFreePtr = nullptr;

sycl/source/detail/memory_pool_impl.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,14 @@ memory_pool_impl::~memory_pool_impl() {
123123
if (MIsDefaultPool)
124124
return;
125125

126-
ur_usm_pool_handle_t handle = this->get_handle();
127-
sycl::context ctx = this->get_context();
128-
sycl::device dev = this->get_device();
129-
destroy_memory_pool(ctx, dev, handle);
126+
try {
127+
ur_usm_pool_handle_t handle = this->get_handle();
128+
sycl::context ctx = this->get_context();
129+
sycl::device dev = this->get_device();
130+
destroy_memory_pool(ctx, dev, handle);
131+
} catch (std::exception &e) {
132+
__SYCL_REPORT_EXCEPTION_TO_STREAM("exception in ~memory_pool_impl", e);
133+
}
130134
}
131135

132136
size_t memory_pool_impl::get_threshold() const {

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3750,6 +3750,7 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
37503750
return UR_RESULT_SUCCESS;
37513751
}
37523752
case CGType::AsyncFree: {
3753+
assert(MQueue && "Async free submissions should have an associated queue");
37533754
CGAsyncFree *AsyncFree = (CGAsyncFree *)MCommandGroup.get();
37543755
const detail::AdapterPtr &Adapter = MQueue->getAdapter();
37553756
void *ptr = AsyncFree->getPtr();

sycl/source/handler.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,15 @@ inline namespace _V1 {
4343

4444
namespace detail {
4545

46+
const DeviceImplPtr &getDeviceImplFromHandler(handler &CGH) {
47+
assert((CGH.MQueue || getSyclObjImpl(CGH)->MGraph) &&
48+
"One of MQueue or MGraph should be nonnull!");
49+
if (CGH.MQueue)
50+
return CGH.MQueue->getDeviceImplPtr();
51+
52+
return getSyclObjImpl(CGH)->MGraph->getDeviceImplPtr();
53+
}
54+
4655
bool isDeviceGlobalUsedInKernel(const void *DeviceGlobalPtr) {
4756
DeviceGlobalMapEntry *DGEntry =
4857
detail::ProgramManager::getInstance().getDeviceGlobalEntry(
@@ -2059,10 +2068,10 @@ void handler::setUserFacingNodeType(ext::oneapi::experimental::node_type Type) {
20592068
}
20602069

20612070
std::optional<std::array<size_t, 3>> handler::getMaxWorkGroups() {
2062-
auto Dev = detail::getSyclObjImpl(detail::getDeviceFromHandler(*this));
2071+
const auto &DeviceImpl = detail::getDeviceImplFromHandler(*this);
20632072
std::array<size_t, 3> UrResult = {};
2064-
auto Ret = Dev->getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
2065-
Dev->getHandleRef(),
2073+
auto Ret = DeviceImpl->getAdapter()->call_nocheck<UrApiKind::urDeviceGetInfo>(
2074+
DeviceImpl->getHandleRef(),
20662075
UrInfoCode<
20672076
ext::oneapi::experimental::info::device::max_work_groups<3>>::value,
20682077
sizeof(UrResult), &UrResult, nullptr);

0 commit comments

Comments
 (0)