@@ -24,14 +24,14 @@ int main() {
24
24
size_t height = 32 ;
25
25
size_t N = width * height;
26
26
std::vector<float > out (N);
27
- std::vector<float > expected (N / 4 );
28
- std::vector<float > dataIn1 (N / 4 );
29
- std::vector<float > dataIn2 (N / 4 );
30
- for (int i = 0 ; i < width / 2 ; i++) {
31
- for (int j = 0 ; j < height / 2 ; j++) {
32
- expected[j + ((height / 2 ) * i)] = j * 3 ;
33
- dataIn1[j + ((height / 2 ) * i)] = j;
34
- dataIn2[j + ((height / 2 ) * i)] = j * 2 ;
27
+ std::vector<float > expected (N);
28
+ std::vector<float > dataIn1 (N);
29
+ std::vector<float > dataIn2 (N);
30
+ for (int i = 0 ; i < width; i++) {
31
+ for (int j = 0 ; j < height; j++) {
32
+ expected[j + ((height)* i)] = j * 3 ;
33
+ dataIn1[j + ((height)* i)] = j;
34
+ dataIn2[j + ((height)* i)] = j * 2 ;
35
35
}
36
36
}
37
37
@@ -55,29 +55,29 @@ int main() {
55
55
56
56
// Extension: copy over data to device (four subregions/quadrants)
57
57
sycl::range copyExtent1 = {width / 2 , height / 2 , 1 };
58
- sycl::range srcExtent = {width / 2 , height / 2 , 0 };
58
+ sycl::range srcExtent = {width, height, 0 };
59
59
60
60
q.ext_oneapi_copy (dataIn1.data (), {0 , 0 , 0 }, srcExtent,
61
61
imgMem0.get_handle (), {0 , 0 , 0 }, desc, copyExtent1);
62
- q.ext_oneapi_copy (dataIn1.data (), {0 , 0 , 0 }, srcExtent,
62
+ q.ext_oneapi_copy (dataIn1.data (), {width / 2 , 0 , 0 }, srcExtent,
63
63
imgMem0.get_handle (), {width / 2 , 0 , 0 }, desc,
64
64
copyExtent1);
65
- q.ext_oneapi_copy (dataIn1.data (), {0 , 0 , 0 }, srcExtent,
65
+ q.ext_oneapi_copy (dataIn1.data (), {0 , height / 2 , 0 }, srcExtent,
66
66
imgMem0.get_handle (), {0 , height / 2 , 0 }, desc,
67
67
copyExtent1);
68
- q.ext_oneapi_copy (dataIn1.data (), {0 , 0 , 0 }, srcExtent,
68
+ q.ext_oneapi_copy (dataIn1.data (), {width / 2 , height / 2 , 0 }, srcExtent,
69
69
imgMem0.get_handle (), {width / 2 , height / 2 , 0 }, desc,
70
70
copyExtent1);
71
71
72
72
q.ext_oneapi_copy (dataIn2.data (), {0 , 0 , 0 }, srcExtent,
73
73
imgMem1.get_handle (), {0 , 0 , 0 }, desc, copyExtent1);
74
- q.ext_oneapi_copy (dataIn2.data (), {0 , 0 , 0 }, srcExtent,
74
+ q.ext_oneapi_copy (dataIn2.data (), {width / 2 , 0 , 0 }, srcExtent,
75
75
imgMem1.get_handle (), {width / 2 , 0 , 0 }, desc,
76
76
copyExtent1);
77
- q.ext_oneapi_copy (dataIn2.data (), {0 , 0 , 0 }, srcExtent,
77
+ q.ext_oneapi_copy (dataIn2.data (), {0 , height / 2 , 0 }, srcExtent,
78
78
imgMem1.get_handle (), {0 , height / 2 , 0 }, desc,
79
79
copyExtent1);
80
- q.ext_oneapi_copy (dataIn2.data (), {0 , 0 , 0 }, srcExtent,
80
+ q.ext_oneapi_copy (dataIn2.data (), {width / 2 , height / 2 , 0 }, srcExtent,
81
81
imgMem1.get_handle (), {width / 2 , height / 2 , 0 }, desc,
82
82
copyExtent1);
83
83
@@ -104,13 +104,18 @@ int main() {
104
104
});
105
105
q.wait_and_throw ();
106
106
107
- // Extension: copy data from device to host (two sub-regions)
108
- sycl::range copyExtent2 = {width, height / 2 , 1 };
109
- sycl::range destExtent = {width, height, 0 };
107
+ // Extension: copy data from device to host (four subregions/quadrants)
108
+ auto destExtent = srcExtent;
110
109
q.ext_oneapi_copy (imgMem2.get_handle (), {0 , 0 , 0 }, desc, out.data (),
111
- {0 , 0 , 0 }, destExtent, copyExtent2);
110
+ {0 , 0 , 0 }, destExtent, copyExtent1);
111
+ q.ext_oneapi_copy (imgMem2.get_handle (), {width / 2 , 0 , 0 }, desc, out.data (),
112
+ {width / 2 , 0 , 0 }, destExtent, copyExtent1);
112
113
q.ext_oneapi_copy (imgMem2.get_handle (), {0 , height / 2 , 0 }, desc,
113
- out.data (), {0 , height / 2 , 0 }, destExtent, copyExtent2);
114
+ out.data (), {0 , height / 2 , 0 }, destExtent, copyExtent1);
115
+ q.ext_oneapi_copy (imgMem2.get_handle (), {width / 2 , height / 2 , 0 }, desc,
116
+ out.data (), {width / 2 , height / 2 , 0 }, destExtent,
117
+ copyExtent1);
118
+
114
119
q.wait_and_throw ();
115
120
116
121
// Extension: cleanup
@@ -128,7 +133,7 @@ int main() {
128
133
bool validated = true ;
129
134
for (int i = 0 ; i < N; i++) {
130
135
bool mismatch = false ;
131
- if (out[i] != expected[i % (N / 4 ) ]) {
136
+ if (out[i] != expected[i]) {
132
137
mismatch = true ;
133
138
validated = false ;
134
139
}
0 commit comments