Skip to content

Commit

Permalink
feat(hip): 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 0f23ff9 commit 9f7f518
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/hip/fasten.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,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 @@ -227,9 +227,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(hipDeviceSynchronize());
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 @@ -247,8 +247,12 @@ template <size_t PPWI> class IMPL_CLS final : public Bude<PPWI> {
sample.kernelTimes.emplace_back(kernelStart, kernelEnd);
}

auto deviceToHostStart = now();
checkError(
hipMemcpy(sample.energies.data(), results, sample.energies.size() * sizeof(float), hipMemcpyDeviceToHost));
auto deviceToHostEnd = now();

sample.deviceToHost = {deviceToHostStart, deviceToHostEnd};

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

0 comments on commit 9f7f518

Please sign in to comment.