4
4
// SPDX-License-Identifier: MIT
5
5
// =============================================================
6
6
7
+ #include < array>
8
+ #include < CL/sycl.hpp>
7
9
// matrix multiply routines
8
10
#include " multiply.hpp"
9
11
10
- #include < CL/sycl.hpp>
11
- #include < array>
12
-
13
12
using namespace cl ::sycl;
14
13
using namespace std ;
15
14
16
- constexpr cl::sycl::access::mode sycl_read = cl::sycl::access::mode::read;
17
- constexpr cl::sycl::access::mode sycl_write = cl::sycl::access::mode::write;
18
- constexpr cl::sycl::access::mode sycl_read_write = cl::sycl::access::mode::read_write;
19
-
20
15
template <typename T>
21
16
class Matrix1 ;
22
17
@@ -39,16 +34,17 @@ void multiply1(int msize, int tidx, int numt, TYPE a[][NUM], TYPE b[][NUM],
39
34
range<2 > matrix_range{NUM, NUM};
40
35
41
36
// Declare 3 buffers and Initialize them
42
- buffer<TYPE, 2 > bufferA ((TYPE*)a, matrix_range);
43
- buffer<TYPE, 2 > bufferB ((TYPE*)b, matrix_range);
44
- buffer<TYPE, 2 > bufferC ((TYPE*)c, matrix_range);
37
+ buffer bufferA ((TYPE*)a, range (matrix_range));
38
+ buffer bufferB ((TYPE*)b, range (matrix_range));
39
+ buffer bufferC ((TYPE*)c, range (matrix_range));
40
+
45
41
// Submit our job to the queue
46
42
q.submit ([&](cl::sycl::handler& h) {
47
43
// Declare 3 accessors to our buffers. The first 2 read and the last
48
- // read_write
49
- auto accessorA = bufferA. get_access <sycl_read>(h );
50
- auto accessorB = bufferB. get_access <sycl_read>(h );
51
- auto accessorC = bufferC. get_access <sycl_read_write>( h);
44
+ // read_write
45
+ accessor accessorA (bufferA, h, read_only );
46
+ accessor accessorB (bufferB, h, read_only );
47
+ accessor accessorC (bufferC, h);
52
48
53
49
// Execute matrix multiply in parallel over our matrix_range
54
50
// ind is an index into this range
@@ -75,18 +71,18 @@ void multiply1_1(int msize, int tidx, int numt, TYPE a[][NUM], TYPE b[][NUM],TYP
75
71
// Declare a 2 dimensional range
76
72
range<2 > matrix_range{NUM, NUM};
77
73
78
- // Declare 3 buffers and Initialize them
79
- buffer<TYPE, 2 > bufferA ((TYPE*)a, matrix_range);
80
- buffer<TYPE, 2 > bufferB ((TYPE*)b, matrix_range);
81
- buffer<TYPE, 2 > bufferC ((TYPE*)c, matrix_range);
74
+ // Declare 3 buffers and Initialize them
75
+ buffer bufferA ((TYPE*)a, range ( matrix_range) );
76
+ buffer bufferB ((TYPE*)b, range ( matrix_range) );
77
+ buffer bufferC ((TYPE*)c, range ( matrix_range) );
82
78
83
79
// Submit our job to the queue
84
80
q.submit ([&](cl::sycl::handler& h) {
85
81
// Declare 3 accessors to our buffers. The first 2 read and the last
86
- // read_write
87
- auto accessorA = bufferA. get_access <sycl_read>(h );
88
- auto accessorB = bufferB. get_access <sycl_read>(h );
89
- auto accessorC = bufferC. get_access <sycl_read_write>( h);
82
+ // read_write
83
+ accessor accessorA (bufferA, h, read_only );
84
+ accessor accessorB (bufferB, h, read_only );
85
+ accessor accessorC (bufferC, h);
90
86
91
87
// Execute matrix multiply in parallel over our matrix_range
92
88
// ind is an index into this range
@@ -117,17 +113,17 @@ void multiply1_2(int msize, int tidx, int numt, TYPE a[][NUM], TYPE b[][NUM],
117
113
range<2 > tile_range{MATRIXTILESIZE, MATRIXTILESIZE};
118
114
119
115
// Declare 3 buffers and Initialize them
120
- buffer<TYPE, 2 > bufferA ((TYPE*)a, matrix_range);
121
- buffer<TYPE, 2 > bufferB ((TYPE*)b, matrix_range);
122
- buffer<TYPE, 2 > bufferC ((TYPE*)c, matrix_range);
116
+ buffer bufferA ((TYPE*)a, range ( matrix_range) );
117
+ buffer bufferB ((TYPE*)b, range ( matrix_range) );
118
+ buffer bufferC ((TYPE*)c, range ( matrix_range) );
123
119
124
120
// Submit our job to the queue
125
121
q.submit ([&](cl::sycl::handler& h) {
126
122
// Declare 3 accessors to our buffers. The first 2 read and the last
127
- // read_write
128
- auto accessorA = bufferA. get_access <sycl_read>(h );
129
- auto accessorB = bufferB. get_access <sycl_read>(h );
130
- auto accessorC = bufferC. get_access <sycl_read_write>( h);
123
+ // read_write
124
+ accessor accessorA (bufferA, h, read_only );
125
+ accessor accessorB (bufferB, h, read_only );
126
+ accessor accessorC (bufferC, h);
131
127
132
128
// Create matrix tiles
133
129
accessor<TYPE, 2 , cl::sycl::access::mode::read_write, cl::sycl::access::target::local> aTile (cl::sycl::range<2 >(MATRIXTILESIZE, MATRIXTILESIZE), h);
0 commit comments