Skip to content

Commit

Permalink
Merge branch 'master' into powellsr/fix/debug-attach-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
powellsr committed Sep 16, 2024
2 parents 6dc49ce + 8af44bd commit 45009fa
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/TiledArray/conversions/vector_of_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifndef TILEDARRAY_CONVERSIONS_VECTOR_OF_ARRAYS_H_
#define TILEDARRAY_CONVERSIONS_VECTOR_OF_ARRAYS_H_

#include <TiledArray/dist_array.h>

namespace TiledArray {

namespace detail {
Expand Down
3 changes: 2 additions & 1 deletion src/TiledArray/device/device_task_fn.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ struct deviceTaskFn : public TaskInterface {
} else {
// TODO should we use device callback or device events??
// insert device callback
TiledArray::device::launchHostFunc(*stream_, device_callback, task_);
DeviceSafeCall(TiledArray::device::launchHostFunc(
*stream_, device_callback, task_));
// processed sync, clear state
stream_ = {};
}
Expand Down
9 changes: 9 additions & 0 deletions src/TiledArray/device/thrust.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@
#include <cuda_runtime_api.h>
#endif

// rocthrust headers rely on THRUST_DEVICE_SYSTEM being defined, which is only
// defined by the HIP-specific compilers to be usable with host compiler define
// it here explicitly
#ifdef TILEDARRAY_HAS_HIP
#ifndef THRUST_DEVICE_SYSTEM
#define THRUST_DEVICE_SYSTEM THRUST_DEVICE_SYSTEM_HIP
#endif
#endif

#include <thrust/device_vector.h>
#include <thrust/host_vector.h>

Expand Down
17 changes: 10 additions & 7 deletions src/TiledArray/external/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -503,8 +503,7 @@ class Env {
/// \param page_size memory added to the pools supporting `this->um_allocator()`, `this->device_allocator()`, and `this->pinned_allocator()` in chunks of at least
/// this size (bytes) [default=2^25]
/// \param pinned_alloc_limit the maximum total amount of memory (in bytes) that
/// allocator returned by `this->pinned_allocator()` can allocate;
/// this allocator is not used by default [default=0]
/// allocator returned by `this->pinned_allocator()` can allocate [default=2^40]
// clang-format on
static void initialize(World& world = TiledArray::get_default_world(),
const std::uint64_t page_size = (1ul << 25),
Expand Down Expand Up @@ -563,8 +562,9 @@ class Env {
// allocate all currently-free memory for UM pool
auto um_dynamic_pool =
rm.makeAllocator<umpire::strategy::QuickPool, introspect>(
"UMDynamicPool", rm.getAllocator("UM"), mem_total_free.second,
pinned_alloc_limit);
"UMDynamicPool", rm.getAllocator("UM"),
/* first_minimum_pool_allocation_size = */ 0,
/* next_minimum_pool_allocation_size = */ page_size);

// allocate zero memory for device pool
auto dev_size_limited_alloc =
Expand All @@ -573,8 +573,9 @@ class Env {
mem_total_free.first);
auto dev_dynamic_pool =
rm.makeAllocator<umpire::strategy::QuickPool, introspect>(
"DEVICEDynamicPool", dev_size_limited_alloc, 0,
pinned_alloc_limit);
"DEVICEDynamicPool", dev_size_limited_alloc,
/* first_minimum_pool_allocation_size = */ 0,
/* next_minimum_pool_allocation_size = */ page_size);

// allocate pinned_alloc_limit in pinned memory
auto pinned_size_limited_alloc =
Expand All @@ -584,7 +585,9 @@ class Env {
auto pinned_dynamic_pool =
rm.makeAllocator<umpire::strategy::QuickPool, introspect>(
"QuickPool_SizeLimited_PINNED", pinned_size_limited_alloc,
page_size, page_size, /* alignment */ TILEDARRAY_ALIGN_SIZE);
/* first_minimum_pool_allocation_size = */ 0,
/* next_minimum_pool_allocation_size = */ page_size,
/* alignment */ TILEDARRAY_ALIGN_SIZE);

auto env = std::unique_ptr<Env>(new Env(
world, num_visible_devices, compute_devices, num_streams_per_device,
Expand Down
14 changes: 13 additions & 1 deletion src/TiledArray/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,23 @@ class Tile {

// Dimension information accessors -----------------------------------------

/// Size accessors
/// Size accessor

/// \return The number of elements in the tensor
decltype(auto) size() const { return tensor().size(); }

/// Total size accessor

/// \return The number of elements in the tensor, tallied across batches (if
/// any)
decltype(auto) total_size() const {
if constexpr (detail::has_member_function_total_size_anyreturn_v<
tensor_type>) {
return tensor().total_size();
} else
return size();
}

/// Range accessor

/// \return An object describes the upper and lower bounds of the tensor data
Expand Down
2 changes: 2 additions & 0 deletions src/TiledArray/type_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ GENERATE_HAS_MEMBER_TYPE(mapped_type)

GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(size)
GENERATE_HAS_MEMBER_FUNCTION(size)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(total_size)
GENERATE_HAS_MEMBER_FUNCTION(total_size)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(data)
GENERATE_HAS_MEMBER_FUNCTION(data)
GENERATE_HAS_MEMBER_FUNCTION_ANYRETURN(empty)
Expand Down
14 changes: 11 additions & 3 deletions tests/conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,21 @@
*
*/

#include "range_fixture.h"
#include "tiledarray.h"
#include "unit_test_config.h"

#include "TiledArray/conversions/concat.h"
#include "TiledArray/conversions/vector_of_arrays.h"

#include "TiledArray/conversions/concat.h"

#include "TiledArray/conversions/dense_to_sparse.h"
#include "TiledArray/conversions/make_array.h"
#include "TiledArray/conversions/sparse_to_dense.h"
#include "TiledArray/conversions/to_new_tile_type.h"

#include "TiledArray/expressions/tsr_expr.h"

#include "range_fixture.h"

using namespace TiledArray;

struct ConversionsFixture : public TiledRangeFixture {
Expand Down

0 comments on commit 45009fa

Please sign in to comment.