Skip to content

Commit

Permalink
Fix ttvalue and buffer in parsec
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Dec 20, 2023
1 parent 220c038 commit e9b3233
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
2 changes: 0 additions & 2 deletions ttg/ttg/parsec/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ struct Buffer : public detail::ttg_parsec_data_wrapper_t
/* Reallocate the buffer with count elements */
void reset(std::size_t n) {
/* TODO: can we resize if count is smaller than m_count? */
/* drop the current data and reallocate */
reset();

if (m_owned) {
deallocate();
Expand Down
4 changes: 2 additions & 2 deletions ttg/ttg/parsec/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ namespace ttg_parsec {
struct TTValue;

template<typename T, typename... Args>
Ptr<T> make_ptr(Args&&... args);
inline Ptr<T> make_ptr(Args&&... args);

template<typename T>
Ptr<std::decay_t<T>> get_ptr(T&& obj);
inline Ptr<std::decay_t<T>> get_ptr(T&& obj);

template<typename... Views>
inline bool register_device_memory(std::tuple<Views&...> &views);
Expand Down
6 changes: 3 additions & 3 deletions ttg/ttg/parsec/ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace ttg_parsec {

// fwd decl
template<typename T>
Ptr<std::decay_t<T>> get_ptr(T&& obj);
inline Ptr<std::decay_t<T>> get_ptr(T&& obj);

template<typename T>
struct Ptr {
Expand Down Expand Up @@ -249,7 +249,7 @@ namespace ttg_parsec {
#endif // 0

template<typename T>
inline auto get_ptr(T&& obj) {
inline Ptr<std::decay_t<T>> get_ptr(T&& obj) {
using ptr_type = Ptr<std::decay_t<T>>;
if (nullptr != detail::parsec_ttg_caller) {
for (int i = 0; i < detail::parsec_ttg_caller->data_count; ++i) {
Expand All @@ -274,7 +274,7 @@ namespace ttg_parsec {

namespace detail {
template<typename T>
detail::ttg_data_copy_t* get_copy(ttg_parsec::Ptr<T>& p) {
inline detail::ttg_data_copy_t* get_copy(ttg_parsec::Ptr<T>& p) {
return p.get_copy();
}
} // namespace detail
Expand Down
7 changes: 7 additions & 0 deletions ttg/ttg/parsec/ttg_data_copy.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,15 @@ namespace ttg_parsec {
* definition of ttg_parsec_data_wrapper_t members that depend on ttg_data_copy_t
*/

inline
void ttg_parsec_data_wrapper_t::remove_from_owner() {
if (nullptr != m_ttg_copy) {
m_ttg_copy->remove_device_data(this);
m_ttg_copy = nullptr;
}
}

inline
void ttg_parsec_data_wrapper_t::reset_parsec_data(void *ptr, size_t size) {
if (ptr == m_data.get()) return;

Expand All @@ -536,6 +538,7 @@ namespace ttg_parsec {
}
}

inline
ttg_parsec_data_wrapper_t::ttg_parsec_data_wrapper_t()
: m_data(nullptr, delete_null_parsec_data)
, m_ttg_copy(detail::ttg_data_copy_container())
Expand All @@ -544,6 +547,8 @@ namespace ttg_parsec {
m_ttg_copy->add_device_data(this);
}
}

inline
ttg_parsec_data_wrapper_t::ttg_parsec_data_wrapper_t(ttg_parsec_data_wrapper_t&& other)
: m_data(std::move(other.m_data))
, m_ttg_copy(detail::ttg_data_copy_container())
Expand All @@ -562,6 +567,7 @@ namespace ttg_parsec {
//}
}

inline
ttg_parsec_data_wrapper_t& ttg_parsec_data_wrapper_t::operator=(ttg_parsec_data_wrapper_t&& other) {
m_data = std::move(other.m_data);
/* check whether the owning ttg_data_copy has already moved us */
Expand All @@ -578,6 +584,7 @@ namespace ttg_parsec {
}


inline
ttg_parsec_data_wrapper_t::~ttg_parsec_data_wrapper_t() {
if (nullptr != m_ttg_copy) {
m_ttg_copy->remove_device_data(this);
Expand Down
4 changes: 2 additions & 2 deletions ttg/ttg/ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ template<typename T>
using Ptr = TTG_IMPL_NS::Ptr<T>;

template<typename T, typename... Args>
Ptr<T> make_ptr(Args&&... args) {
inline Ptr<T> make_ptr(Args&&... args) {
return TTG_IMPL_NS::make_ptr(std::forward<Args>(args)...);
}

template<typename T>
Ptr<std::decay_t<T>> get_ptr(T&& obj) {
inline Ptr<std::decay_t<T>> get_ptr(T&& obj) {
return TTG_IMPL_NS::get_ptr(std::forward<T>(obj));
}

Expand Down

0 comments on commit e9b3233

Please sign in to comment.