Skip to content

Commit 26a9b47

Browse files
committed
apply clang-format
1 parent fb407c2 commit 26a9b47

File tree

10 files changed

+130
-81
lines changed

10 files changed

+130
-81
lines changed

sycl/include/sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@ inline namespace _V1 {
1313

1414
namespace ext::oneapi::experimental {
1515

16-
/// @brief Indicates USM memory migration direction: either from host to device, or device to host.
17-
enum class migration_direction {
18-
HOST_TO_DEVICE, /// Move data from host USM to device USM
19-
DEVICE_TO_HOST /// Move data from device USM to host USM
20-
};
16+
/// @brief Indicates USM memory migration direction: either from host to device,
17+
/// or device to host.
18+
enum class migration_direction {
19+
HOST_TO_DEVICE, /// Move data from host USM to device USM
20+
DEVICE_TO_HOST /// Move data from device USM to host USM
21+
};
2122

2223
} // namespace ext::oneapi::experimental
2324
} // namespace _V1

sycl/include/sycl/handler.hpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@
3232
#include <sycl/ext/oneapi/bindless_images_mem_handle.hpp>
3333
#include <sycl/ext/oneapi/device_global/device_global.hpp>
3434
#include <sycl/ext/oneapi/device_global/properties.hpp>
35+
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp>
3536
#include <sycl/ext/oneapi/experimental/cluster_group_prop.hpp>
3637
#include <sycl/ext/oneapi/experimental/graph.hpp>
3738
#include <sycl/ext/oneapi/experimental/raw_kernel_arg.hpp>
38-
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp>
3939
#include <sycl/ext/oneapi/experimental/use_root_sync_prop.hpp>
4040
#include <sycl/ext/oneapi/experimental/virtual_functions.hpp>
4141
#include <sycl/ext/oneapi/kernel_properties/properties.hpp>
@@ -164,8 +164,7 @@ class pipe;
164164
}
165165

166166
namespace ext ::oneapi ::experimental {
167-
template <typename, typename>
168-
class work_group_memory;
167+
template <typename, typename> class work_group_memory;
169168
struct image_descriptor;
170169
} // namespace ext::oneapi::experimental
171170

@@ -492,7 +491,8 @@ class __SYCL_EXPORT handler {
492491

493492
/// Saves the location of user's code passed in \p CodeLoc for future usage in
494493
/// finalize() method.
495-
/// TODO: remove the first version of this func (the one without the IsTopCodeLoc arg)
494+
/// TODO: remove the first version of this func (the one without the
495+
/// IsTopCodeLoc arg)
496496
/// at the next ABI breaking window since removing it breaks ABI on windows.
497497
void saveCodeLoc(detail::code_location CodeLoc);
498498
void saveCodeLoc(detail::code_location CodeLoc, bool IsTopCodeLoc);
@@ -703,8 +703,9 @@ class __SYCL_EXPORT handler {
703703
detail::KernelLambdaHasKernelHandlerArgT<KernelType,
704704
LambdaArgType>::value;
705705

706-
MHostKernel = std::make_unique<
707-
detail::HostKernel<KernelType, LambdaArgType, Dims>>(KernelFunc);
706+
MHostKernel =
707+
std::make_unique<detail::HostKernel<KernelType, LambdaArgType, Dims>>(
708+
KernelFunc);
708709

709710
constexpr bool KernelHasName =
710711
detail::getKernelName<KernelName>() != nullptr &&
@@ -2837,11 +2838,14 @@ class __SYCL_EXPORT handler {
28372838
/// require it to be available.
28382839
///
28392840
/// \param CGH is the handler to be used for prefetching.
2840-
/// \param Ptr is a USM pointer to the memory to be prefetched to the destination.
2841-
/// \param Count is a number of bytes to be prefetched.
2842-
/// \param Direction indicates the direction to prefetch data to/from.
2843-
void ext_oneapi_prefetch_exp(const void* Ptr, size_t Count, ext::oneapi::experimental::migration_direction Direction = ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE);
2844-
2841+
/// \param Ptr is a USM pointer to the memory to be prefetched to the
2842+
/// destination. \param Count is a number of bytes to be prefetched. \param
2843+
/// Direction indicates the direction to prefetch data to/from.
2844+
void ext_oneapi_prefetch_exp(
2845+
const void *Ptr, size_t Count,
2846+
ext::oneapi::experimental::migration_direction Direction =
2847+
ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE);
2848+
28452849
/// Provides additional information to the underlying runtime about how
28462850
/// different allocations are used.
28472851
///
@@ -3271,8 +3275,8 @@ class __SYCL_EXPORT handler {
32713275
bool MIsFinalized = false;
32723276
event MLastEvent;
32733277
/// Enum to indicate USM data migration direction
3274-
ext::oneapi::experimental::migration_direction MDirection = ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE;
3275-
3278+
ext::oneapi::experimental::migration_direction MDirection =
3279+
ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE;
32763280

32773281
// Make queue_impl class friend to be able to call finalize method.
32783282
friend class detail::queue_impl;

sycl/include/sycl/queue.hpp

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@
3030
#include <sycl/exception_list.hpp> // for defaultAsyncHa...
3131
#include <sycl/ext/oneapi/device_global/device_global.hpp> // for device_global
3232
#include <sycl/ext/oneapi/device_global/properties.hpp> // for device_image_s...
33-
#include <sycl/ext/oneapi/experimental/graph.hpp> // for command_graph...
3433
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp> // for migration...
35-
#include <sycl/ext/oneapi/properties/properties.hpp> // for empty_properti...
36-
#include <sycl/handler.hpp> // for handler, isDev...
37-
#include <sycl/id.hpp> // for id
38-
#include <sycl/kernel.hpp> // for auto_name
39-
#include <sycl/kernel_handler.hpp> // for kernel_handler
40-
#include <sycl/nd_range.hpp> // for nd_range
41-
#include <sycl/property_list.hpp> // for property_list
42-
#include <sycl/range.hpp> // for range
34+
#include <sycl/ext/oneapi/experimental/graph.hpp> // for command_graph...
35+
#include <sycl/ext/oneapi/properties/properties.hpp> // for empty_properti...
36+
#include <sycl/handler.hpp> // for handler, isDev...
37+
#include <sycl/id.hpp> // for id
38+
#include <sycl/kernel.hpp> // for auto_name
39+
#include <sycl/kernel_handler.hpp> // for kernel_handler
40+
#include <sycl/nd_range.hpp> // for nd_range
41+
#include <sycl/property_list.hpp> // for property_list
42+
#include <sycl/range.hpp> // for range
4343

4444
#include <cstddef> // for size_t
4545
#include <functional> // for function
@@ -757,11 +757,15 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
757757
/// \return an event representing prefetch operation.
758758
event ext_oneapi_prefetch_exp(
759759
const void *Ptr, size_t Count,
760-
ext::oneapi::experimental::migration_direction Direction = ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
760+
ext::oneapi::experimental::migration_direction Direction =
761+
ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
761762
const detail::code_location &CodeLoc = detail::code_location::current()) {
762763
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
763-
return submit([=](handler &CGH) { CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction); },
764-
TlsCodeLocCapture.query());
764+
return submit(
765+
[=](handler &CGH) {
766+
CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
767+
},
768+
TlsCodeLocCapture.query());
765769
}
766770

767771
/// Provides hints to the runtime library that data should be made available
@@ -796,7 +800,8 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
796800
/// \return an event representing prefetch operation.
797801
event ext_oneapi_prefetch_exp(
798802
const void *Ptr, size_t Count, event DepEvent,
799-
ext::oneapi::experimental::migration_direction Direction = ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
803+
ext::oneapi::experimental::migration_direction Direction =
804+
ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
800805
const detail::code_location &CodeLoc = detail::code_location::current()) {
801806
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
802807
return submit(
@@ -841,7 +846,8 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
841846
/// \return an event representing prefetch operation.
842847
event ext_oneapi_prefetch_exp(
843848
const void *Ptr, size_t Count, const std::vector<event> &DepEvents,
844-
ext::oneapi::experimental::migration_direction Direction = ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
849+
ext::oneapi::experimental::migration_direction Direction =
850+
ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
845851
const detail::code_location &CodeLoc = detail::code_location::current()) {
846852
detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
847853
return submit(
@@ -2818,7 +2824,8 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
28182824
queue(std::shared_ptr<detail::queue_impl> impl) : impl(impl) {}
28192825

28202826
template <class Obj>
2821-
friend const decltype(Obj::impl)& detail::getSyclObjImpl(const Obj &SyclObject);
2827+
friend const decltype(Obj::impl) &
2828+
detail::getSyclObjImpl(const Obj &SyclObject);
28222829
template <class T>
28232830
friend T detail::createSyclObjFromImpl(decltype(T::impl) ImplObj);
28242831

sycl/source/detail/cg.hpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
#include <sycl/detail/ur.hpp> // for ur_rect_region_t, ur_rect_offset_t
1616
#include <sycl/event.hpp> // for event_impl
1717
#include <sycl/exception_list.hpp> // for queue_impl
18-
#include <sycl/kernel.hpp> // for kernel_impl
19-
#include <sycl/kernel_bundle.hpp> // for kernel_bundle_impl
2018
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp> // for migration_direction
19+
#include <sycl/kernel.hpp> // for kernel_impl
20+
#include <sycl/kernel_bundle.hpp> // for kernel_bundle_impl
2121

2222
#include <assert.h> // for assert
2323
#include <memory> // for shared_ptr, unique_ptr
@@ -112,8 +112,8 @@ class NDRDescT {
112112

113113
NDRDescT(sycl::range<3> NumWorkItems, sycl::range<3> LocalSize,
114114
sycl::id<3> Offset, int DimsArg)
115-
: GlobalSize{NumWorkItems}, LocalSize{LocalSize}, GlobalOffset{Offset},
116-
Dims{size_t(DimsArg)} {
115+
: GlobalSize{NumWorkItems}, LocalSize{LocalSize},
116+
GlobalOffset{Offset}, Dims{size_t(DimsArg)} {
117117
setNDRangeLeftover();
118118
}
119119

@@ -228,7 +228,7 @@ class CG {
228228
getAuxiliaryResources() const {
229229
return {};
230230
}
231-
virtual void clearAuxiliaryResources() {};
231+
virtual void clearAuxiliaryResources(){};
232232

233233
virtual ~CG() = default;
234234

@@ -319,8 +319,8 @@ class CGCopy : public CG {
319319
CGCopy(CGType CopyType, void *Src, void *Dst, CG::StorageInitHelper CGData,
320320
std::vector<std::shared_ptr<const void>> AuxiliaryResources,
321321
detail::code_location loc = {})
322-
: CG(CopyType, std::move(CGData), std::move(loc)), MSrc(Src), MDst(Dst),
323-
MAuxiliaryResources{AuxiliaryResources} {}
322+
: CG(CopyType, std::move(CGData), std::move(loc)), MSrc(Src),
323+
MDst(Dst), MAuxiliaryResources{AuxiliaryResources} {}
324324
void *getSrc() { return MSrc; }
325325
void *getDst() { return MDst; }
326326

@@ -397,13 +397,16 @@ class CGPrefetchUSM : public CG {
397397
ext::oneapi::experimental::migration_direction MDirection;
398398

399399
public:
400-
CGPrefetchUSM(void *DstPtr, size_t Length, CG::StorageInitHelper CGData, ext::oneapi::experimental::migration_direction Direction,
400+
CGPrefetchUSM(void *DstPtr, size_t Length, CG::StorageInitHelper CGData,
401+
ext::oneapi::experimental::migration_direction Direction,
401402
detail::code_location loc = {})
402403
: CG(CGType::PrefetchUSM, std::move(CGData), std::move(loc)),
403404
MDst(DstPtr), MLength(Length), MDirection(Direction) {}
404405
void *getDst() { return MDst; }
405406
size_t getLength() { return MLength; }
406-
ext::oneapi::experimental::migration_direction getDirection() { return MDirection; }
407+
ext::oneapi::experimental::migration_direction getDirection() {
408+
return MDirection;
409+
}
407410
};
408411

409412
/// "Advise USM" command group class.

sycl/source/detail/memory_manager.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -964,20 +964,23 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length,
964964
DepEvents.size(), DepEvents.data(), OutEvent);
965965
}
966966

967-
void MemoryManager::prefetch_usm(void *Mem, QueueImplPtr Queue, size_t Length, sycl::ext::oneapi::experimental::migration_direction Direction,
968-
std::vector<ur_event_handle_t> DepEvents,
969-
ur_event_handle_t *OutEvent,
970-
const detail::EventImplPtr &OutEventImpl) {
967+
void MemoryManager::prefetch_usm(
968+
void *Mem, QueueImplPtr Queue, size_t Length,
969+
sycl::ext::oneapi::experimental::migration_direction Direction,
970+
std::vector<ur_event_handle_t> DepEvents, ur_event_handle_t *OutEvent,
971+
const detail::EventImplPtr &OutEventImpl) {
971972
assert(Queue && "USM prefetch must be called with a valid device queue");
972973
const AdapterPtr &Adapter = Queue->getAdapter();
973-
ur_usm_migration_flags_t migration_flag = UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE;
974-
if (Direction == sycl::ext::oneapi::experimental::migration_direction::DEVICE_TO_HOST)
974+
ur_usm_migration_flags_t migration_flag =
975+
UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE;
976+
if (Direction ==
977+
sycl::ext::oneapi::experimental::migration_direction::DEVICE_TO_HOST)
975978
migration_flag = UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
976979
if (OutEventImpl != nullptr)
977980
OutEventImpl->setHostEnqueueTime();
978-
Adapter->call<UrApiKind::urEnqueueUSMPrefetch>(Queue->getHandleRef(), Mem,
979-
Length, migration_flag, DepEvents.size(),
980-
DepEvents.data(), OutEvent);
981+
Adapter->call<UrApiKind::urEnqueueUSMPrefetch>(
982+
Queue->getHandleRef(), Mem, Length, migration_flag, DepEvents.size(),
983+
DepEvents.data(), OutEvent);
981984
}
982985

983986
void MemoryManager::advise_usm(const void *Mem, QueueImplPtr Queue,
@@ -1613,16 +1616,19 @@ void MemoryManager::ext_oneapi_fill_cmd_buffer(
16131616

16141617
void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer(
16151618
sycl::detail::ContextImplPtr Context,
1616-
ur_exp_command_buffer_handle_t CommandBuffer, void *Mem, size_t Length, sycl::ext::oneapi::experimental::migration_direction Direction,
1619+
ur_exp_command_buffer_handle_t CommandBuffer, void *Mem, size_t Length,
1620+
sycl::ext::oneapi::experimental::migration_direction Direction,
16171621
std::vector<ur_exp_command_buffer_sync_point_t> Deps,
16181622
ur_exp_command_buffer_sync_point_t *OutSyncPoint) {
16191623
const AdapterPtr &Adapter = Context->getAdapter();
1620-
ur_usm_migration_flags_t migration_flag = UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE;
1621-
if (Direction == sycl::ext::oneapi::experimental::migration_direction::DEVICE_TO_HOST)
1624+
ur_usm_migration_flags_t migration_flag =
1625+
UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE;
1626+
if (Direction ==
1627+
sycl::ext::oneapi::experimental::migration_direction::DEVICE_TO_HOST)
16221628
migration_flag = UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
16231629
Adapter->call<UrApiKind::urCommandBufferAppendUSMPrefetchExp>(
1624-
CommandBuffer, Mem, Length, migration_flag, Deps.size(),
1625-
Deps.data(), 0, nullptr, OutSyncPoint, nullptr, nullptr);
1630+
CommandBuffer, Mem, Length, migration_flag, Deps.size(), Deps.data(), 0,
1631+
nullptr, OutSyncPoint, nullptr, nullptr);
16261632
}
16271633

16281634
void MemoryManager::ext_oneapi_advise_usm_cmd_buffer(

sycl/source/detail/memory_manager.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
#include <detail/sycl_mem_obj_i.hpp>
1212
#include <sycl/access/access.hpp>
1313
#include <sycl/detail/export.hpp>
14+
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp>
1415
#include <sycl/id.hpp>
1516
#include <sycl/property_list.hpp>
1617
#include <sycl/range.hpp>
17-
#include <sycl/ext/oneapi/experimental/USM/prefetch_exp.hpp>
1818

1919
#include <ur_api.h>
2020

@@ -150,10 +150,12 @@ class MemoryManager {
150150
ur_event_handle_t *OutEvent,
151151
const detail::EventImplPtr &OutEventImpl);
152152

153-
static void prefetch_usm(void *Ptr, QueueImplPtr Queue, size_t Len, sycl::ext::oneapi::experimental::migration_direction Direction,
154-
std::vector<ur_event_handle_t> DepEvents,
155-
ur_event_handle_t *OutEvent,
156-
const detail::EventImplPtr &OutEventImpl);
153+
static void
154+
prefetch_usm(void *Ptr, QueueImplPtr Queue, size_t Len,
155+
sycl::ext::oneapi::experimental::migration_direction Direction,
156+
std::vector<ur_event_handle_t> DepEvents,
157+
ur_event_handle_t *OutEvent,
158+
const detail::EventImplPtr &OutEventImpl);
157159

158160
static void advise_usm(const void *Ptr, QueueImplPtr Queue, size_t Len,
159161
ur_usm_advice_flags_t Advice,

sycl/source/detail/scheduler/commands.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3001,7 +3001,8 @@ ur_result_t ExecCGCommand::enqueueImpCommandBuffer() {
30013001
if (auto Result = callMemOpHelper(
30023002
MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer,
30033003
MQueue->getContextImplPtr(), MCommandBuffer, Prefetch->getDst(),
3004-
Prefetch->getLength(), Prefetch->getDirection(), std::move(MSyncPointDeps), &OutSyncPoint);
3004+
Prefetch->getLength(), Prefetch->getDirection(),
3005+
std::move(MSyncPointDeps), &OutSyncPoint);
30053006
Result != UR_RESULT_SUCCESS)
30063007
return Result;
30073008

@@ -3208,7 +3209,8 @@ ur_result_t ExecCGCommand::enqueueImpQueue() {
32083209
CGPrefetchUSM *Prefetch = (CGPrefetchUSM *)MCommandGroup.get();
32093210
if (auto Result = callMemOpHelper(
32103211
MemoryManager::prefetch_usm, Prefetch->getDst(), MQueue,
3211-
Prefetch->getLength(), Prefetch->getDirection(), std::move(RawEvents), Event, MEvent);
3212+
Prefetch->getLength(), Prefetch->getDirection(),
3213+
std::move(RawEvents), Event, MEvent);
32123214
Result != UR_RESULT_SUCCESS)
32133215
return Result;
32143216

sycl/source/handler.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,9 @@ void handler::prefetch(const void *Ptr, size_t Count) {
984984
setType(detail::CGType::PrefetchUSM);
985985
}
986986

987-
void handler::ext_oneapi_prefetch_exp(const void* ptr, size_t Count, ext::oneapi::experimental::migration_direction Direction) {
987+
void handler::ext_oneapi_prefetch_exp(
988+
const void *ptr, size_t Count,
989+
ext::oneapi::experimental::migration_direction Direction) {
988990
throwIfActionIsCreated();
989991
MDstPtr = const_cast<void *>(ptr);
990992
MLength = Count;

0 commit comments

Comments
 (0)