From b382cc0a3f434f654c2c2d8310a4b5543bcf4e20 Mon Sep 17 00:00:00 2001 From: Joseph Schuchart Date: Wed, 13 Nov 2024 16:49:15 -0500 Subject: [PATCH] Bring back Buffer::reset(n) needed for serialization Signed-off-by: Joseph Schuchart --- ttg/ttg/parsec/buffer.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ttg/ttg/parsec/buffer.h b/ttg/ttg/parsec/buffer.h index 3e76af2b3..8662901d2 100644 --- a/ttg/ttg/parsec/buffer.h +++ b/ttg/ttg/parsec/buffer.h @@ -401,6 +401,13 @@ struct Buffer { return m_count; } + void reset(std::size_t n, ttg::scope scope = ttg::scope::SyncIn) { + if (nullptr != m_data) { + release_data(); + } + m_data = detail::ttg_parsec_data_types::create_data(n*sizeof(element_type), scope); + } + /** * Resets the scope of the buffer. * If scope is SyncIn then the next time @@ -425,8 +432,8 @@ struct Buffer { void prefer_device(ttg::device::Device dev) { /* only set device if the host has the latest copy as otherwise we might end up with a stale copy */ - if (dev.is_device() && this->parsec_data()->owner_device == 0) { - parsec_advise_data_on_device(this->parsec_data(), detail::ttg_device_to_parsec_device(dev), + if (dev.is_device() && m_data->owner_device == 0) { + parsec_advise_data_on_device(m_data, detail::ttg_device_to_parsec_device(dev), PARSEC_DEV_DATA_ADVICE_PREFERRED_DEVICE); } } @@ -438,7 +445,7 @@ struct Buffer { add_copy(detail::ttg_device_to_parsec_device(dev), ptr); if (is_current) { // mark the data as being current on the new device - parsec_data()->owner_device = detail::ttg_device_to_parsec_device(dev); + m_data->owner_device = detail::ttg_device_to_parsec_device(dev); } }