Skip to content

Commit

Permalink
tiling: Remove OutputStage::Done()
Browse files Browse the repository at this point in the history
Remove OutputStage::Done() and explicitly test the output interval
size from the top level pipeline. We also set the branch complete flag
with a new helper OutputStage::SetBranchComplete() to be explicit.

Rename OutputStage::BranchComplete() to OutputStage::GetBranchComplete()
for consistency. Similarly rename BranchInactive() to GetBranchInactive().

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir committed Aug 5, 2024
1 parent 17cf7b0 commit 5fa5519
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libpisp/backend/tiling/crop_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ void CropStage::PushCropDown(Interval interval, Dir dir)
downstream_->PushCropDown(output_interval_, dir);
}

bool CropStage::BranchInactive() const
bool CropStage::GetBranchInactive() const
{
return !output_interval_.length;
}
2 changes: 1 addition & 1 deletion src/libpisp/backend/tiling/crop_stage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class CropStage : public BasicStage
virtual int PushEndDown(int input_end, Dir dir) override;
virtual void PushEndUp(int output_end, Dir dir) override;
virtual void PushCropDown(Interval interval, Dir dir) override;
bool BranchInactive() const override;
bool GetBranchInactive() const override;

private:
Config config_;
Expand Down
2 changes: 1 addition & 1 deletion src/libpisp/backend/tiling/pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int Pipeline::tileDirection(Dir dir, void *mem, size_t num_items, size_t item_si
throw std::runtime_error("Too many tiles!");
for (auto s : outputs_)
{
if (!s->BranchComplete())
if (!s->GetBranchComplete())
s->PushStartUp(s->GetOutputInterval().End(), dir);
}
for (auto s : inputs_)
Expand Down
16 changes: 8 additions & 8 deletions src/libpisp/backend/tiling/split_stage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void SplitStage::PushStartUp(int output_start, Dir dir)

unsigned int branch_incomplete_count = 0;
for (auto const &d : downstream_)
if (!d->BranchComplete())
if (!d->GetBranchComplete())
branch_incomplete_count++;

if (count_ == branch_incomplete_count)
Expand All @@ -73,7 +73,7 @@ int SplitStage::PushEndDown(int input_end, Dir dir)
input_interval_.SetEnd(0);
for (auto d : downstream_)
{
if (d->BranchComplete())
if (d->GetBranchComplete())
continue;
int branch_end = d->PushEndDown(input_end, dir);
// (It is OK for a branch to make no progress at all - so long as another branch does!)
Expand All @@ -90,7 +90,7 @@ int SplitStage::PushEndDown(int input_end, Dir dir)
}

for (auto d : downstream_)
if (!d->BranchComplete())
if (!d->GetBranchComplete())
d->PushEndDown(input_interval_.End(), dir);

PushEndUp(input_interval_.End(), dir);
Expand All @@ -114,7 +114,7 @@ void SplitStage::PushCropDown(Interval interval, Dir dir)
input_interval_ = interval;
for (auto d : downstream_)
{
if (d->BranchComplete())
if (d->GetBranchComplete())
continue;
PISP_LOG(debug, "(" << name_ << ") Exit with interval " << interval);
d->PushCropDown(interval, dir);
Expand All @@ -125,17 +125,17 @@ void SplitStage::CopyOut([[maybe_unused]] void *dest, [[maybe_unused]] Dir dir)
{
}

bool SplitStage::BranchComplete() const
bool SplitStage::GetBranchComplete() const
{
bool done = true;
for (auto d : downstream_)
done &= d->BranchComplete();
done &= d->GetBranchComplete();
return done;
}

bool SplitStage::BranchInactive() const
bool SplitStage::GetBranchInactive() const
{
if (!upstream_)
return false;
return upstream_->BranchInactive();
return upstream_->GetBranchInactive();
}
4 changes: 2 additions & 2 deletions src/libpisp/backend/tiling/split_stage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class SplitStage : public Stage
virtual void PushEndUp(int output_end, Dir dir);
virtual void PushCropDown(Interval interval, Dir dir);
virtual void CopyOut(void *dest, Dir dir);
virtual bool BranchComplete() const;
virtual bool BranchInactive() const;
virtual bool GetBranchComplete() const;
virtual bool GetBranchInactive() const;

private:
Stage *upstream_;
Expand Down
12 changes: 6 additions & 6 deletions src/libpisp/backend/tiling/stages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ void BasicStage::CopyOut(void *dest, Dir dir)
{
Region *region = (Region *)((uint8_t *)dest + struct_offset_);

PISP_LOG(debug, "(" << name_ << ") complete: " << BranchComplete() << " inactive: " << BranchInactive());
if (BranchComplete() || BranchInactive())
PISP_LOG(debug, "(" << name_ << ") complete: " << GetBranchComplete() << " inactive: " << GetBranchInactive());
if (GetBranchComplete() || GetBranchInactive())
BasicStage::Reset();

region->input[dir] = input_interval_;
Expand All @@ -86,14 +86,14 @@ void BasicStage::CopyOut(void *dest, Dir dir)
}
}

bool BasicStage::BranchComplete() const
bool BasicStage::GetBranchComplete() const
{
return downstream_->BranchComplete();
return downstream_->GetBranchComplete();
}

bool BasicStage::BranchInactive() const
bool BasicStage::GetBranchInactive() const
{
if (!upstream_)
return false;
return upstream_->BranchInactive();
return upstream_->GetBranchInactive();
}
8 changes: 4 additions & 4 deletions src/libpisp/backend/tiling/stages.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Stage
virtual void PushEndUp(int output_end, Dir dir) = 0;
virtual void PushCropDown(Interval interval, Dir dir) = 0;
virtual void CopyOut(void *dest, Dir dir) = 0;
virtual bool BranchComplete() const = 0;
virtual bool BranchInactive() const = 0;
virtual bool GetBranchComplete() const = 0;
virtual bool GetBranchInactive() const = 0;
void MergeRegions(void *dest, void *x_src, void *y_src) const;

protected:
Expand All @@ -57,8 +57,8 @@ class BasicStage : public Stage
virtual void SetDownstream(Stage *downstream);
virtual void Reset();
virtual void CopyOut(void *dest, Dir dir);
virtual bool BranchComplete() const;
virtual bool BranchInactive() const;
virtual bool GetBranchComplete() const;
virtual bool GetBranchInactive() const;

protected:
Stage *upstream_;
Expand Down

0 comments on commit 5fa5519

Please sign in to comment.