-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced support for timeouts (#4)
- Loading branch information
Showing
14 changed files
with
339 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
class Hypertrie(ConanFile): | ||
name = "hypertrie" | ||
version = "0.5" | ||
version = "0.5.1" | ||
author = "DICE Group <[email protected]>" | ||
description = "A flexible data structure for low-rank, sparse tensors supporting slices by any dimension and einstein summation (einsum)" | ||
homepage = "https://github.com/dice-group/hypertrie" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#ifndef HYPERTRIE_CONTEXT_HPP | ||
#define HYPERTRIE_CONTEXT_HPP | ||
|
||
#include "Dice/einsum/internal/Subscript.hpp" | ||
|
||
namespace einsum::internal { | ||
|
||
using TimePoint = std::chrono::steady_clock::time_point; | ||
|
||
/** | ||
* The context is passed to very operator. It helps to pass information into the operator graph and allows the | ||
* operators to communicate during execution. | ||
* It is also responsible for managing timeouts. | ||
*/ | ||
class Context { | ||
constexpr static const uint max_counter = 500; | ||
public: | ||
/** | ||
* The time after that the processing shall be stopped. | ||
*/ | ||
TimePoint timeout; | ||
|
||
/** | ||
* The time is only checked when counter hits max_counter. | ||
*/ | ||
uint counter = 0; | ||
|
||
/** | ||
* Indicates if the timeout was already reached. | ||
*/ | ||
bool timed_out = false; | ||
|
||
Context(TimePoint const &timeout = TimePoint::max()) : timeout(timeout) {} | ||
|
||
/** | ||
* Checks if the timeout is already reached. This method is intentionally unsynchronized. | ||
* @return if the timeout was reached. If true, the timeout was reached for sure. | ||
* If false, the timeout may already be reached. | ||
* It will be reported monotonically starting approximately at one of the next max_counter calls of this method. | ||
*/ | ||
inline bool hasTimedOut() { | ||
if (this->timed_out) | ||
return true; | ||
else if (this->counter > max_counter) { | ||
this->timed_out = this->timeout <= std::chrono::steady_clock::now(); | ||
if (not this->timed_out) { | ||
this->counter = 0; | ||
} | ||
return this->counter; | ||
} | ||
|
||
++this->counter; | ||
return false; | ||
} | ||
}; | ||
|
||
} | ||
#endif //HYPERTRIE_CONTEXT_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.