Skip to content

RFC: test out new syntax for launch with type deduction #305

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

Open
wants to merge 2 commits into
base: sycl-develop
Choose a base branch
from
Open
Changes from all commits
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
36 changes: 26 additions & 10 deletions examples/cute/tutorial/sgemm_1_sycl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@
#include "cutlass/util/sycl_event_manager.hpp"
#include "cutlass/util/GPU_Clock.hpp"

namespace syclcompat {
template <class F, int Dim>
sycl::event launch(const sycl::nd_range<Dim> &range, sycl::queue q, const F& f) {
return q.parallel_for(detail::transform_nd_range<Dim>(range), [=](sycl::nd_item<Dim>) { f(); });
}
template <class F, int Dim>
sycl::event launch(const sycl::nd_range<Dim> &range, const F& f) {
return launch(range, get_default_queue(), f);
}
// Alternative launch through dim3 objects
template <class F>
sycl::event launch(const dim3 &grid, const dim3 &threads, sycl::queue q, const F& f) {
return launch(sycl::nd_range<3>{grid * threads, threads}, q, f);
}
template <class F>
sycl::event launch(const dim3 &grid, const dim3 &threads, const F& f) {
return launch(grid, threads, get_default_queue(), f);
}
}
Comment on lines +42 to +60
Copy link
Collaborator

@mehdi-goli mehdi-goli Apr 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we put those as PR on sycl::compat repo?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


template <class ProblemShape, class CtaTiler,
class TA, class AStride, class ASmemLayout, class AThreadLayout,
class TB, class BStride, class BSmemLayout, class BThreadLayout,
Expand Down Expand Up @@ -283,16 +303,12 @@ gemm_nt(int m, int n, int k,
auto dimBlock = syclcompat::dim3(size(tC));
auto dimGrid = syclcompat::dim3(size(ceil_div(M, bM)), size(ceil_div(N, bN)));

auto event = syclcompat::launch<
gemm_device<decltype(prob_shape), decltype(cta_tiler),
TA, decltype(dA), decltype(sA), decltype(tA),
TB, decltype(dB), decltype(sB), decltype(tB),
TC, decltype(dC), decltype(sC), decltype(tC),
Alpha, Beta>>(dimGrid, dimBlock, prob_shape, cta_tiler,
A, dA, sA, tA,
B, dB, sB, tB,
C, dC, sC, tC,
alpha, beta);
auto event = syclcompat::launch(dimGrid, dimBlock, [=]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you only want to record this event if you are doing fine-grained profiling?
It is possible you could see a notable performance improvement by only recording events when required: see https://github.com/intel/llvm/pull/18021/files#r2048537558

Copy link

@JackAKirk JackAKirk Apr 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also if an analogue to cudaEventRecord in sycl would be useful to you then you could request creating an extension for e.g. oneapi_event_record that takes a sycl event.

{ gemm_device(prob_shape, cta_tiler,
A, dA, sA, tA,
B, dB, sB, tB,
C, dC, sC, tC,
alpha, beta); });
EventManager::getInstance().addEvent(event);
}

Expand Down