Skip to content

Commit

Permalink
POTRF: Fix allocator type when TiledArray is not available
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Schuchart <[email protected]>
  • Loading branch information
devreal committed Nov 8, 2024
1 parent dc08fcf commit 91e1d3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions examples/matrixtile.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@

#include <TiledArray/device/allocators.h>
#if defined(TILEDARRAY_HAS_DEVICE)
#define ALLOCATOR TiledArray::device_pinned_allocator<T>
template<typename T>
using default_allocator_t = TiledArray::device_pinned_allocator<T>;

inline void allocator_init(int argc, char **argv) {
// initialize MADNESS so that TA allocators can be created
Expand All @@ -26,15 +27,16 @@ inline void allocator_fini() {
madness::finalize();
}
#else // TILEDARRAY_HAS_DEVICE
#define ALLOCATOR std::allocator<T>
template<typename T>
using default_allocator_t = std::allocator<T>;

inline void allocator_init(int argc, char **argv) { }

inline void allocator_fini() { }

#endif // TILEDARRAY_HAS_DEVICE

template <typename T, class Allocator = ALLOCATOR>
template <typename T, class Allocator = default_allocator_t<T>>
class MatrixTile : public ttg::TTValue<MatrixTile<T, Allocator>> {
public:
using metadata_t = typename std::tuple<std::size_t, std::size_t, std::size_t>;
Expand Down
4 changes: 2 additions & 2 deletions examples/potrf/potrf.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define ENABLE_DEVICE_KERNEL 1
#endif

#if defined(TTG_HAVE_CUDART)
#if defined(TTG_ENABLE_CUDA)
#define ES ttg::ExecutionSpace::CUDA
#include <cusolverDn.h>
#elif defined(TTG_ENABLE_HIP)
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace potrf {
ttg::Edge<Key2, MatrixTile<typename MatrixT::element_type>>& output_result) {
using T = typename MatrixT::element_type;
#if defined(ENABLE_DEVICE_KERNEL)
auto iallocator = std::make_shared<TiledArray::device_pinned_allocator<int>>();
auto iallocator = std::make_shared<default_allocator_t<int>>();
//std::cout << "Creating CUDA POTRF task " << std::endl;
auto f_dev = [=, iallocator = std::move(iallocator)]
(const Key1& key, MatrixTile<T>&& tile_kk,
Expand Down

0 comments on commit 91e1d3d

Please sign in to comment.