Skip to content

Commit 272adc6

Browse files
committed
applied clang format
1 parent f0f228e commit 272adc6

File tree

10 files changed

+140
-104
lines changed

10 files changed

+140
-104
lines changed

sycl/include/sycl/ext/oneapi/experimental/enqueue_functions.hpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212

1313
#include <sycl/detail/common.hpp>
1414
#include <sycl/event.hpp>
15-
#include <sycl/ext/oneapi/experimental/graph.hpp>
1615
#include <sycl/ext/oneapi/experimental/enqueue_types.hpp>
16+
#include <sycl/ext/oneapi/experimental/graph.hpp>
1717
#include <sycl/ext/oneapi/properties/properties.hpp>
1818
#include <sycl/handler.hpp>
1919
#include <sycl/nd_range.hpp>
@@ -350,18 +350,21 @@ void fill(sycl::queue Q, T *Ptr, const T &Pattern, size_t Count,
350350
submit(Q, [&](handler &CGH) { fill<T>(CGH, Ptr, Pattern, Count); }, CodeLoc);
351351
}
352352

353-
inline void prefetch(handler &CGH, void *Ptr, size_t NumBytes, prefetch_type type = prefetch_type::device) {
353+
inline void prefetch(handler &CGH, void *Ptr, size_t NumBytes,
354+
prefetch_type type = prefetch_type::device) {
354355
if (type == prefetch_type::device) {
355356
CGH.prefetch(Ptr, NumBytes);
356357
} else {
357358
CGH.ext_oneapi_prefetch_d2h(Ptr, NumBytes);
358359
}
359360
}
360361

361-
inline void prefetch(queue Q, void *Ptr, size_t NumBytes, prefetch_type type = prefetch_type::device,
362+
inline void prefetch(queue Q, void *Ptr, size_t NumBytes,
363+
prefetch_type type = prefetch_type::device,
362364
const sycl::detail::code_location &CodeLoc =
363365
sycl::detail::code_location::current()) {
364-
submit(Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes, type); }, CodeLoc);
366+
submit(
367+
Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes, type); }, CodeLoc);
365368
}
366369

367370
inline void mem_advise(handler &CGH, void *Ptr, size_t NumBytes, int Advice) {

sycl/include/sycl/ext/oneapi/experimental/enqueue_types.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ namespace sycl {
1212
inline namespace _V1 {
1313
namespace ext::oneapi::experimental {
1414

15-
enum class prefetch_type {
16-
device,
17-
host
18-
};
15+
enum class prefetch_type { device, host };
1916

2017
} // namespace ext::oneapi::experimental
2118
} // namespace _V1

sycl/include/sycl/handler.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3538,10 +3538,13 @@ class __SYCL_EXPORT handler {
35383538
bool IsDeviceImageScoped, size_t NumBytes,
35393539
size_t Offset);
35403540

3541-
// Implementation of USM prefetch, fetching from device back to host.
3541+
// Implementation of USM prefetch, fetching from device back to host.
35423542
void ext_oneapi_prefetch_d2h(const void *Ptr, size_t Count);
3543-
// Friend prefetch from the enqueue functions extension to allow call to private function ext_oneapi_prefetch_d2h
3544-
friend void sycl::ext::oneapi::experimental::prefetch(handler &CGH, void *Ptr, size_t NumBytes, sycl::ext::oneapi::experimental::prefetch_type type);
3543+
// Friend prefetch from the enqueue functions extension to allow call to
3544+
// private function ext_oneapi_prefetch_d2h
3545+
friend void sycl::ext::oneapi::experimental::prefetch(
3546+
handler &CGH, void *Ptr, size_t NumBytes,
3547+
sycl::ext::oneapi::experimental::prefetch_type type);
35453548

35463549
// Changing values in this will break ABI/API.
35473550
enum class StableKernelCacheConfig : int32_t {

sycl/include/sycl/queue.hpp

Lines changed: 83 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -745,27 +745,32 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
745745
TlsCodeLocCapture.query());
746746
}
747747

748-
// /// Experimental implementation of prefetch supporting bidirectional USM data
749-
// /// migration: Provides hints to the runtime library that data should be made
750-
// /// available on a device earlier than Unified Shared Memory would normally
751-
// /// require it to be available.
752-
// ///
753-
// /// \param Ptr is a USM pointer to the memory to be prefetched to the device.
754-
// /// \param Count is a number of bytes to be prefetched.
755-
// /// \param Direction indicates the direction to prefetch data to/from.
756-
// /// \return an event representing prefetch operation.
757-
// event ext_oneapi_prefetch_exp(
758-
// const void *Ptr, size_t Count,
759-
// ext::oneapi::experimental::migration_direction Direction =
760-
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
761-
// const detail::code_location &CodeLoc = detail::code_location::current()) {
762-
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
763-
// return submit(
764-
// [=](handler &CGH) {
765-
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
766-
// },
767-
// TlsCodeLocCapture.query());
768-
// }
748+
// /// Experimental implementation of prefetch supporting bidirectional USM
749+
// data
750+
// /// migration: Provides hints to the runtime library that data should be
751+
// made
752+
// /// available on a device earlier than Unified Shared Memory would
753+
// normally
754+
// /// require it to be available.
755+
// ///
756+
// /// \param Ptr is a USM pointer to the memory to be prefetched to the
757+
// device.
758+
// /// \param Count is a number of bytes to be prefetched.
759+
// /// \param Direction indicates the direction to prefetch data to/from.
760+
// /// \return an event representing prefetch operation.
761+
// event ext_oneapi_prefetch_exp(
762+
// const void *Ptr, size_t Count,
763+
// ext::oneapi::experimental::migration_direction Direction =
764+
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
765+
// const detail::code_location &CodeLoc =
766+
// detail::code_location::current()) {
767+
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
768+
// return submit(
769+
// [=](handler &CGH) {
770+
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
771+
// },
772+
// TlsCodeLocCapture.query());
773+
// }
769774

770775
/// Provides hints to the runtime library that data should be made available
771776
/// on a device earlier than Unified Shared Memory would normally require it
@@ -787,29 +792,34 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
787792
TlsCodeLocCapture.query());
788793
}
789794

790-
// /// Experimental implementation of prefetch supporting bidirectional USM data
791-
// /// migration: Provides hints to the runtime library that data should be made
792-
// /// available on a device earlier than Unified Shared Memory would normally
793-
// /// require it to be available.
794-
// ///
795-
// /// \param Ptr is a USM pointer to the memory to be prefetched to the device.
796-
// /// \param Count is a number of bytes to be prefetched.
797-
// /// \param DepEvent is an event that specifies the kernel dependencies.
798-
// /// \param Direction indicates the direction to prefetch data to/from.
799-
// /// \return an event representing prefetch operation.
800-
// event ext_oneapi_prefetch_exp(
801-
// const void *Ptr, size_t Count, event DepEvent,
802-
// ext::oneapi::experimental::migration_direction Direction =
803-
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
804-
// const detail::code_location &CodeLoc = detail::code_location::current()) {
805-
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
806-
// return submit(
807-
// [=](handler &CGH) {
808-
// CGH.depends_on(DepEvent);
809-
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
810-
// },
811-
// TlsCodeLocCapture.query());
812-
// }
795+
// /// Experimental implementation of prefetch supporting bidirectional USM
796+
// data
797+
// /// migration: Provides hints to the runtime library that data should be
798+
// made
799+
// /// available on a device earlier than Unified Shared Memory would
800+
// normally
801+
// /// require it to be available.
802+
// ///
803+
// /// \param Ptr is a USM pointer to the memory to be prefetched to the
804+
// device.
805+
// /// \param Count is a number of bytes to be prefetched.
806+
// /// \param DepEvent is an event that specifies the kernel dependencies.
807+
// /// \param Direction indicates the direction to prefetch data to/from.
808+
// /// \return an event representing prefetch operation.
809+
// event ext_oneapi_prefetch_exp(
810+
// const void *Ptr, size_t Count, event DepEvent,
811+
// ext::oneapi::experimental::migration_direction Direction =
812+
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
813+
// const detail::code_location &CodeLoc =
814+
// detail::code_location::current()) {
815+
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
816+
// return submit(
817+
// [=](handler &CGH) {
818+
// CGH.depends_on(DepEvent);
819+
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
820+
// },
821+
// TlsCodeLocCapture.query());
822+
// }
813823

814824
/// Provides hints to the runtime library that data should be made available
815825
/// on a device earlier than Unified Shared Memory would normally require it
@@ -832,30 +842,35 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
832842
TlsCodeLocCapture.query());
833843
}
834844

835-
// /// Experimental implementation of prefetch supporting bidirectional USM data
836-
// /// migration: Provides hints to the runtime library that data should be made
837-
// /// available on a device earlier than Unified Shared Memory would normally
838-
// /// require it to be available.
839-
// ///
840-
// /// \param Ptr is a USM pointer to the memory to be prefetched to the device.
841-
// /// \param Count is a number of bytes to be prefetched.
842-
// /// \param DepEvents is a vector of events that specifies the kernel
843-
// /// dependencies.
844-
// /// \param Direction indicates the direction to prefetch data to/from.
845-
// /// \return an event representing prefetch operation.
846-
// event ext_oneapi_prefetch_exp(
847-
// const void *Ptr, size_t Count, const std::vector<event> &DepEvents,
848-
// ext::oneapi::experimental::migration_direction Direction =
849-
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
850-
// const detail::code_location &CodeLoc = detail::code_location::current()) {
851-
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
852-
// return submit(
853-
// [=](handler &CGH) {
854-
// CGH.depends_on(DepEvents);
855-
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
856-
// },
857-
// TlsCodeLocCapture.query());
858-
// }
845+
// /// Experimental implementation of prefetch supporting bidirectional USM
846+
// data
847+
// /// migration: Provides hints to the runtime library that data should be
848+
// made
849+
// /// available on a device earlier than Unified Shared Memory would
850+
// normally
851+
// /// require it to be available.
852+
// ///
853+
// /// \param Ptr is a USM pointer to the memory to be prefetched to the
854+
// device.
855+
// /// \param Count is a number of bytes to be prefetched.
856+
// /// \param DepEvents is a vector of events that specifies the kernel
857+
// /// dependencies.
858+
// /// \param Direction indicates the direction to prefetch data to/from.
859+
// /// \return an event representing prefetch operation.
860+
// event ext_oneapi_prefetch_exp(
861+
// const void *Ptr, size_t Count, const std::vector<event> &DepEvents,
862+
// ext::oneapi::experimental::migration_direction Direction =
863+
// ext::oneapi::experimental::migration_direction::HOST_TO_DEVICE,
864+
// const detail::code_location &CodeLoc =
865+
// detail::code_location::current()) {
866+
// detail::tls_code_loc_t TlsCodeLocCapture(CodeLoc);
867+
// return submit(
868+
// [=](handler &CGH) {
869+
// CGH.depends_on(DepEvents);
870+
// CGH.ext_oneapi_prefetch_exp(Ptr, Count, Direction);
871+
// },
872+
// TlsCodeLocCapture.query());
873+
// }
859874

860875
/// Copies data from one 2D memory region to another, both pointed by
861876
/// USM pointers.

sycl/source/detail/cg.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ class CGPrefetchUSMExpD2H : public CG {
410410

411411
public:
412412
CGPrefetchUSMExpD2H(void *DstPtr, size_t Length, CG::StorageInitHelper CGData,
413-
detail::code_location loc = {})
413+
detail::code_location loc = {})
414414
: CG(CGType::PrefetchUSMExpD2H, std::move(CGData), std::move(loc)),
415415
MDst(DstPtr), MLength(Length) {}
416416
void *getDst() { return MDst; }

sycl/source/detail/memory_manager.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -972,8 +972,9 @@ void MemoryManager::prefetch_usm(
972972
assert(Queue && "USM prefetch must be called with a valid device queue");
973973
const AdapterPtr &Adapter = Queue->getAdapter();
974974
ur_usm_migration_flags_t migration_flag =
975-
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device) ?
976-
UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE : UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
975+
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device)
976+
? UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
977+
: UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
977978
if (OutEventImpl != nullptr)
978979
OutEventImpl->setHostEnqueueTime();
979980
Adapter->call<UrApiKind::urEnqueueUSMPrefetch>(
@@ -1620,8 +1621,9 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer(
16201621
sycl::ext::oneapi::experimental::prefetch_type Dest) {
16211622
const AdapterPtr &Adapter = Context->getAdapter();
16221623
ur_usm_migration_flags_t migration_flag =
1623-
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device) ?
1624-
UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE : UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
1624+
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device)
1625+
? UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
1626+
: UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
16251627
Adapter->call<UrApiKind::urCommandBufferAppendUSMPrefetchExp>(
16261628
CommandBuffer, Mem, Length, migration_flag, Deps.size(), Deps.data(), 0,
16271629
nullptr, OutSyncPoint, nullptr, nullptr);

sycl/source/detail/memory_manager.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@ class MemoryManager {
155155
std::vector<ur_event_handle_t> DepEvents,
156156
ur_event_handle_t *OutEvent,
157157
const detail::EventImplPtr &OutEventImpl,
158-
sycl::ext::oneapi::experimental::prefetch_type Dest = sycl::ext::oneapi::experimental::prefetch_type::device
159-
);
158+
sycl::ext::oneapi::experimental::prefetch_type Dest =
159+
sycl::ext::oneapi::experimental::prefetch_type::device);
160160

161161
static void advise_usm(const void *Ptr, QueueImplPtr Queue, size_t Len,
162162
ur_usm_advice_flags_t Advice,
@@ -255,9 +255,9 @@ class MemoryManager {
255255
sycl::detail::ContextImplPtr Context,
256256
ur_exp_command_buffer_handle_t CommandBuffer, void *Mem, size_t Length,
257257
std::vector<ur_exp_command_buffer_sync_point_t> Deps,
258-
ur_exp_command_buffer_sync_point_t *OutSyncPoint,
259-
sycl::ext::oneapi::experimental::prefetch_type Dest = sycl::ext::oneapi::experimental::prefetch_type::device
260-
);
258+
ur_exp_command_buffer_sync_point_t *OutSyncPoint,
259+
sycl::ext::oneapi::experimental::prefetch_type Dest =
260+
sycl::ext::oneapi::experimental::prefetch_type::device);
261261

262262
static void ext_oneapi_advise_usm_cmd_buffer(
263263
sycl::detail::ContextImplPtr Context,

sycl/source/detail/scheduler/commands.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include <sycl/detail/cg_types.hpp>
2929
#include <sycl/detail/helpers.hpp>
3030
#include <sycl/detail/kernel_desc.hpp>
31-
#include <sycl/sampler.hpp>
3231
#include <sycl/ext/oneapi/experimental/enqueue_types.hpp> // For prefetch_type
32+
#include <sycl/sampler.hpp>
3333

3434
#include <cassert>
3535
#include <optional>

sycl/test-e2e/USM/prefetch_exp.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ int main() {
3333

3434
{
3535
// Test host to device handler::ext_oneapi_prefetch_exp
36-
event init_prefetch = ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
37-
ext::oneapi::experimental::prefetch(cgh, src, sizeof(float) * count);
38-
});
36+
event init_prefetch =
37+
ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
38+
ext::oneapi::experimental::prefetch(cgh, src,
39+
sizeof(float) * count);
40+
});
3941

4042
q.submit([&](handler &cgh) {
4143
cgh.depends_on(init_prefetch);
@@ -57,9 +59,12 @@ int main() {
5759
dest[i] = 4 * src[i];
5860
});
5961
});
60-
event init_prefetch_back = ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
61-
ext::oneapi::experimental::prefetch(cgh, src, sizeof(float) * count, ext::oneapi::experimental::prefetch_type::host);
62-
});
62+
event init_prefetch_back =
63+
ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
64+
ext::oneapi::experimental::prefetch(
65+
cgh, src, sizeof(float) * count,
66+
ext::oneapi::experimental::prefetch_type::host);
67+
});
6368
q.wait_and_throw();
6469

6570
for (int i = 0; i < count; i++) {
@@ -69,7 +74,9 @@ int main() {
6974

7075
// Test queue::prefetch
7176
{
72-
ext::oneapi::experimental::prefetch(q, src, sizeof(float) * count, ext::oneapi::experimental::prefetch_type::device);
77+
ext::oneapi::experimental::prefetch(
78+
q, src, sizeof(float) * count,
79+
ext::oneapi::experimental::prefetch_type::device);
7380
q.wait_and_throw();
7481

7582
q.submit([&](handler &cgh) {
@@ -91,7 +98,9 @@ int main() {
9198
});
9299
});
93100
q.wait_and_throw();
94-
ext::oneapi::experimental::prefetch(q, src, sizeof(float) * count, ext::oneapi::experimental::prefetch_type::host);
101+
ext::oneapi::experimental::prefetch(
102+
q, src, sizeof(float) * count,
103+
ext::oneapi::experimental::prefetch_type::host);
95104
q.wait_and_throw();
96105

97106
for (int i = 0; i < count; i++) {

0 commit comments

Comments
 (0)