Skip to content

Commit

Permalink
feat(cuda): use new hostToDevice and deviceToHost timers
Browse files Browse the repository at this point in the history
  • Loading branch information
pranav-sivaraman committed Jan 9, 2024
1 parent c99fafb commit 4b47e68
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/cuda/fasten.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {

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

auto contextStart = now();
auto hostToDeviceStart = now();
auto protein = allocate(p.protein);
auto ligand = allocate(p.ligand);
auto transforms_0 = allocate(p.poses[0]);
Expand All @@ -265,9 +265,9 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
auto forcefield = allocate(p.forcefield);
auto results = allocate<float>(sample.energies.size());
checkError(cudaDeviceSynchronize());
auto contextEnd = now();
auto hostToDeviceEnd = now();

sample.contextTime = {contextStart, contextEnd};
sample.hostToDevice = {hostToDeviceStart, hostToDeviceEnd};

size_t global = std::ceil(double(p.nposes()) / PPWI);
global = std::ceil(double(global) / double(wgsize));
Expand All @@ -285,8 +285,13 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
sample.kernelTimes.emplace_back(kernelStart, kernelEnd);
}

auto deviceToHostStart = now();

checkError(
cudaMemcpy(sample.energies.data(), results, sample.energies.size() * sizeof(float), cudaMemcpyDeviceToHost));

auto deviceToHostEnd = now();
sample.deviceToHost = {deviceToHostStart, deviceToHostEnd};

free(protein);
free(ligand);
Expand Down

0 comments on commit 4b47e68

Please sign in to comment.