Skip to content

Commit 4e910dc

Browse files
committed
cleanup
1 parent 653df4f commit 4e910dc

File tree

8 files changed

+120
-120
lines changed

8 files changed

+120
-120
lines changed

sycl/include/sycl/detail/cg_types.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
#include <sycl/detail/item_base.hpp> // for id
1616
#include <sycl/detail/kernel_desc.hpp> // for kernel_param_kind_t
1717
#include <sycl/exception.hpp>
18-
#include <sycl/group.hpp> // for group
19-
#include <sycl/h_item.hpp> // for h_item
20-
#include <sycl/id.hpp> // for id
21-
#include <sycl/item.hpp> // for item
22-
#include <sycl/kernel_handler.hpp> // for kernel_handler
23-
#include <sycl/nd_item.hpp> // for nd_item
24-
#include <sycl/nd_range.hpp> // for nd_range
25-
#include <sycl/range.hpp> // for range, operator*
26-
27-
#include <functional> // for function
28-
#include <stddef.h> // for size_t
29-
#include <type_traits> // for enable_if_t, false_type
30-
#include <utility> // for declval
18+
#include <sycl/group.hpp> // for group
19+
#include <sycl/h_item.hpp> // for h_item
20+
#include <sycl/id.hpp> // for id
21+
#include <sycl/item.hpp> // for item
22+
#include <sycl/kernel_handler.hpp> // for kernel_handler
23+
#include <sycl/nd_item.hpp> // for nd_item
24+
#include <sycl/nd_range.hpp> // for nd_range
25+
#include <sycl/range.hpp> // for range, operator*
26+
27+
#include <functional> // for function
28+
#include <stddef.h> // for size_t
29+
#include <type_traits> // for enable_if_t, false_type
30+
#include <utility> // for declval
3131

3232
namespace sycl {
3333
inline namespace _V1 {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,11 @@ void fill(sycl::queue Q, T *Ptr, const T &Pattern, size_t Count,
358358
}
359359

360360
inline void prefetch(handler &CGH, void *Ptr, size_t NumBytes,
361-
prefetch_type type = prefetch_type::device) {
361+
prefetch_type Type = prefetch_type::device) {
362362
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
363-
CGH.ext_oneapi_prefetch_exp(Ptr, NumBytes, type);
363+
CGH.ext_oneapi_prefetch_exp(Ptr, NumBytes, Type);
364364
#else
365-
if (type == prefetch_type::device) {
365+
if (Type == prefetch_type::device) {
366366
CGH.prefetch(Ptr, NumBytes);
367367
} else {
368368
CGH.ext_oneapi_prefetch_d2h(Ptr, NumBytes);
@@ -371,10 +371,10 @@ inline void prefetch(handler &CGH, void *Ptr, size_t NumBytes,
371371
}
372372

373373
inline void prefetch(queue Q, void *Ptr, size_t NumBytes,
374-
prefetch_type type = prefetch_type::device,
374+
prefetch_type Type = prefetch_type::device,
375375
const sycl::detail::code_location &CodeLoc =
376376
sycl::detail::code_location::current()) {
377-
submit(Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes, type); }, CodeLoc);
377+
submit(Q, [&](handler &CGH) { prefetch(CGH, Ptr, NumBytes, Type); }, CodeLoc);
378378
}
379379

380380
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace sycl {
1212
inline namespace _V1 {
1313
namespace ext::oneapi::experimental {
1414

15-
/// @brief Indicates the destination device for USM data to be prefetched to
15+
/// @brief Indicates the destination device for USM data to be prefetched to.
1616
enum class prefetch_type { device, host };
1717

1818
} // namespace ext::oneapi::experimental

sycl/include/sycl/handler.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3529,7 +3529,7 @@ class __SYCL_EXPORT handler {
35293529
// private function ext_oneapi_prefetch_d2h
35303530
friend void sycl::ext::oneapi::experimental::prefetch(
35313531
handler &CGH, void *Ptr, size_t NumBytes,
3532-
sycl::ext::oneapi::experimental::prefetch_type type);
3532+
sycl::ext::oneapi::experimental::prefetch_type Type);
35333533

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

sycl/source/detail/cg.hpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
#ifdef __INTEL_PREVIEW_BREAKING_CHANGES
2020
#include <sycl/ext/oneapi/experimental/enqueue_types.hpp> // for prefetch_type
2121
#endif
22-
#include <sycl/kernel.hpp> // for kernel_impl
23-
#include <sycl/kernel_bundle.hpp> // for kernel_bundle_impl
24-
25-
#include <assert.h> // for assert
26-
#include <memory> // for shared_ptr, unique_ptr
27-
#include <stddef.h> // for size_t
28-
#include <stdint.h> // for int32_t
29-
#include <string> // for string
30-
#include <utility> // for move
31-
#include <vector> // for vector
22+
#include <sycl/kernel.hpp> // for kernel_impl
23+
#include <sycl/kernel_bundle.hpp> // for kernel_bundle_impl
24+
25+
#include <assert.h> // for assert
26+
#include <memory> // for shared_ptr, unique_ptr
27+
#include <stddef.h> // for size_t
28+
#include <stdint.h> // for int32_t
29+
#include <string> // for string
30+
#include <utility> // for move
31+
#include <vector> // for vector
3232

3333
namespace sycl {
3434
inline namespace _V1 {

sycl/source/detail/memory_manager.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -971,14 +971,14 @@ void MemoryManager::prefetch_usm(
971971
sycl::ext::oneapi::experimental::prefetch_type Dest) {
972972
assert(Queue && "USM prefetch must be called with a valid device queue");
973973
const AdapterPtr &Adapter = Queue->getAdapter();
974-
ur_usm_migration_flags_t migration_flag =
974+
ur_usm_migration_flags_t MigrationFlag =
975975
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device)
976976
? UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
977977
: UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
978978
if (OutEventImpl != nullptr)
979979
OutEventImpl->setHostEnqueueTime();
980980
Adapter->call<UrApiKind::urEnqueueUSMPrefetch>(
981-
Queue->getHandleRef(), Mem, Length, migration_flag, DepEvents.size(),
981+
Queue->getHandleRef(), Mem, Length, MigrationFlag, DepEvents.size(),
982982
DepEvents.data(), OutEvent);
983983
}
984984

@@ -1620,12 +1620,12 @@ void MemoryManager::ext_oneapi_prefetch_usm_cmd_buffer(
16201620
ur_exp_command_buffer_sync_point_t *OutSyncPoint,
16211621
sycl::ext::oneapi::experimental::prefetch_type Dest) {
16221622
const AdapterPtr &Adapter = Context->getAdapter();
1623-
ur_usm_migration_flags_t migration_flag =
1623+
ur_usm_migration_flags_t MigrationFlag =
16241624
(Dest == sycl::ext::oneapi::experimental::prefetch_type::device)
16251625
? UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE
16261626
: UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST;
16271627
Adapter->call<UrApiKind::urCommandBufferAppendUSMPrefetchExp>(
1628-
CommandBuffer, Mem, Length, migration_flag, Deps.size(), Deps.data(), 0,
1628+
CommandBuffer, Mem, Length, MigrationFlag, Deps.size(), Deps.data(), 0,
16291629
nullptr, OutSyncPoint, nullptr, nullptr);
16301630
}
16311631

sycl/test-e2e/USM/prefetch_exp.cpp

Lines changed: 78 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -15,99 +15,102 @@
1515

1616
using namespace sycl;
1717

18-
static constexpr int count = 100;
18+
static constexpr int Count = 100;
1919

2020
int main() {
2121
queue q([](exception_list el) {
2222
for (auto &e : el)
2323
throw e;
2424
});
25-
if (q.get_device().get_info<info::device::usm_shared_allocations>()) {
26-
float *src = (float *)malloc_shared(sizeof(float) * count, q.get_device(),
25+
26+
if (!q.get_device().get_info<info::device::usm_shared_allocations>()) {
27+
// USM not supported, skipping test and returning early.
28+
return 0;
29+
}
30+
31+
float *Src = (float *)malloc_shared(sizeof(float) * Count, q.get_device(),
32+
q.get_context());
33+
float *Dest = (float *)malloc_shared(sizeof(float) * Count, q.get_device(),
2734
q.get_context());
28-
float *dest = (float *)malloc_shared(sizeof(float) * count, q.get_device(),
29-
q.get_context());
30-
for (int i = 0; i < count; i++)
31-
src[i] = i;
32-
33-
{
34-
// Test host to device handler::ext_oneapi_prefetch_exp
35-
event init_prefetch =
36-
ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
37-
ext::oneapi::experimental::prefetch(cgh, src,
38-
sizeof(float) * count);
39-
});
40-
41-
q.submit([&](handler &cgh) {
42-
cgh.depends_on(init_prefetch);
43-
cgh.single_task<class double_dest>([=]() {
44-
for (int i = 0; i < count; i++)
45-
dest[i] = 2 * src[i];
35+
for (int i = 0; i < Count; i++)
36+
Src[i] = i;
37+
38+
{
39+
// Test host-to-device prefetch via prefetch(handler ...).
40+
event InitPrefetch =
41+
ext::oneapi::experimental::submit_with_event(q, [&](handler &CGH) {
42+
ext::oneapi::experimental::prefetch(CGH, Src,
43+
sizeof(float) * Count);
4644
});
45+
46+
q.submit([&](handler &CGH) {
47+
CGH.depends_on(init_prefetch);
48+
CGH.single_task<class double_dest>([=]() {
49+
for (int i = 0; i < Count; i++)
50+
Dest[i] = 2 * Src[i];
4751
});
48-
q.wait_and_throw();
52+
});
53+
q.wait_and_throw();
4954

50-
for (int i = 0; i < count; i++) {
51-
assert(dest[i] == i * 2);
52-
}
55+
for (int i = 0; i < Count; i++) {
56+
assert(Dest[i] == i * 2);
57+
}
5358

54-
// Test device to host handler::ext_oneapi_prefetch_exp
55-
q.submit([&](handler &cgh) {
56-
cgh.single_task<class quadruple_dest>([=]() {
57-
for (int i = 0; i < count; i++)
58-
dest[i] = 4 * src[i];
59-
});
59+
// Test device-to-host prefetch via prefetch(handler ...).
60+
q.submit([&](handler &CGH) {
61+
CGH.single_task<class quadruple_dest>([=]() {
62+
for (int i = 0; i < Count; i++)
63+
Dest[i] = 4 * Src[i];
6064
});
61-
event init_prefetch_back =
62-
ext::oneapi::experimental::submit_with_event(q, [&](handler &cgh) {
63-
ext::oneapi::experimental::prefetch(
64-
cgh, src, sizeof(float) * count,
65-
ext::oneapi::experimental::prefetch_type::host);
66-
});
67-
q.wait_and_throw();
68-
69-
for (int i = 0; i < count; i++) {
70-
assert(dest[i] == i * 4);
71-
}
65+
});
66+
event InitPrefetchBack =
67+
ext::oneapi::experimental::submit_with_event(q, [&](handler &CGH) {
68+
ext::oneapi::experimental::prefetch(
69+
CGH, Src, sizeof(float) * Count,
70+
ext::oneapi::experimental::prefetch_type::host);
71+
});
72+
q.wait_and_throw();
73+
74+
for (int i = 0; i < Count; i++) {
75+
assert(Dest[i] == i * 4);
7276
}
77+
}
7378

74-
// Test queue::prefetch
75-
{
76-
ext::oneapi::experimental::prefetch(
77-
q, src, sizeof(float) * count,
78-
ext::oneapi::experimental::prefetch_type::device);
79-
q.wait_and_throw();
80-
81-
q.submit([&](handler &cgh) {
82-
cgh.single_task<class triple_dest>([=]() {
83-
for (int i = 0; i < count; i++)
84-
dest[i] = 3 * src[i];
85-
});
79+
{
80+
// Test host-to-device prefetch via prefetch(queue ...).
81+
ext::oneapi::experimental::prefetch(
82+
q, Src, sizeof(float) * Count,
83+
ext::oneapi::experimental::prefetch_type::device);
84+
q.wait_and_throw();
85+
q.submit([&](handler &CGH) {
86+
CGH.single_task<class triple_dest>([=]() {
87+
for (int i = 0; i < Count; i++)
88+
Dest[i] = 3 * Src[i];
8689
});
87-
q.wait_and_throw();
90+
});
91+
q.wait_and_throw();
8892

89-
for (int i = 0; i < count; i++) {
90-
assert(dest[i] == i * 3);
91-
}
93+
for (int i = 0; i < Count; i++) {
94+
assert(Dest[i] == i * 3);
95+
}
9296

93-
q.submit([&](handler &cgh) {
94-
cgh.single_task<class sixtuple_dest>([=]() {
95-
for (int i = 0; i < count; i++)
96-
dest[i] = 6 * src[i];
97-
});
97+
// Test device-to-host prefetch via prefetch(queue ...).
98+
q.submit([&](handler &CGH) {
99+
CGH.single_task<class sixtuple_dest>([=]() {
100+
for (int i = 0; i < Count; i++)
101+
Dest[i] = 6 * Src[i];
98102
});
99-
q.wait_and_throw();
100-
ext::oneapi::experimental::prefetch(
101-
q, src, sizeof(float) * count,
102-
ext::oneapi::experimental::prefetch_type::host);
103-
q.wait_and_throw();
104-
105-
for (int i = 0; i < count; i++) {
106-
assert(dest[i] == i * 6);
107-
}
103+
});
104+
q.wait_and_throw();
105+
ext::oneapi::experimental::prefetch(
106+
q, Src, sizeof(float) * Count,
107+
ext::oneapi::experimental::prefetch_type::host);
108+
q.wait_and_throw();
109+
110+
for (int i = 0; i < Count; i++) {
111+
assert(Dest[i] == i * 6);
108112
}
109-
free(src, q);
110-
free(dest, q);
111113
}
112-
return 0;
114+
free(Src, q);
115+
free(Dest, q);
113116
}

sycl/unittests/Extensions/USMPrefetchExp.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
static constexpr int N = 8;
99
static ur_usm_migration_flags_t urUSMPrefetchDirection = -1;
1010

11-
// TODO: FIGURE OUT WHEN COMMANDBUF GETS CALLED AND IMPLEMENT COMMANDBUF TESTING
12-
1311
ur_result_t redefinedEnqueueUSMPrefetch(void *pParams) {
1412
auto params = *static_cast<ur_enqueue_usm_prefetch_params_t *>(pParams);
1513
urUSMPrefetchDirection = *(params.pflags);
@@ -22,49 +20,48 @@ TEST(USMPrefetchExp, CheckURCall) {
2220
mock::getCallbacks().set_replace_callback("urEnqueueUSMPrefetch",
2321
&redefinedEnqueueUSMPrefetch);
2422
queue q;
25-
int *mem =
23+
int *Mem =
2624
(int *)malloc_shared(sizeof(int) * N, q.get_device(), q.get_context());
2725

2826
// Check handler calls:
2927
q.submit([&](handler &cgh) {
30-
sycl::ext::oneapi::experimental::prefetch(cgh, mem, sizeof(int) * N);
28+
sycl::ext::oneapi::experimental::prefetch(cgh, Mem, sizeof(int) * N);
3129
});
3230
q.wait_and_throw();
3331
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE);
3432

3533
q.submit([&](handler &cgh) {
3634
sycl::ext::oneapi::experimental::prefetch(
37-
cgh, mem, sizeof(int) * N,
35+
cgh, Mem, sizeof(int) * N,
3836
sycl::ext::oneapi::experimental::prefetch_type::device);
3937
});
4038
q.wait_and_throw();
4139
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE);
4240

4341
q.submit([&](handler &cgh) {
4442
sycl::ext::oneapi::experimental::prefetch(
45-
cgh, mem, sizeof(int) * N,
43+
cgh, Mem, sizeof(int) * N,
4644
sycl::ext::oneapi::experimental::prefetch_type::host);
4745
});
4846
q.wait_and_throw();
4947
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST);
5048

5149
// Check queue calls:
52-
sycl::ext::oneapi::experimental::prefetch(q, mem, sizeof(int) * N);
50+
sycl::ext::oneapi::experimental::prefetch(q, Mem, sizeof(int) * N);
5351
q.wait_and_throw();
5452
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE);
5553

5654
sycl::ext::oneapi::experimental::prefetch(
57-
q, mem, sizeof(int) * N,
55+
q, Mem, sizeof(int) * N,
5856
sycl::ext::oneapi::experimental::prefetch_type::device);
5957
q.wait_and_throw();
6058
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_HOST_TO_DEVICE);
6159

6260
sycl::ext::oneapi::experimental::prefetch(
63-
q, mem, sizeof(int) * N,
61+
q, Mem, sizeof(int) * N,
6462
sycl::ext::oneapi::experimental::prefetch_type::host);
6563
q.wait_and_throw();
6664
EXPECT_EQ(urUSMPrefetchDirection, UR_USM_MIGRATION_FLAG_DEVICE_TO_HOST);
6765

68-
// TODO: not sure what else to test for, check event? I don't think there's
69-
// any other parameters to validate....
66+
free(Mem, q);
7067
}

0 commit comments

Comments
 (0)