Skip to content

Commit

Permalink
Add missing device functions in the madness backend
Browse files Browse the repository at this point in the history
Missing register_device_memory on span and Buffer::empty

Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Nov 15, 2024
1 parent 0a88756 commit dc4bf9b
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
1 change: 1 addition & 0 deletions ttg/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ if (TARGET MADworld)
set(ttg-mad-headers
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/buffer.h
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/device.h
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/devicefunc.h
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/fwd.h
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/import.h
${CMAKE_CURRENT_SOURCE_DIR}/ttg/madness/ttg.h
Expand Down
4 changes: 4 additions & 0 deletions ttg/ttg/madness/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ struct Buffer : private Allocator {
throw std::runtime_error("not implemented yet");
}

bool empty() const {
return (m_host_data == nullptr);
}

/* TODO: can we do this automatically?
* Pin the memory on all devices we currently track.
* Pinned memory won't be released by PaRSEC and can be used
Expand Down
30 changes: 30 additions & 0 deletions ttg/ttg/madness/devicefunc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef TTG_MAD_DEVICEFUNC_H
#define TTG_MAD_DEVICEFUNC_H

#include "ttg/madness/buffer.h"

namespace ttg_madness {

template<typename T, typename A>
auto buffer_data(const Buffer<T, A>& buffer) {
/* for now return the internal pointer, should be adapted if ever relevant for madness */
return buffer.current_device_ptr();
}

template<typename... Views>
inline bool register_device_memory(std::tuple<Views&...> &views)
{
/* nothing to do here */
return true;
}

template<typename T, std::size_t N>
inline bool register_device_memory(const ttg::span<T, N>& span)
{
/* nothing to do here */
return true;
}

} // namespace ttg_madness

#endif // TTG_MAD_DEVICEFUNC_H
4 changes: 4 additions & 0 deletions ttg/ttg/madness/fwd.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "ttg/fwd.h"
#include "ttg/util/typelist.h"
#include "ttg/util/span.h"

#include <future>

Expand Down Expand Up @@ -71,6 +72,9 @@ namespace ttg_madness {
template<typename... Views>
inline bool register_device_memory(std::tuple<Views&...> &views);

template<typename T, std::size_t N>
inline bool register_device_memory(const ttg::span<T, N>& span);

template<typename... Buffer>
inline void post_device_out(std::tuple<Buffer&...> &b);

Expand Down
1 change: 1 addition & 0 deletions ttg/ttg/madness/ttg.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "ttg/base/tt.h"
#include "ttg/func.h"
#include "ttg/madness/device.h"
#include "ttg/madness/devicefunc.h"
#include "ttg/runtimes.h"
#include "ttg/tt.h"
#include "ttg/util/bug.h"
Expand Down

0 comments on commit dc4bf9b

Please sign in to comment.