@@ -25,90 +25,90 @@ namespace syclexp = sycl::ext::oneapi::experimental;
2525constexpr int SIZE = 16 ;
2626
2727SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
28- void scratchKernel(float *src , float *dst ) {
29- size_t lid = syclext::this_work_item::get_nd_item<1 >().get_local_linear_id ();
30- float *localMem =
28+ void scratchKernel(float *Src , float *Dst ) {
29+ size_t Lid = syclext::this_work_item::get_nd_item<1 >().get_local_linear_id ();
30+ float *LocalMem =
3131 reinterpret_cast <float *>(syclexp::get_work_group_scratch_memory ());
32- localMem[lid ] = 2 * src[lid ];
33- dst[lid ] = localMem[lid ];
32+ LocalMem[Lid ] = 2 * Src[Lid ];
33+ Dst[Lid ] = LocalMem[Lid ];
3434}
3535
3636SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
37- void staticKernel(float *src , float *dst ) {
38- sycl::nd_item<1 > item = syclext::this_work_item::get_nd_item<1 >();
39- size_t lid = item .get_local_linear_id ();
40- syclexp::work_group_static<float [SIZE]> localMem ;
41- localMem[lid ] = src[lid ] * src[lid ];
42- sycl::group_barrier (item .get_group ());
43- if (item .get_group ().leader ()) { // Check that memory is indeed shared between
37+ void staticKernel(float *Src , float *Dst ) {
38+ sycl::nd_item<1 > Item = syclext::this_work_item::get_nd_item<1 >();
39+ size_t Lid = Item .get_local_linear_id ();
40+ syclexp::work_group_static<float [SIZE]> LocalMem ;
41+ LocalMem[Lid ] = Src[Lid ] * Src[Lid ];
42+ sycl::group_barrier (Item .get_group ());
43+ if (Item .get_group ().leader ()) { // Check that memory is indeed shared between
4444 // the work group.
4545 for (int i = 0 ; i < SIZE; ++i)
46- assert (localMem [i] == src [i] * src [i]);
46+ assert (LocalMem [i] == Src [i] * Src [i]);
4747 }
48- dst[lid ] = localMem[lid ];
48+ Dst[Lid ] = LocalMem[Lid ];
4949}
5050
5151SYCL_EXT_ONEAPI_FUNCTION_PROPERTY ((syclexp::nd_range_kernel<1 >))
52- void scratchStaticKernel(float *src , float *dst ) {
53- size_t lid = syclext::this_work_item::get_nd_item<1 >().get_local_linear_id ();
54- float *scratchMem =
52+ void scratchStaticKernel(float *Src , float *Dst ) {
53+ size_t Lid = syclext::this_work_item::get_nd_item<1 >().get_local_linear_id ();
54+ float *ScratchMem =
5555 reinterpret_cast <float *>(syclexp::get_work_group_scratch_memory ());
56- syclexp::work_group_static<float [SIZE]> staticMem ;
57- scratchMem[lid ] = src[lid ];
58- staticMem[lid ] = src[lid ];
59- dst[lid ] = scratchMem[lid ] + staticMem[lid ];
56+ syclexp::work_group_static<float [SIZE]> StaticMem ;
57+ ScratchMem[Lid ] = Src[Lid ];
58+ StaticMem[Lid ] = Src[Lid ];
59+ Dst[Lid ] = ScratchMem[Lid ] + StaticMem[Lid ];
6060}
6161
6262int main () {
63- sycl::queue q ;
64- float *src = sycl::malloc_shared<float >(SIZE, q );
65- float *dst = sycl::malloc_shared<float >(SIZE, q );
63+ sycl::queue Q ;
64+ float *Src = sycl::malloc_shared<float >(SIZE, Q );
65+ float *Dst = sycl::malloc_shared<float >(SIZE, Q );
6666
6767 for (int i = 0 ; i < SIZE; i++) {
68- src [i] = i;
68+ Src [i] = i;
6969 }
7070
71- auto scratchBndl =
71+ auto ScratchBndl =
7272 syclexp::get_kernel_bundle<scratchKernel, sycl::bundle_state::executable>(
73- q .get_context ());
74- auto staticBndl =
73+ Q .get_context ());
74+ auto StaticBndl =
7575 syclexp::get_kernel_bundle<staticKernel, sycl::bundle_state::executable>(
76- q .get_context ());
77- auto scratchStaticBndl = syclexp::get_kernel_bundle<
78- scratchStaticKernel, sycl::bundle_state::executable>(q .get_context ());
79-
80- sycl::kernel scratchKrn =
81- scratchBndl .template ext_oneapi_get_kernel <scratchKernel>();
82- sycl::kernel staticKrn =
83- staticBndl .template ext_oneapi_get_kernel <staticKernel>();
84- sycl::kernel scratchStaticKrn =
85- scratchStaticBndl .template ext_oneapi_get_kernel <scratchStaticKernel>();
86- syclexp::launch_config scratchKernelcfg {
76+ Q .get_context ());
77+ auto ScratchStaticBndl = syclexp::get_kernel_bundle<
78+ scratchStaticKernel, sycl::bundle_state::executable>(Q .get_context ());
79+
80+ sycl::kernel ScratchKrn =
81+ ScratchBndl .template ext_oneapi_get_kernel <scratchKernel>();
82+ sycl::kernel StaticKrn =
83+ StaticBndl .template ext_oneapi_get_kernel <staticKernel>();
84+ sycl::kernel ScratchStaticKrn =
85+ ScratchStaticBndl .template ext_oneapi_get_kernel <scratchStaticKernel>();
86+ syclexp::launch_config ScratchKernelcfg {
8787 ::sycl::nd_range<1 >(::sycl::range<1 >(SIZE), ::sycl::range<1 >(SIZE)),
8888 syclexp::properties{
8989 syclexp::work_group_scratch_size (SIZE * sizeof (float ))}};
90- syclexp::launch_config staticKernelcfg {
90+ syclexp::launch_config StaticKernelcfg {
9191 ::sycl::nd_range<1 >(::sycl::range<1 >(SIZE), ::sycl::range<1 >(SIZE))};
9292
93- syclexp::nd_launch (q, scratchKernelcfg, scratchKrn, src, dst );
94- q .wait ();
93+ syclexp::nd_launch (Q, ScratchKernelcfg, ScratchKrn, Src, Dst );
94+ Q .wait ();
9595 for (int i = 0 ; i < SIZE; i++) {
96- assert (dst [i] == 2 * src [i]);
96+ assert (Dst [i] == 2 * Src [i]);
9797 }
9898
99- syclexp::nd_launch (q, staticKernelcfg, staticKrn, src, dst );
100- q .wait ();
99+ syclexp::nd_launch (Q, StaticKernelcfg, StaticKrn, Src, Dst );
100+ Q .wait ();
101101 for (int i = 0 ; i < SIZE; i++) {
102- assert (dst [i] == src [i] * src [i]);
102+ assert (Dst [i] == Src [i] * Src [i]);
103103 }
104104
105- syclexp::nd_launch (q, scratchKernelcfg, scratchStaticKrn, src, dst );
106- q .wait ();
105+ syclexp::nd_launch (Q, ScratchKernelcfg, ScratchStaticKrn, Src, Dst );
106+ Q .wait ();
107107 for (int i = 0 ; i < SIZE; i++) {
108- assert (dst [i] == 2 * src [i]);
108+ assert (Dst [i] == 2 * Src [i]);
109109 }
110110
111- sycl::free (src, q );
112- sycl::free (dst, q );
111+ sycl::free (Src, Q );
112+ sycl::free (Dst, Q );
113113 return 0 ;
114114}
0 commit comments