Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Table Reset Improvements #335

Open
burgholzer opened this issue Nov 29, 2021 · 0 comments
Open

Compute Table Reset Improvements #335

burgholzer opened this issue Nov 29, 2021 · 0 comments
Labels
DD Anything related to the DD package enhancement New feature or request good first issue Good for newcomers

Comments

@burgholzer
Copy link
Member

burgholzer commented Nov 29, 2021

At the moment, once garbage collection is called (and actually collects something), all compute tables are completely reset, i.e., emptied. While this is fast, it is not necessarily efficient. The compute table most probably contains many entries that are still valid (i.e., all constituents have a non-zero reference count).

The compute table reset should only clear the table from dead entries (i.e., where at least one of the edges has a zero reference count). In this fashion, valid entries are kept in the tables and can be used for further computations.

A prototypical implementation would be

  void clear() {
    if (count > 0) {
      for (auto& entry: table) {
        // If this is an unused entry, there is no need to clear it
        if (entry.leftOperand.p == nullptr && entry.rightOperand.p == nullptr) {
          continue;
        }

        // If all constituents of the entry have a non-zero reference count,
        // the entry is still valid and should not be cleared
        // This assumes that as long as a node is alive, the respective complex
        // numbers are alive as well.
        const auto leftAlive = entry.leftOperand.p == nullptr || entry.leftOperand.p->ref > 0;
        const auto rightAlive = entry.rightOperand.p == nullptr || entry.rightOperand.p->ref > 0;
        const auto resultAlive = entry.result.p == nullptr || entry.result.p->ref > 0;
        if (leftAlive && rightAlive && resultAlive) {
          continue;
        }

        entry = Entry{};
        --count;
      }
    }
  }

It's important to think about how often such a scenario might happen during multiplication and addition assuming the way we currently perform reference counting (e.g., the ref count of operation matrices is never increased).

@burgholzer burgholzer added enhancement New feature or request good first issue Good for newcomers labels Nov 29, 2021
@burgholzer burgholzer transferred this issue from cda-tum/dd_package Jun 15, 2023
@burgholzer burgholzer added the DD Anything related to the DD package label Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DD Anything related to the DD package enhancement New feature or request good first issue Good for newcomers
Projects
Status: Todo
Status: Todo
Development

No branches or pull requests

1 participant