Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions legate/core/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ def get_inline_allocation(

physical_region = self.get_inline_mapped_region(context)
# We need a pointer to the physical allocation for this physical region
dim = len(shape)
dim = max(shape.ndim, 1)
# Build the accessor for this physical region
if transform is not None:
# We have a transform so build the accessor special with a
Expand All @@ -367,9 +367,13 @@ def get_inline_allocation(
)
# Now that we've got our accessor we can get a pointer to the memory
rect = ffi.new(f"legion_rect_{dim}d_t *")
for d in range(dim):
rect[0].lo.x[d] = 0
rect[0].hi.x[d] = shape[d] - 1 # inclusive
if shape.ndim == 0:
rect[0].lo.x[0] = 0
rect[0].hi.x[0] = 0 # inclusive
else:
for d in range(dim):
rect[0].lo.x[d] = 0
rect[0].hi.x[d] = shape[d] - 1 # inclusive
subrect = ffi.new(f"legion_rect_{dim}d_t *")
offsets = ffi.new("legion_byte_offset_t[]", dim)
func = getattr(legion, f"legion_accessor_array_{dim}d_raw_rect_ptr")
Expand All @@ -385,7 +389,7 @@ def get_inline_allocation(
ptr = ffi.cast("size_t", base_ptr)
return InlineMappedAllocation(
self,
tuple(shape),
tuple(shape) if shape.ndim > 0 else (1,),
int(ptr), # type: ignore[call-overload]
strides,
)
Expand Down
2 changes: 2 additions & 0 deletions legate/core/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,8 @@ def convert_restrictions(self, restrictions: Restrictions) -> Restrictions:

def get_inverse_transform(self, ndim: int) -> AffineTransform:
parent_ndim = ndim + 1
if ndim == 0:
return AffineTransform(parent_ndim, parent_ndim, False)
result = AffineTransform(parent_ndim, ndim, False)
result.offset[self._dim] = self._index
child_dim = 0
Expand Down
10 changes: 5 additions & 5 deletions src/core/data/store.inl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ AccessorRD<OP, EXCLUSIVE, DIM> Store::reduce_accessor() const
if (is_future_) return future_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, shape<DIM>());

if (!transform_->identity()) {
auto transform = transform_->inverse_transform(DIM);
auto transform = transform_->inverse_transform(dim_);
return region_field_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, shape<DIM>(), transform);
}
return region_field_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, shape<DIM>());
Expand All @@ -346,7 +346,7 @@ AccessorRO<T, DIM> Store::read_accessor(const Legion::Rect<DIM>& bounds) const
if (is_future_) return future_.read_accessor<T, DIM>(bounds);

if (!transform_->identity()) {
auto transform = transform_->inverse_transform(DIM);
auto transform = transform_->inverse_transform(dim_);
return region_field_.read_accessor<T, DIM>(bounds, transform);
}
return region_field_.read_accessor<T, DIM>(bounds);
Expand All @@ -362,7 +362,7 @@ AccessorWO<T, DIM> Store::write_accessor(const Legion::Rect<DIM>& bounds) const
if (is_future_) return future_.write_accessor<T, DIM>(bounds);

if (!transform_->identity()) {
auto transform = transform_->inverse_transform(DIM);
auto transform = transform_->inverse_transform(dim_);
return region_field_.write_accessor<T, DIM>(bounds, transform);
}
return region_field_.write_accessor<T, DIM>(bounds);
Expand All @@ -378,7 +378,7 @@ AccessorRW<T, DIM> Store::read_write_accessor(const Legion::Rect<DIM>& bounds) c
if (is_future_) return future_.read_write_accessor<T, DIM>(bounds);

if (!transform_->identity()) {
auto transform = transform_->inverse_transform(DIM);
auto transform = transform_->inverse_transform(dim_);
return region_field_.read_write_accessor<T, DIM>(bounds, transform);
}
return region_field_.read_write_accessor<T, DIM>(bounds);
Expand All @@ -394,7 +394,7 @@ AccessorRD<OP, EXCLUSIVE, DIM> Store::reduce_accessor(const Legion::Rect<DIM>& b
if (is_future_) return future_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, bounds);

if (!transform_->identity()) {
auto transform = transform_->inverse_transform(DIM);
auto transform = transform_->inverse_transform(dim_);
return region_field_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, bounds, transform);
}
return region_field_.reduce_accessor<OP, EXCLUSIVE, DIM>(redop_id_, bounds);
Expand Down
8 changes: 5 additions & 3 deletions src/core/data/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,11 @@ Legion::DomainAffineTransform TransformStack::inverse_transform(int32_t in_dim)

void TransformStack::print(std::ostream& out) const
{
#ifdef DEBUG_LEGATE
assert(transform_ != nullptr);
#endif
if (identity()) {
out << "(identity)";
return;
}

transform_->print(out);
if (!parent_->identity()) {
out << " >> ";
Expand Down