Skip to content

Commit 62f41d8

Browse files
authored
[SYCL][Graph] Reduce data sizes of some graph E2E tests (#15814)
- Reduce sizes used in some graph tests that were excessively large - Improves testing performance in performance-limited testing scenarios
1 parent 5f3e6d0 commit 62f41d8

File tree

4 files changed

+37
-23
lines changed

4 files changed

+37
-23
lines changed

sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@
33

44
#include "../graph_common.hpp"
55

6+
#include <cmath>
7+
68
int main() {
79
queue Queue{};
810

911
using T = int;
1012

1113
const T ModValue = 7;
12-
std::vector<T> DataA(Size * Size), DataB(Size * Size), DataC(Size * Size);
14+
15+
const size_t SizeX = std::sqrt(Size);
16+
const size_t SizeY = SizeX;
17+
std::vector<T> DataA(Size), DataB(Size), DataC(Size);
1318

1419
std::iota(DataA.begin(), DataA.end(), 1);
1520
std::iota(DataB.begin(), DataB.end(), 10);
@@ -18,7 +23,7 @@ int main() {
1823
// Create reference data for output
1924
std::vector<T> ReferenceA(DataA), ReferenceB(DataB), ReferenceC(DataC);
2025
for (size_t i = 0; i < Iterations; i++) {
21-
for (size_t j = 0; j < Size * Size; j++) {
26+
for (size_t j = 0; j < Size; j++) {
2227
ReferenceA[j] = ReferenceB[j];
2328
ReferenceA[j] += ModValue;
2429
ReferenceB[j] = ReferenceA[j];
@@ -28,11 +33,11 @@ int main() {
2833
}
2934

3035
// Make the buffers 2D so we can test the rect copy path
31-
buffer BufferA{DataA.data(), range<2>(Size, Size)};
36+
buffer BufferA{DataA.data(), range<2>(SizeX, SizeY)};
3237
BufferA.set_write_back(false);
33-
buffer BufferB{DataB.data(), range<2>(Size, Size)};
38+
buffer BufferB{DataB.data(), range<2>(SizeX, SizeY)};
3439
BufferB.set_write_back(false);
35-
buffer BufferC{DataC.data(), range<2>(Size, Size)};
40+
buffer BufferC{DataC.data(), range<2>(SizeX, SizeY)};
3641
BufferC.set_write_back(false);
3742
{
3843
exp_ext::command_graph Graph{
@@ -52,7 +57,7 @@ int main() {
5257
Graph, Queue,
5358
[&](handler &CGH) {
5459
auto AccA = BufferA.get_access(CGH);
55-
CGH.parallel_for(range<2>(Size, Size),
60+
CGH.parallel_for(range<2>(SizeX, SizeY),
5661
[=](item<2> id) { AccA[id] += ModValue; });
5762
},
5863
NodeA);
@@ -62,7 +67,7 @@ int main() {
6267
Graph, Queue,
6368
[&](handler &CGH) {
6469
auto AccB = BufferB.get_access(CGH);
65-
CGH.parallel_for(range<2>(Size, Size),
70+
CGH.parallel_for(range<2>(SizeX, SizeY),
6671
[=](item<2> id) { AccB[id] += ModValue; });
6772
},
6873
NodeA);
@@ -82,7 +87,7 @@ int main() {
8287
Graph, Queue,
8388
[&](handler &CGH) {
8489
auto AccB = BufferB.get_access(CGH);
85-
CGH.parallel_for(range<2>(Size, Size),
90+
CGH.parallel_for(range<2>(SizeX, SizeY),
8691
[=](item<2> id) { AccB[id] += (ModValue + 1); });
8792
},
8893
NodeC);
@@ -109,9 +114,9 @@ int main() {
109114
host_accessor HostAccB(BufferB);
110115
host_accessor HostAccC(BufferC);
111116

112-
for (size_t i = 0; i < Size; i++) {
113-
for (size_t j = 0; j < Size; j++) {
114-
const size_t index = i * Size + j;
117+
for (size_t i = 0; i < SizeX; i++) {
118+
for (size_t j = 0; j < SizeY; j++) {
119+
const size_t index = i * SizeY + j;
115120
assert(check_value(index, ReferenceA[index], HostAccA[i][j], "HostAccA"));
116121
assert(check_value(index, ReferenceB[index], HostAccB[i][j], "HostAccB"));
117122
assert(check_value(index, ReferenceC[index], HostAccC[i][j], "HostAccC"));

sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,26 @@
33

44
#include "../graph_common.hpp"
55

6+
#include <cmath>
7+
68
int main() {
79
queue Queue{};
810

911
using T = int;
1012

11-
std::vector<T> DataA(Size * Size), DataB(Size * Size);
13+
const size_t SizeX = std::sqrt(Size);
14+
const size_t SizeY = SizeX;
15+
std::vector<T> DataA(Size), DataB(Size);
1216
std::iota(DataA.begin(), DataA.end(), 1);
1317
std::iota(DataB.begin(), DataB.end(), 1000);
1418

1519
std::vector<T> ReferenceA(DataA);
16-
for (size_t i = 0; i < Size * Size; i++) {
20+
for (size_t i = 0; i < Size; i++) {
1721
ReferenceA[i] = DataB[i];
1822
}
1923

2024
// Make the buffers 2D so we can test the rect write path
21-
buffer BufferA{DataA.data(), range<2>(Size, Size)};
25+
buffer BufferA{DataA.data(), range<2>(SizeX, SizeY)};
2226
BufferA.set_write_back(false);
2327

2428
{
@@ -37,9 +41,9 @@ int main() {
3741
}
3842
host_accessor HostAccA(BufferA);
3943

40-
for (size_t i = 0; i < Size; i++) {
41-
for (size_t j = 0; j < Size; j++) {
42-
const size_t index = i * Size + j;
44+
for (size_t i = 0; i < SizeX; i++) {
45+
for (size_t j = 0; j < SizeY; j++) {
46+
const size_t index = i * SizeY + j;
4347
assert(check_value(index, ReferenceA[index], HostAccA[i][j], "HostAccA"));
4448
}
4549
}

sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,27 @@
33

44
#include "../graph_common.hpp"
55

6+
#include <cmath>
7+
68
int main() {
79
queue Queue{};
810

911
using T = int;
1012

11-
std::vector<T> DataA(Size * Size), DataB(Size * Size);
13+
const size_t SizeX = std::sqrt(Size);
14+
const size_t SizeY = SizeX;
15+
std::vector<T> DataA(Size), DataB(Size);
1216
std::iota(DataA.begin(), DataA.end(), 1);
1317
std::iota(DataB.begin(), DataB.end(), 1000);
1418

1519
std::vector<T> ReferenceA(DataA), ReferenceB(DataB);
16-
for (size_t i = 0; i < Size * Size; i++) {
20+
for (size_t i = 0; i < Size; i++) {
1721
ReferenceA[i] = DataA[i];
1822
ReferenceB[i] = DataA[i];
1923
}
2024

2125
// Make the buffers 2D so we can test the rect read path
22-
buffer BufferA{DataA.data(), range<2>(Size, Size)};
26+
buffer BufferA{DataA.data(), range<2>(SizeX, SizeY)};
2327
BufferA.set_write_back(false);
2428

2529
{
@@ -39,7 +43,7 @@ int main() {
3943

4044
host_accessor HostAccA(BufferA);
4145

42-
for (size_t i = 0; i < Size * Size; i++) {
46+
for (size_t i = 0; i < Size; i++) {
4347
assert(check_value(i, ReferenceA[i], DataA[i], "DataA"));
4448
assert(check_value(i, ReferenceB[i], DataB[i], "DataB"));
4549
}

sycl/test-e2e/Graph/Threading/submit.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ int main() {
1919

2020
using T = int;
2121

22-
const unsigned NumThreads = std::thread::hardware_concurrency();
23-
const unsigned SubmitsPerThread = 128;
22+
const unsigned HwThreads = std::thread::hardware_concurrency();
23+
const unsigned NumThreads = std::min(HwThreads, static_cast<unsigned>(4));
24+
const unsigned SubmitsPerThread = 8;
2425
std::vector<T> DataA(Size), DataB(Size), DataC(Size);
2526

2627
std::iota(DataA.begin(), DataA.end(), 1);

0 commit comments

Comments
 (0)