forked from intel/llvm
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SYCL][Graph] Port sycl/test/graph tests to sycl/test-e2e/Graph
We've treating these tests are runtime tests, so move them to test-e2e which the following changes: * Prefer device USM to shared USM. Device USM support is mandatory while shared is optional * Change `TestQueue` variable name to `Queue` * Comment new tests and remove buffer copy back behaviour. * Fix test name mismatch between recording & explicit. * Rename `Explicit/whole_graph_update_ordering.cpp` -> `Explicit/executable_graph_update_ordering.cpp` * Introduce a record & replay saxypy test. * Add more host, shared, and system USM tests. * Move dotp reductions to their own tests
- Loading branch information
Showing
98 changed files
with
3,100 additions
and
2,171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// Tests constructing a graph using the explicit API to perform a dotp | ||
// operation using USM memory. | ||
|
||
#include "../graph_common.hpp" | ||
|
||
int main() { | ||
queue Queue{gpu_selector_v}; | ||
|
||
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; | ||
|
||
float *Dotp = malloc_device<float>(1, Queue); | ||
|
||
const size_t N = 10; | ||
float *X = malloc_device<float>(N, Queue); | ||
float *Y = malloc_device<float>(N, Queue); | ||
float *Z = malloc_device<float>(N, Queue); | ||
|
||
auto NodeI = Graph.add([&](handler &CGH) { | ||
CGH.parallel_for(N, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
X[i] = 1.0f; | ||
Y[i] = 2.0f; | ||
Z[i] = 3.0f; | ||
}); | ||
}); | ||
|
||
auto NodeA = Graph.add( | ||
[&](handler &CGH) { | ||
CGH.parallel_for(range<1>{N}, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
X[i] = Alpha * X[i] + Beta * Y[i]; | ||
}); | ||
}, | ||
{exp_ext::property::node::depends_on(NodeI)}); | ||
|
||
auto NodeB = Graph.add( | ||
[&](handler &CGH) { | ||
CGH.parallel_for(range<1>{N}, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
Z[i] = Gamma * Z[i] + Beta * Y[i]; | ||
}); | ||
}, | ||
{exp_ext::property::node::depends_on(NodeI)}); | ||
|
||
auto NodeC = Graph.add( | ||
[&](handler &CGH) { | ||
CGH.single_task([=]() { | ||
for (size_t j = 0; j < N; j++) { | ||
Dotp[0] += X[j] * Z[j]; | ||
} | ||
}); | ||
}, | ||
{exp_ext::property::node::depends_on(NodeA, NodeB)}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
|
||
// Using shortcut for executing a graph of commands | ||
Queue.ext_oneapi_graph(ExecGraph).wait(); | ||
|
||
float Output; | ||
Queue.memcpy(&Output, Dotp, sizeof(float)).wait(); | ||
|
||
assert(Output == dotp_reference_result(N)); | ||
|
||
sycl::free(Dotp, Queue); | ||
sycl::free(X, Queue); | ||
sycl::free(Y, Queue); | ||
sycl::free(Z, Queue); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// REQUIRES: level_zero, gpu | ||
// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out | ||
// RUN: %GPU_RUN_PLACEHOLDER %t.out | ||
|
||
// Tests creating a dotp operation through explicit graph creation with | ||
// buffers. | ||
|
||
#include "../graph_common.hpp" | ||
|
||
int main() { | ||
|
||
queue Queue{gpu_selector_v}; | ||
|
||
exp_ext::command_graph Graph{Queue.get_context(), Queue.get_device()}; | ||
|
||
float DotpData = 0.f; | ||
|
||
const size_t N = 10; | ||
std::vector<float> XData(N); | ||
std::vector<float> YData(N); | ||
std::vector<float> ZData(N); | ||
|
||
{ | ||
buffer DotpBuf(&DotpData, range<1>(1)); | ||
DotpBuf.set_write_back(false); | ||
|
||
buffer XBuf(XData); | ||
XBuf.set_write_back(false); | ||
buffer YBuf(YData); | ||
YBuf.set_write_back(false); | ||
buffer ZBuf(ZData); | ||
ZBuf.set_write_back(false); | ||
|
||
auto NodeI = Graph.add([&](handler &CGH) { | ||
auto X = XBuf.get_access(CGH); | ||
auto Y = YBuf.get_access(CGH); | ||
auto Z = ZBuf.get_access(CGH); | ||
CGH.parallel_for(N, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
X[i] = 1.0f; | ||
Y[i] = 2.0f; | ||
Z[i] = 3.0f; | ||
}); | ||
}); | ||
|
||
auto NodeA = Graph.add([&](handler &CGH) { | ||
auto X = XBuf.get_access(CGH); | ||
auto Y = YBuf.get_access(CGH); | ||
CGH.parallel_for(range<1>{N}, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
X[i] = Alpha * X[i] + Beta * Y[i]; | ||
}); | ||
}); | ||
|
||
auto NodeB = Graph.add([&](handler &CGH) { | ||
auto Y = YBuf.get_access(CGH); | ||
auto Z = ZBuf.get_access(CGH); | ||
CGH.parallel_for(range<1>{N}, [=](id<1> it) { | ||
const size_t i = it[0]; | ||
Z[i] = Gamma * Z[i] + Beta * Y[i]; | ||
}); | ||
}); | ||
|
||
auto NodeC = Graph.add([&](handler &CGH) { | ||
auto Dotp = DotpBuf.get_access(CGH); | ||
auto X = XBuf.get_access(CGH); | ||
auto Z = ZBuf.get_access(CGH); | ||
CGH.single_task([=]() { | ||
for (size_t j = 0; j < N; j++) { | ||
Dotp[0] += X[j] * Z[j]; | ||
} | ||
}); | ||
}); | ||
|
||
auto ExecGraph = Graph.finalize(); | ||
|
||
// Using shortcut for executing a graph of commands | ||
Queue.ext_oneapi_graph(ExecGraph).wait(); | ||
|
||
host_accessor HostAcc(DotpBuf); | ||
assert(HostAcc[0] == dotp_reference_result(N)); | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.