Skip to content

[SYCL Spec][Joint Matrix] Add a new overload for joint_matrix_apply to be able to return result into a different matrix #13153

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

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,15 @@ of the link:sycl_ext_intel_matrix.asciidoc[sycl_ext_intel_matrix]

Besides the `Group` and the `joint_matrix` arguments,
`joint_matrix_apply` takes a C++ Callable object which is invoked once
for each element of the matrix. This callable object must be invocable
with a single parameter of type `T&`. Commonly, applications pass a
lambda expression.
for each element of the matrix. There are two cases: (1) The input and
output matrix are the same, (2) The output matrix is different from
the input matrix.

===== Input and output matrix are the same
In this case, `joint_matrix_apply` takes one `joint_matrix`
argument. The callable object must be invocable with a single
parameter of type `T&`. Commonly, applications pass a lambda
expression.

```c++
namespace sycl::ext::oneapi::experimental::matrix {
Expand All @@ -427,6 +433,36 @@ joint_matrix_apply(sg, C, [=](T &x) {
});
```

===== Input and output matrix are different
In this case, `joint_matrix_apply` takes two `joint_matrix` arguments:
`srcjm` and `destjm` that have the same `use`, type, number of rows,
number of columns, and `layout`. The callable object must be invocable
with two parameters of type `T&`. Commonly, applications pass a lambda
expression.

```c++
namespace sycl::ext::oneapi::experimental::matrix {

template<typename Group, typename T, use Use, size_t Rows, size_t Cols,
layout Layout, typename F>
void joint_matrix_apply(Group g,
joint_matrix<Group, T, Use, Rows, Cols, Layout>& srcjm,
joint_matrix<Group, T, Use, Rows, Cols, Layout>& destjm,
F&& func);

} // namespace sycl::ext::oneapi::experimental::matrix
```

In the following example, every element of the matrix `C` is
multiplied by `alpha`. The result is returned into a different matrix
`D`.

```c++
joint_matrix_apply(sg, C, D, [=](T &x, T &y) {
y = x * alpha;
});
```

==== Prefetch

```c++
Expand Down