Skip to content

Commit

Permalink
Bring back Buffer::reset(n) needed for serialization
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Nov 13, 2024
1 parent 2d70423 commit b382cc0
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ttg/ttg/parsec/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<T*, Allocator>::create_data(n*sizeof(element_type), scope);
}

/**
* Resets the scope of the buffer.
* If scope is SyncIn then the next time
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}

Expand Down

0 comments on commit b382cc0

Please sign in to comment.