Skip to content

Commit

Permalink
[SYCL][Graph] Changes parentheses for braces in e2e tests for Sycl ob…
Browse files Browse the repository at this point in the history
…jects (#327)

Makes all Sycl objects use braces instead of parentheses when calling constructor.
This is safer for multi-platform software since braces prevent for type narrowing.
  • Loading branch information
mfrancepillois authored Sep 27, 2023
1 parent 304e9de commit d8adfa4
Show file tree
Hide file tree
Showing 21 changed files with 63 additions and 63 deletions.
4 changes: 2 additions & 2 deletions sycl/test-e2e/Graph/Inputs/add_nodes_after_finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ int main() {
Queue.wait_and_throw();

auto NodeA = add_node(Graph, Queue, [&](handler &CGH) {
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrC[id] += PtrA[id] + PtrB[id]; });
});

Expand All @@ -50,7 +50,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeA);
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrOut[id] += PtrC[id] + 1; });
},
NodeA);
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Graph/Inputs/buffer_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccA = BufferA.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccA[LinID] += ModValue;
});
Expand All @@ -63,7 +63,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccB[LinID] += ModValue;
});
Expand All @@ -85,7 +85,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccB[LinID] += ModValue;
});
Expand Down
12 changes: 6 additions & 6 deletions sycl/test-e2e/Graph/Inputs/buffer_copy_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ int main() {
}

// Make the buffers 2D so we can test the rect copy path
buffer BufferA{DataA.data(), range<2>(Size, Size)};
buffer BufferA{DataA.data(), range<2>{Size, Size}};
BufferA.set_write_back(false);
buffer BufferB{DataB.data(), range<2>(Size, Size)};
buffer BufferB{DataB.data(), range<2>{Size, Size}};
BufferB.set_write_back(false);
buffer BufferC{DataC.data(), range<2>(Size, Size)};
buffer BufferC{DataC.data(), range<2>{Size, Size}};
BufferC.set_write_back(false);
{
exp_ext::command_graph Graph{
Expand All @@ -52,7 +52,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccA = BufferA.get_access(CGH);
CGH.parallel_for(range<2>(Size, Size),
CGH.parallel_for(range<2>{Size, Size},
[=](item<2> id) { AccA[id] += ModValue; });
},
NodeA);
Expand All @@ -62,7 +62,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<2>(Size, Size),
CGH.parallel_for(range<2>{Size, Size},
[=](item<2> id) { AccB[id] += ModValue; });
},
NodeA);
Expand All @@ -82,7 +82,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<2>(Size, Size),
CGH.parallel_for(range<2>{Size, Size},
[=](item<2> id) { AccB[id] += ModValue; });
},
NodeC);
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/buffer_copy_host2target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ int main() {
ReferenceA[i] = DataB[i];
}

buffer<T, 1> BufferA(DataA.data(), range<1>(Size));
buffer<T, 1> BufferA{DataA.data(), range<1>{Size}};
BufferA.set_write_back(false);

{
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {
}

// Make the buffers 2D so we can test the rect write path
buffer BufferA{DataA.data(), range<2>(Size, Size)};
buffer BufferA{DataA.data(), range<2>{Size, Size}};
BufferA.set_write_back(false);

{
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Graph/Inputs/buffer_copy_host2target_offset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main() {
ReferenceA[i] = DataB[i - Offset];
}

buffer<T, 1> BufferA(DataA.data(), range<1>(Size + Offset));
buffer<T, 1> BufferA{DataA.data(), range<1>{Size + Offset}};
BufferA.set_write_back(false);

{
Expand All @@ -30,8 +30,8 @@ int main() {
{exp_ext::property::graph::assume_buffer_outlives_graph{}}};

auto NodeA = add_node(Graph, Queue, [&](handler &CGH) {
auto AccA = BufferA.get_access<access::mode::write>(CGH, range<1>(Size),
id<1>(Offset));
auto AccA = BufferA.get_access<access::mode::write>(CGH, range<1>{Size},
id<1>{Offset});
CGH.copy(DataB.data(), AccA);
});

Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Graph/Inputs/buffer_copy_offsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ int main() {
// Copy from A to B
auto NodeA = add_node(Graph, Queue, [&](handler &CGH) {
auto AccA = BufferA.get_access<access::mode::read_write>(
CGH, range<1>(Size - OffsetSrc), id<1>(OffsetSrc));
CGH, range<1>{Size - OffsetSrc}, id<1>{OffsetSrc});
auto AccB = BufferB.get_access<access::mode::read_write>(
CGH, range<1>(Size - OffsetDst), id<1>(OffsetDst));
CGH, range<1>{Size - OffsetDst}, id<1>{OffsetDst});
CGH.copy(AccA, AccB);
});

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/buffer_copy_target2host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {
ReferenceB[i] = DataA[i];
}

buffer<T, 1> BufferA(DataA.data(), range<1>(Size));
buffer<T, 1> BufferA{DataA.data(), range<1>{Size}};
BufferA.set_write_back(false);

{
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ int main() {
}

// Make the buffers 2D so we can test the rect read path
buffer BufferA{DataA.data(), range<2>(Size, Size)};
buffer BufferA{DataA.data(), range<2>{Size, Size}};
BufferA.set_write_back(false);

{
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Graph/Inputs/buffer_copy_target2host_offset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ int main() {
ReferenceB[i] = DataB[i];
}

buffer<T, 1> BufferA(DataA.data(), range<1>(Size));
buffer<T, 1> BufferA{DataA.data(), range<1>{Size}};
BufferA.set_write_back(false);

{
Expand All @@ -32,7 +32,7 @@ int main() {

auto NodeA = add_node(Graph, Queue, [&](handler &CGH) {
auto AccA = BufferA.get_access<access::mode::read>(
CGH, range<1>(Size - Offset), id<1>(Offset));
CGH, range<1>{Size - Offset}, id<1>{Offset});
CGH.copy(AccA, DataB.data());
});

Expand Down
10 changes: 5 additions & 5 deletions sycl/test-e2e/Graph/Inputs/buffer_fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ int main() {
const size_t N = 10;
const float Pattern = 3.14f;
std::vector<float> Data(N);
buffer<float> Buffer(Data);
buffer<float> Buffer{Data};

const uint64_t PatternI64 = 0x3333333355555555;
std::vector<uint64_t> DataI64(N);
buffer<uint64_t> BufferI64(DataI64);
buffer<uint64_t> BufferI64{DataI64};

const uint32_t PatternI32 = 888;
std::vector<uint32_t> DataI32(N);
buffer<uint32_t> BufferI32(DataI32);
buffer<uint32_t> BufferI32{DataI32};

const uint16_t PatternI16 = 777;
std::vector<uint16_t> DataI16(N);
buffer<uint16_t> BufferI16(DataI16);
buffer<uint16_t> BufferI16{DataI16};

const uint8_t PatternI8 = 33;
std::vector<uint8_t> DataI8(N);
buffer<uint8_t> BufferI8(DataI8);
buffer<uint8_t> BufferI8{DataI8};

Buffer.set_write_back(false);
BufferI64.set_write_back(false);
Expand Down
8 changes: 4 additions & 4 deletions sycl/test-e2e/Graph/Inputs/dotp_buffer_reduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ int main() {
std::vector<int> YData(N);
std::vector<int> ZData(N);

buffer DotpBuf(&DotpData, range<1>(1));
buffer DotpBuf(&DotpData, range<1>{1});
DotpBuf.set_write_back(false);

buffer XBuf(XData);
buffer XBuf{XData};
XBuf.set_write_back(false);
buffer YBuf(YData);
buffer YBuf{YData};
YBuf.set_write_back(false);
buffer ZBuf(ZData);
buffer ZBuf{ZData};
ZBuf.set_write_back(false);
{
exp_ext::command_graph Graph{
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Graph/Inputs/event_status_querying.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int main() {
// Read & write A
auto Node1 = add_node(Graph, Queue, [&](handler &CGH) {
auto AccA = BufferA.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccA[LinID] += ModValue;
});
Expand All @@ -87,7 +87,7 @@ int main() {
// Read & write B
auto Node2 = add_node(Graph, Queue, [&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccB[LinID] += ModValue;
});
Expand All @@ -103,7 +103,7 @@ int main() {
// Read and write B
auto Node4 = add_node(Graph, Queue, [&](handler &CGH) {
auto AccB = BufferB.get_access(CGH);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
AccB[LinID] += ModValue;
});
Expand Down
4 changes: 2 additions & 2 deletions sycl/test-e2e/Graph/Inputs/host_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int main() {

// Vector add to output
auto NodeA = add_node(Graph, Queue, [&](handler &CGH) {
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrC[id] += PtrA[id] + PtrB[id]; });
});

Expand All @@ -60,7 +60,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeB);
CGH.parallel_for(range<1>(Size), [=](item<1> id) { PtrC[id] += 1; });
CGH.parallel_for(range<1>{Size}, [=](item<1> id) { PtrC[id] += 1; });
},
NodeB);

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ int main() {

add_node(Graph, Queue, [&](handler &CGH) {
sycl::stream Out(WorkItems * 16, 16, CGH);
CGH.parallel_for(range<1>(WorkItems), [=](item<1> id) {
CGH.parallel_for(range<1>{WorkItems}, [=](item<1> id) {
Out << "Val: " << PtrIn[id.get_linear_id()] << sycl::endl;
});
});
Expand Down
8 changes: 4 additions & 4 deletions sycl/test-e2e/Graph/Inputs/sub_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ int main() {

// Vector add two values
auto NodeSubA = add_node(SubGraph, Queue, [&](handler &CGH) {
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrC[id] = PtrA[id] + PtrB[id]; });
});

Expand All @@ -59,7 +59,7 @@ int main() {
SubGraph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeSubA);
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrC[id] -= ModValue; });
},
NodeSubA);
Expand All @@ -70,7 +70,7 @@ int main() {

// Modify the input values.
auto NodeMainA = add_node(MainGraph, Queue, [&](handler &CGH) {
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
PtrA[id] += ModValue;
PtrB[id] += ModValue;
});
Expand All @@ -89,7 +89,7 @@ int main() {
MainGraph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeMainB);
CGH.parallel_for(range<1>(Size),
CGH.parallel_for(range<1>{Size},
[=](item<1> id) { PtrOut[id] = PtrC[id] + ModValue; });
},
NodeMainB);
Expand Down
6 changes: 3 additions & 3 deletions sycl/test-e2e/Graph/Inputs/usm_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeA);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
PtrA[LinID] += ModValue;
});
Expand All @@ -58,7 +58,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeA);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
PtrB[LinID] += ModValue;
});
Expand All @@ -79,7 +79,7 @@ int main() {
Graph, Queue,
[&](handler &CGH) {
depends_on_helper(CGH, NodeC);
CGH.parallel_for(range<1>(Size), [=](item<1> id) {
CGH.parallel_for(range<1>{Size}, [=](item<1> id) {
auto LinID = id.get_linear_id();
PtrB[LinID] += ModValue;
});
Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/usm_fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {
const size_t N = 10;
int *Arr = malloc_device<int>(N, Queue);

int Pattern = 3.14f;
int Pattern = 314;
auto NodeA =
add_node(Graph, Queue, [&](handler &CGH) { CGH.fill(Arr, Pattern, N); });

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/usm_fill_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main() {
const size_t N = 10;
int *Arr = malloc_host<int>(N, Queue);

int Pattern = 3.14f;
int Pattern = 314;
auto NodeA =
add_node(Graph, Queue, [&](handler &CGH) { CGH.fill(Arr, Pattern, N); });

Expand Down
2 changes: 1 addition & 1 deletion sycl/test-e2e/Graph/Inputs/usm_fill_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ int main() {
const size_t N = 10;
int *Arr = malloc_shared<int>(N, Queue);

int Pattern = 3.14f;
int Pattern = 314;
auto NodeA =
add_node(Graph, Queue, [&](handler &CGH) { CGH.fill(Arr, Pattern, N); });

Expand Down
Loading

0 comments on commit d8adfa4

Please sign in to comment.