Skip to content

Commit

Permalink
[SYCL][Graph] Improve threading tests
Browse files Browse the repository at this point in the history
Improves threading tests by removing the dependency of test-e2e to
graph_impl.hpp.
The part of the test requesting graph_impl has been moved to unitest.
Finalize e2e test is kept as still useful for memory leak checking.
  • Loading branch information
mfrancepillois committed Aug 7, 2023
1 parent bc01f0f commit 841e934
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 110 deletions.
62 changes: 0 additions & 62 deletions sycl/test-e2e/Graph/Threading/finalize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,9 @@
// ZE_DEBUG=4 testing capability.

#include "../graph_common.hpp"
#include <detail/graph_impl.hpp>

#include <thread>

bool checkExecGraphSchedule(
std::shared_ptr<sycl::ext::oneapi::experimental::detail::exec_graph_impl>
GraphA,
std::shared_ptr<sycl::ext::oneapi::experimental::detail::exec_graph_impl>
GraphB) {
auto ScheduleA = GraphA->getSchedule();
auto ScheduleB = GraphB->getSchedule();
if (ScheduleA.size() != ScheduleB.size())
return false;

std::vector<
std::shared_ptr<sycl::ext::oneapi::experimental::detail::node_impl>>
VScheduleA{std::begin(ScheduleA), std::end(ScheduleA)};
std::vector<
std::shared_ptr<sycl::ext::oneapi::experimental::detail::node_impl>>
VScheduleB{std::begin(ScheduleB), std::end(ScheduleB)};

for (size_t i = 0; i < VScheduleA.size(); i++) {
if (!VScheduleA[i]->isSimilar(VScheduleB[i]))
return false;
}
return true;
}

int main() {
queue Queue;

Expand Down Expand Up @@ -71,15 +46,9 @@ int main() {

Barrier SyncPoint{NumThreads};

std::map<int, exp_ext::command_graph<exp_ext::graph_state::executable>>
GraphsExecMap;
auto FinalizeGraph = [&](int ThreadNum) {
SyncPoint.wait();
auto GraphExec = Graph.finalize();
GraphsExecMap.insert(
std::map<int,
exp_ext::command_graph<exp_ext::graph_state::executable>>::
value_type(ThreadNum, GraphExec));
Queue.submit([&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExec); });
};

Expand All @@ -101,37 +70,6 @@ int main() {
Queue.copy(PtrC, DataC.data(), Size);
Queue.wait_and_throw();

// Ref computation
queue QueueRef{Queue.get_context(), Queue.get_device()};
exp_ext::command_graph GraphRef{Queue.get_context(), Queue.get_device()};

T *PtrARef = malloc_device<T>(Size, QueueRef);
T *PtrBRef = malloc_device<T>(Size, QueueRef);
T *PtrCRef = malloc_device<T>(Size, QueueRef);

QueueRef.copy(DataA.data(), PtrARef, Size);
QueueRef.copy(DataB.data(), PtrBRef, Size);
QueueRef.copy(DataC.data(), PtrCRef, Size);
QueueRef.wait_and_throw();

GraphRef.begin_recording(QueueRef);
run_kernels_usm(QueueRef, Size, PtrA, PtrB, PtrC);
GraphRef.end_recording();

for (unsigned i = 0; i < NumThreads; ++i) {
auto GraphExecRef = GraphRef.finalize();
QueueRef.submit(
[&](sycl::handler &CGH) { CGH.ext_oneapi_graph(GraphExecRef); });
auto GraphExecImpl =
sycl::detail::getSyclObjImpl(GraphsExecMap.find(i)->second);
auto GraphExecRefImpl = sycl::detail::getSyclObjImpl(GraphExecRef);
assert(checkExecGraphSchedule(GraphExecImpl, GraphExecRefImpl));
}

free(PtrARef, QueueRef);
free(PtrBRef, QueueRef);
free(PtrCRef, QueueRef);

free(PtrA, Queue);
free(PtrB, Queue);
free(PtrC, Queue);
Expand Down
7 changes: 1 addition & 6 deletions sycl/test-e2e/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,8 @@ def execute(self, test, litConfig):
# get GIT root path
stream = os.popen('git rev-parse --show-toplevel')
git_root_path = stream.read()[:-1]

if 'windows' in test.config.available_features:
source_files_path = git_root_path+"\sycl\source"
else:
source_files_path = git_root_path+"/sycl/source"

compilation_cmd_pthread = "%clangxx -I" + source_files_path + " -pthread -fsycl -fsycl-targets=%{sycl_triple} %s"
compilation_cmd_pthread = "%clangxx -pthread -fsycl -fsycl-targets=%{sycl_triple} %s"
substitutions.append(('%{build_pthread_inc}', compilation_cmd_pthread))

def get_extra_env(sycl_devices):
Expand Down
Loading

0 comments on commit 841e934

Please sign in to comment.