Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/gsd with queue #1543

Merged
merged 39 commits into from
Jun 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d6181bb
refactor: Separate gsd frame writing from analyze.
b-butler Apr 27, 2023
5b5d626
refactor: Make GSDDumpWriter more amenable to subclassing
b-butler Apr 28, 2023
64a3b35
feat: Add C++ GSDDequeWriter
b-butler Apr 27, 2023
9741ae3
feat: Add Deque writer to Python.
b-butler Apr 28, 2023
f4bc01b
test: Test existing Deque writer functionality.
b-butler May 1, 2023
3b5fe05
refactor: Move writeLogQuantities to C++
b-butler May 4, 2023
66d0746
feat: Add logging ability to Deque.
b-butler May 5, 2023
47e0da0
refactor: Remove now redundant IO check in Deque
b-butler May 5, 2023
186d24d
Embed latest gsd implementation.
joaander Apr 28, 2023
bef3e02
Add GSD.flush
joaander Apr 28, 2023
4367b13
Add necessary flush() calls to gsd unit tests.
joaander Apr 28, 2023
3ac9698
Add maximum_write_buffer_size to GSD.
joaander Apr 28, 2023
a8ed1e1
Flush on calls to GSD.write.
joaander Apr 28, 2023
75cb42d
Run pre-commit.
joaander Apr 28, 2023
f44a6c0
Scale index buffer size with write buffer size.
joaander Apr 28, 2023
a3734ec
Install SIGTERM handler.
joaander Apr 28, 2023
9c4cca6
Sync gsd.c with gsd package.
joaander Apr 28, 2023
192f609
Update migration guide.
joaander May 1, 2023
92e5dfc
refactor: Make m_handle available to subclasses (GSDDumpWriter).
b-butler May 8, 2023
1996e53
fix: Deque.__init__ correctly call base class constructor.
b-butler May 8, 2023
e2f5114
fix: Write first frame in GSDDequeWriter
b-butler May 8, 2023
590ef8e
test: Update Deque tests.
b-butler May 8, 2023
54ae6a0
refactor: Rename Deque writer to Burst
b-butler May 8, 2023
021d2c8
doc: Add Burst to documentation.
b-butler May 8, 2023
42a2bd2
Merge branch 'trunk-major' into feat/gsd-with-queue
b-butler May 8, 2023
7cd1bcd
fix: Correctly set m_write_initial_frame with MPI
b-butler May 12, 2023
e1b02e3
test: Fix the burst writer tests.
b-butler May 12, 2023
59eb771
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 12, 2023
377efd5
fix: Non-MPI GSDDequeWriter m_write_initial_frame setting
b-butler May 15, 2023
01cae4c
test: Reduce runtime of Burst writer test
b-butler May 15, 2023
87685c6
doc: Improve Burst writer documentation
b-butler May 19, 2023
9c94979
doc: Add warning about initial Burst write.
b-butler May 19, 2023
f783db6
refactor: Error by default when using empty file for Burst.
b-butler May 30, 2023
8a84515
test: Update Burst tests
b-butler May 31, 2023
2d4fe88
test: Test new write_on_start Burst attribute
b-butler May 31, 2023
2e430c7
refactor: Move writers to end of Operations._schedule
b-butler May 31, 2023
07c8cbd
Revise docs.
joaander Jun 1, 2023
1bc8580
Merge branch 'trunk-major' into feat/gsd-with-queue
b-butler Jun 1, 2023
70363b9
fix: mistake in previous merge
b-butler Jun 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions hoomd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ set(_hoomd_sources Action.cc
ExecutionConfiguration.cc
ForceCompute.cc
ForceConstraint.cc
GSDDequeWriter.cc
GSDDumpWriter.cc
GSDReader.cc
HOOMDMath.cc
Expand Down Expand Up @@ -149,6 +150,7 @@ set(_hoomd_headers
GPUPolymorph.cuh
GPUVector.h
GSD.h
GSDDequeWriter.h
GSDDumpWriter.h
GSDReader.h
HalfStepHook.h
Expand Down
113 changes: 113 additions & 0 deletions hoomd/GSDDequeWriter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// Copyright (c) 2009-2023 The Regents of the University of Michigan.
// Part of HOOMD-blue, released under the BSD 3-Clause License.

#include "GSDDequeWriter.h"
#include "hoomd/GSDDumpWriter.h"

namespace hoomd
{
GSDDequeWriter::GSDDequeWriter(std::shared_ptr<SystemDefinition> sysdef,
std::shared_ptr<Trigger> trigger,
const std::string& fname,
std::shared_ptr<ParticleGroup> group,
pybind11::object logger,
int queue_size,
std::string mode,
bool write_at_init,
uint64_t timestep)
: GSDDumpWriter(sysdef, trigger, fname, group, mode), m_queue_size(queue_size)
{
setLogWriter(logger);
bool file_empty = true;
#ifdef ENABLE_MPI
if (m_sysdef->isDomainDecomposed())
{
if (m_exec_conf->isRoot())
{
file_empty = gsd_get_nframes(&m_handle) == 0;
}
bcast(file_empty, 0, m_exec_conf->getMPICommunicator());
}
else
#endif
{
file_empty = gsd_get_nframes(&m_handle) == 0;
}
if (file_empty)
{
if (!write_at_init)
{
throw std::runtime_error("Must set write_at_start to write to a new file.");
}
else
{
analyze(timestep);
dump();
}
}
}

void GSDDequeWriter::analyze(uint64_t timestep)
{
m_frame_queue.emplace_front();
populateLocalFrame(m_frame_queue.front(), timestep);
m_log_queue.push_front(getLogData());
if (m_queue_size != -1 && m_frame_queue.size() > static_cast<size_t>(m_queue_size))
{
m_frame_queue.pop_back();
m_log_queue.pop_back();
}
}

void GSDDequeWriter::dump()
{
for (auto i {static_cast<long int>(m_frame_queue.size()) - 1}; i >= 0; --i)
{
write(m_frame_queue[i], m_log_queue[i]);
}
m_frame_queue.clear();
m_log_queue.clear();
}

int GSDDequeWriter::getMaxQueueSize() const
{
return m_queue_size;
}

void GSDDequeWriter::setMaxQueueSize(int new_max_size)
{
m_queue_size = new_max_size;
if (m_queue_size == -1)
{
return;
}
while (static_cast<size_t>(m_queue_size) < m_frame_queue.size())
{
m_frame_queue.pop_back();
m_log_queue.pop_back();
}
}

namespace detail
{
void export_GSDDequeWriter(pybind11::module& m)
{
pybind11::class_<GSDDequeWriter, GSDDumpWriter, std::shared_ptr<GSDDequeWriter>>(
m,
"GSDDequeWriter")
.def(pybind11::init<std::shared_ptr<SystemDefinition>,
std::shared_ptr<Trigger>,
std::string,
std::shared_ptr<ParticleGroup>,
pybind11::object,
int,
std::string,
bool,
uint64_t>())
.def_property("max_burst_size",
&GSDDequeWriter::getMaxQueueSize,
&GSDDequeWriter::setMaxQueueSize)
.def("dump", &GSDDequeWriter::dump);
}
} // namespace detail
} // namespace hoomd
49 changes: 49 additions & 0 deletions hoomd/GSDDequeWriter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Copyright (c) 2009-2023 The Regents of the University of Michigan.
// Part of HOOMD-blue, released under the BSD 3-Clause License.

#pragma once

#ifdef __HIPCC__
#error This header cannot be compiled by nvcc
#endif

#include <deque>

#include <pybind11/pybind11.h>

#include "GSDDumpWriter.h"

namespace hoomd
{
class PYBIND11_EXPORT GSDDequeWriter : public GSDDumpWriter
{
public:
GSDDequeWriter(std::shared_ptr<SystemDefinition> sysdef,
std::shared_ptr<Trigger> trigger,
const std::string& fname,
std::shared_ptr<ParticleGroup> group,
pybind11::object logger,
int queue_size,
std::string mode,
bool write_on_init,
uint64_t timestep);
~GSDDequeWriter() = default;

void analyze(uint64_t timestep) override;

void dump();

int getMaxQueueSize() const;
void setMaxQueueSize(int new_max_size);

protected:
int m_queue_size;
std::deque<GSDDumpWriter::GSDFrame> m_frame_queue;
std::deque<pybind11::dict> m_log_queue;
};

namespace detail
{
void export_GSDDequeWriter(pybind11::module& m);
} // namespace detail
} // namespace hoomd