Skip to content

Commit

Permalink
feat(sycl): use hostToDevice/deviceToHost timers
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-sivaraman committed Jan 24, 2024
1 parent 9f7f518 commit 0e57e55
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/sycl/fasten.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,9 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
auto device = devices[deviceIdx];

Sample sample(PPWI, wgsize, p.nposes());

auto contextStart = now();
sycl::queue queue(device);

auto hostToDeviceStart = now();
sycl::buffer<Atom> proteins(p.protein.data(), p.protein.size());
sycl::buffer<Atom> ligands(p.ligand.data(), p.ligand.size());
sycl::buffer<FFParams> forcefields(p.forcefield.data(), p.forcefield.size());
Expand All @@ -212,8 +212,8 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
sycl::buffer<float> transforms_5(p.poses[5].data(), p.poses[5].size());
sycl::buffer<float> energies(sample.energies.size());
queue.wait_and_throw();
auto contextEnd = now();
sample.contextTime = {contextStart, contextEnd};
auto hostToDeviceEnd = now();
sample.hostToDevice = {hostToDeviceStart, hostToDeviceEnd};

for (size_t i = 0; i < p.iterations + p.warmupIterations; ++i) {
auto kernelStart = now();
Expand All @@ -229,9 +229,12 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
sample.kernelTimes.emplace_back(kernelStart, kernelEnd);
}

auto deviceToHostStart = now();
queue.submit([&](sycl::handler &h) { h.copy(energies.get_access<R>(h), sample.energies.data()); });
queue.wait_and_throw();
auto deviceToHostEnd = now();
sample.deviceToHost = {deviceToHostStart, deviceToHostEnd};

return sample;
};
};
};

0 comments on commit 0e57e55

Please sign in to comment.