Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SYCL] sycl_khr_free_function_commands extension #16770

Open
wants to merge 57 commits into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f9179d0
sycl_khr_free_function_commands KHR extension
dyniols Jan 24, 2025
758274a
Update sycl/include/sycl/ext/khr/free_function_commands.hpp
dyniols Jan 24, 2025
ee6f98b
Update sycl/include/sycl/ext/khr/free_function_commands.hpp
dyniols Jan 24, 2025
a0b8a1c
launch task fix
dyniols Jan 27, 2025
e9f6dfe
formatting fixed
dyniols Jan 27, 2025
3e5f55f
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 27, 2025
63103c1
added copy interfaces
dyniols Jan 27, 2025
dd909f4
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 28, 2025
1fd39b7
added barrier interfaces
dyniols Jan 28, 2025
8e83089
added inline keyword
dyniols Jan 28, 2025
53ebdd4
fixed formatting
dyniols Jan 28, 2025
c2dcb41
fix
dyniols Jan 28, 2025
d892296
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 28, 2025
c9ea35c
test fix
dyniols Jan 29, 2025
521f531
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 29, 2025
e2b6af2
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 30, 2025
b923016
fix
dyniols Jan 30, 2025
da99a1c
removed comment from layout_array
dyniols Jan 30, 2025
72e47f7
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 30, 2025
c54cf1d
workaround for compilation failure of parrallel_for with explicit tem…
dyniols Jan 30, 2025
d94e36c
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Jan 31, 2025
df2dd4e
added e2e launch_task test
dyniols Jan 31, 2025
9a1c57f
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 3, 2025
cfd5f7d
added newline
dyniols Feb 3, 2025
a28a8d3
fixed formatting
dyniols Feb 3, 2025
917116a
added test for launch free function command
dyniols Feb 3, 2025
bd0ca94
header fix
dyniols Feb 3, 2025
efa45f8
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 4, 2025
02e7710
added launch_reduce e2e test
dyniols Feb 4, 2025
3643f07
newline fix
dyniols Feb 4, 2025
b1d7c80
added launch_grouped test
dyniols Feb 4, 2025
0180a3b
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 4, 2025
908698d
fix
dyniols Feb 4, 2025
a10eae0
fix
dyniols Feb 4, 2025
7a782e2
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 5, 2025
0e55297
added launch_grouped_reduce test
dyniols Feb 5, 2025
7c8e6c1
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 5, 2025
4f8db59
added memory_operations test
dyniols Feb 5, 2025
562f3c5
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 6, 2025
c872be6
improvements to e2e tests
dyniols Feb 6, 2025
4d00c8e
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 7, 2025
d122ea7
fixed launch_task test
dyniols Feb 7, 2025
bcd6f52
fixed newline
dyniols Feb 7, 2025
2cd5d1b
fixed tests
dyniols Feb 7, 2025
e3cb987
formatting fixed
dyniols Feb 7, 2025
cbf4f88
added mem_advise and prefetch e2e tests
dyniols Feb 7, 2025
8c20f42
added barrier unitests
dyniols Feb 7, 2025
40f739f
fixed newline
dyniols Feb 7, 2025
4182b9d
fix
dyniols Feb 7, 2025
c3ca9fb
fixed newline
dyniols Feb 7, 2025
4753bd4
Update sycl/unittests/Extensions/FreeFunctionCommands/Barrier.cpp
dyniols Feb 10, 2025
c281145
removed return from prefetch and mem_advise tests
dyniols Feb 10, 2025
d7a685a
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 10, 2025
191363b
Merge branch 'khr_free_function_commands' of https://github.com/DYNIO…
dyniols Feb 10, 2025
45f76cb
fixed kernel types
dyniols Feb 11, 2025
9b0e397
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 11, 2025
358ea12
Merge remote-tracking branch 'intel/sycl' into khr_free_function_comm…
dyniols Feb 12, 2025
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
515 changes: 515 additions & 0 deletions sycl/include/sycl/ext/khr/free_function_commands.hpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions sycl/include/sycl/sycl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
#include <sycl/ext/intel/experimental/task_sequence_properties.hpp>
#include <sycl/ext/intel/experimental/usm_properties.hpp>
#include <sycl/ext/intel/usm_pointers.hpp>
#include <sycl/ext/khr/free_function_commands.hpp>
#include <sycl/ext/oneapi/bfloat16.hpp>
#include <sycl/ext/oneapi/bindless_images.hpp>
#include <sycl/ext/oneapi/device_global/device_global.hpp>
Expand Down
3 changes: 2 additions & 1 deletion sycl/source/feature_test.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ inline namespace _V1 {
#define SYCL_EXT_ONEAPI_GET_KERNEL_INFO 1
#define SYCL_EXT_ONEAPI_WORK_GROUP_MEMORY 1
#define SYCL_EXT_ONEAPI_WORK_GROUP_SCRATCH_MEMORY 1
#define SYCL_EXT_ONEAPI_WORK_GROUP_STATIC 1
#define SYCL_EXT_ONEAPI_WORK_GROUP_STATIC 1
#define SYCL_EXT_ONEAPI_NUM_COMPUTE_UNITS 1
#define SYCL_EXT_ONEAPI_DEVICE_IMAGE_BACKEND_CONTENT 1
#define SYCL_KHR_FREE_FUNCTION_COMMANDS 1
// In progress yet
#define SYCL_EXT_ONEAPI_ATOMIC16 0

Expand Down
19 changes: 19 additions & 0 deletions sycl/test-e2e/FreeFunctionCommands/helpers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include <iostream>
#include <string>

static int Check(int *Data, int Expected, size_t Index,
const std::string &TestName) {
if (Data[Index] == Expected)
return 0;
std::cout << "Failed " << TestName << " at index " << Index << " : "
<< Data[Index] << " != " << Expected << std::endl;
return 1;
}

static int Check(int &Data, int Expected, const std::string &TestName) {
if (Data == Expected)
return 0;
std::cout << "Failed " << TestName << " : " << Data << " != " << Expected
<< std::endl;
return 1;
}
78 changes: 78 additions & 0 deletions sycl/test-e2e/FreeFunctionCommands/launch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// This test checks whether the free function command launch is valid.
#define __DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS

#include <sycl/detail/core.hpp>
#include <sycl/ext/khr/free_function_commands.hpp>
#include <sycl/usm.hpp>

#include <array>

#include "helpers.hpp"

int main() {

int Failed = 0;

sycl::queue Queue;
constexpr size_t Dim = 8;

{
constexpr size_t N = Dim * Dim * Dim;

std::array<int, N> Numbers = {0};
{
sycl::buffer<int, 1> MemBuffer{Numbers.data(), sycl::range<1>{N}};
sycl::khr::submit(Queue, [&](sycl::handler &Handler) {
sycl::accessor MemAcc{MemBuffer, Handler, sycl::write_only};
sycl::khr::launch(Handler, sycl::range<3>(Dim, Dim, Dim),
[=](sycl::item<3> Item) {
size_t Index = Item.get_linear_id();
MemAcc[Index] = 901;
});
});
}
for (size_t i = 0; i < N; ++i)
Failed += Check(Numbers.data(), 901, i, "launch_with_buffer");
}

{
constexpr size_t N = Dim * Dim;
int *Numbers = sycl::malloc_shared<int>(N, Queue);

sycl::event Event =
sycl::khr::submit_tracked(Queue, [&](sycl::handler &Handler) {
sycl::khr::launch(Handler, sycl::range<1>(N),
[=](sycl::item<1> Item) { Numbers[Item] = 2; });
});

sycl::khr::submit(Queue, [&](sycl::handler &Handler) {
Handler.depends_on(Event);
sycl::khr::launch(Handler, sycl::range<3>(Dim / 4, Dim / 2, Dim),
[=](sycl::item<3> Item) {
size_t Index = Item.get_linear_id();
Numbers[Index] = Numbers[Index] + 900;
});
});

Queue.wait();
for (size_t i = 0; i < N; ++i)
Failed += Check(Numbers, 902, i, "launch_with_usm");

sycl::khr::launch(Queue, sycl::range<2>(Dim, Dim), [=](sycl::item<2> Item) {
size_t Index = Item.get_linear_id();
Numbers[Index] = 903;
});

Queue.wait();
for (size_t i = 0; i < N; ++i)
Failed += Check(Numbers, 903, i, "launch_shortcut_with_usm");

sycl::free(Numbers, Queue);
}

return Failed;
}
75 changes: 75 additions & 0 deletions sycl/test-e2e/FreeFunctionCommands/launch_grouped.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// This test checks whether the free function command launch grouped is valid.

#define __DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS

#include <sycl/detail/core.hpp>
#include <sycl/ext/khr/free_function_commands.hpp>
#include <sycl/usm.hpp>

#include "helpers.hpp"

int main() {

int Failed = 0;
sycl::queue Queue;
constexpr size_t N = 1024;

{
std::array<int, N> Numbers = {0};
{
sycl::buffer<int> MemBuffer{Numbers.data(), N};
Queue.submit([&](sycl::handler &Handler) {
sycl::accessor MemAcc{MemBuffer, Handler, sycl::write_only};
sycl::khr::launch_grouped(Handler, sycl::range<3>(8, 8, N / 64),
sycl::range<3>(4, 4, 4),
[=](sycl::nd_item<3> Item) {
size_t Index = Item.get_global_linear_id();
MemAcc[Index] = 301;
});
});
}
for (size_t i = 0; i < N; ++i)
Failed +=
Check(Numbers.data(), 301, i, "launch_grouped_with_sycl_buffer");
}

{
int *Numbers = sycl::malloc_shared<int>(N, Queue);

sycl::event Event =
sycl::khr::submit_tracked(Queue, [&](sycl::handler &Handler) {
sycl::khr::launch_grouped(Handler, sycl::range<3>(4, 4, N / 16),
sycl::range<3>(4, 4, 4),
[=](sycl::nd_item<3> Item) {
Numbers[Item.get_global_linear_id()] = 2;
});
});

sycl::khr::submit(Queue, [&](sycl::handler &Handler) {
Handler.depends_on(Event);
sycl::khr::launch_grouped(Handler, sycl::range<1>(N), sycl::range<1>(8),
[=](sycl::nd_item<1> Item) {
size_t Index = Item.get_global_linear_id();
Numbers[Index] = Numbers[Index] + 300;
});
});
Queue.wait();
for (size_t i = 0; i < N; ++i)
Failed += Check(Numbers, 302, i, "launch_grouped_with_usm");

sycl::khr::launch_grouped(Queue, sycl::range<2>(8, N / 8),
sycl::range<2>(8, 8), [=](sycl::nd_item<2> Item) {
Numbers[Item.get_global_linear_id()] = 303;
});
Queue.wait();
for (size_t i = 0; i < N; ++i)
Failed += Check(Numbers, 303, i, "launch_grouped_shortcut_with_usm");
sycl::free(Numbers, Queue);
}

return Failed;
}
81 changes: 81 additions & 0 deletions sycl/test-e2e/FreeFunctionCommands/launch_grouped_reduce.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// This test checks whether the free function command launch grouped reduce is
// valid.

#define __DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS

#include <sycl/detail/core.hpp>
#include <sycl/ext/khr/free_function_commands.hpp>
#include <sycl/reduction.hpp>
#include <sycl/usm.hpp>

#include "helpers.hpp"

int main() {

int Failed = 0;
sycl::queue Queue;

{
int Result = 0;
constexpr size_t Dim = 8;
constexpr size_t N = Dim * Dim * Dim - 1;
constexpr int ExpectedResult = N * (N + 1) / 2;
{
sycl::buffer<int> sumBuf{&Result, 1};
Queue.submit([&](sycl::handler &Handler) {
sycl::khr::launch_grouped_reduce(
Handler, sycl::range<3>(Dim, Dim, Dim), sycl::range<3>(8, 8, 8),
[=](sycl::nd_item<3> Item, auto &Sum) {
Sum += Item.get_local_linear_id();
},
sycl::reduction(sumBuf, Handler, sycl::plus<>()));
});
}
Failed +=
Check(Result, ExpectedResult, "launch_grouped_reduce_with_buffer");
}

{
int *Result = sycl::malloc_shared<int>(1, Queue);
Result[0] = 0;
constexpr size_t N = 1024;
constexpr int ExpectedResult = ((N - 1) * N) / 2;

sycl::event Event =
sycl::khr::submit_tracked(Queue, [&](sycl::handler &Handler) {
sycl::khr::launch_grouped_reduce(
Handler, sycl::range<3>(8, 8, N / 64), sycl::range<3>(8, 8, 8),
[=](sycl::nd_item<3> Item, auto &Sum) { Sum += 1; },
sycl::reduction(Result, sycl::plus<>()));
});

sycl::khr::submit(Queue, [&](sycl::handler &Handler) {
Handler.depends_on(Event);
sycl::khr::launch_grouped_reduce(
Handler, sycl::range<2>(16, N / 16), sycl::range<2>(8, 8),
[=](sycl::nd_item<2> Item, auto &Sum) { Sum += 1; },
sycl::reduction(Result, sycl::plus<>()));
});
Queue.wait();
Failed += Check(Result[0], N * 2, "launch_grouped_reduce_with_usm");

Result[0] = 0;
sycl::khr::launch_grouped_reduce(
Queue, sycl::range<1>(N), sycl::range<1>(8),
[=](sycl::nd_item<1> Item, auto &Sum) {
Sum += Item.get_global_linear_id();
},
sycl::reduction(Result, sycl::plus<>()));

Queue.wait();
Failed += Check(Result[0], ExpectedResult,
"launch_grouped_reduce_shortcut_with_usm");
sycl::free(Result, Queue);
}

return Failed;
}
76 changes: 76 additions & 0 deletions sycl/test-e2e/FreeFunctionCommands/launch_reduce.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// REQUIRES: aspect-usm_shared_allocations
// RUN: %{build} -o %t.out
// RUN: %{run} %t.out

// This test checks whether the free function command launch reduce is valid.
#define __DPCPP_ENABLE_UNFINISHED_KHR_EXTENSIONS

#include <sycl/detail/core.hpp>
#include <sycl/ext/khr/free_function_commands.hpp>
#include <sycl/reduction.hpp>
#include <sycl/usm.hpp>

#include "helpers.hpp"

int main() {

int Failed = 0;
sycl::queue Queue;

{
int Result = 0;
constexpr size_t Dim = 8;
constexpr size_t N = Dim * Dim * Dim - 1;
constexpr int ExpectedResult = N * (N + 1) / 2;
{
sycl::buffer<int> sumBuf{&Result, 1};
Queue.submit([&](sycl::handler &Handler) {
sycl::khr::launch_reduce(
Handler, sycl::range<3>(Dim, Dim, Dim),
[=](sycl::item<3> Item, auto &Sum) { Sum += Item.get_linear_id(); },
sycl::reduction(sumBuf, Handler, sycl::plus<>()));
});
}
Failed += Check(Result, ExpectedResult, "launch_reduce_with_buffer");
}

{
int *Result = sycl::malloc_shared<int>(1, Queue);
Result[0] = 0;
constexpr size_t N = 1024;
constexpr int ExpectedResult = ((N - 1) * N) / 2;

sycl::event Event =
sycl::khr::submit_tracked(Queue, [&](sycl::handler &Handler) {
sycl::khr::launch_reduce(
Handler, sycl::range<1>(N),
[=](sycl::id<1> Id, auto &Sum) {
int NegativeId = -(int)Id;
Sum += NegativeId;
},
sycl::reduction(Result, sycl::plus<>()));
});

Queue.submit([&](sycl::handler &Handler) {
Handler.depends_on(Event);
sycl::khr::launch_reduce(
Handler, sycl::range<1>(N),
[=](sycl::item<1> Item, auto &Sum) { Sum += Item.get_linear_id(); },
sycl::reduction(Result, sycl::plus<>()));
});

Queue.wait();
Failed += Check(Result[0], 0, "launch_reduce_with_usm");

sycl::khr::launch_reduce(
Queue, sycl::range<1>(N), [=](sycl::id<1> Id, auto &Sum) { Sum += Id; },
sycl::reduction(Result, sycl::plus<>()));

Queue.wait();
Failed +=
Check(Result[0], ExpectedResult, "launch_reduce_shortcut_with_usm");
sycl::free(Result, Queue);
}

return Failed;
}
Loading