Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Simple engine #30

Merged
merged 27 commits into from
Aug 31, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7a3fb78
[simple-engine] cherry pick Minjie's refactoring on interface
hotpxl Aug 23, 2015
6bfcc7d
[simple-engine] fix typo and unmark virtual
hotpxl Aug 23, 2015
e149942
[simple-engine] WIP, need to refactor interface and remove inheritance
hotpxl Aug 23, 2015
cfe80c6
[simple-engine] A not so simple engine that should somehow work
hotpxl Aug 23, 2015
005db3a
[simple-engine] lint
hotpxl Aug 23, 2015
5dfc759
[simple-engine] remove unnecessary files
hotpxl Aug 24, 2015
6b948fd
[simple-engine] that goes worker
hotpxl Aug 24, 2015
c7146a7
[simple-engine] passed some tests
hotpxl Aug 24, 2015
fef28d2
[simple-engine] some document
hotpxl Aug 24, 2015
761e0e1
[simple-engine] implement missing functions
hotpxl Aug 24, 2015
11432db
[simple-engine] fix order
hotpxl Aug 24, 2015
50bf69b
[simple-engine] fix concurrency
hotpxl Aug 24, 2015
1ad9132
[simple-engine] fix a concurrency bug
hotpxl Aug 24, 2015
4662b4e
[simple-engine] lint
hotpxl Aug 24, 2015
d59a125
[simple-engine] Merge branch 'master' into simple-engine
hotpxl Aug 25, 2015
e71055c
[simple-engine] @antinucleon Sorry I had to turn this on to pass Doxygen
hotpxl Aug 25, 2015
be8312d
[simple-engine] heavier test on engine
hotpxl Aug 25, 2015
3a15c13
[simple-engine] add tests to Makefile
hotpxl Aug 25, 2015
e9ab2a2
[simple-engine] use macro for debugging
hotpxl Aug 25, 2015
a3dbb93
[simple-engine] fix engine bug
hotpxl Aug 25, 2015
6b1b9a1
[simple-engine] even more tests
hotpxl Aug 25, 2015
1c57396
[simple-engine] Merge branch 'master' into simple-engine
hotpxl Aug 26, 2015
602a436
[simple-engine] Merge branch 'master' into simple-engine
hotpxl Aug 28, 2015
e85fb0d
[simple-engine] fix concurrency bug
hotpxl Aug 29, 2015
5d4189e
[simple-engine] obj pool raw implementation
hotpxl Aug 29, 2015
bb16dc4
[simple-engine] Merge branch 'master' into simple-engine
hotpxl Aug 29, 2015
8628138
[simple-engine] fix counter
hotpxl Aug 29, 2015
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
Prev Previous commit
[simple-engine] fix counter
  • Loading branch information
hotpxl committed Aug 29, 2015
commit 862813847a4302f4c60b80c5b0b2bd31b89cd7ea
10 changes: 5 additions & 5 deletions src/dag_engine/simple_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,8 @@ void SimpleEngine::OnComplete(SimpleOpr* simple_opr) {
* Mark complete for read variables.
*/
for (auto&& i : simple_opr->use_vars) {
std::lock_guard<std::mutex> lock{i->m};
if (--i->num_pending_reads == 0) {
std::lock_guard<std::mutex> lock{i->m};
if (i->pending_write != nullptr &&
--i->pending_write->trigger->wait == 0) {
task_queue_.Push(i->pending_write->trigger);
Expand All @@ -200,7 +200,7 @@ void SimpleEngine::OnComplete(SimpleOpr* simple_opr) {
* Mark complete for write variables.
*/
for (auto&& i : simple_opr->mutate_vars) {
SimpleVar* to_delete = nullptr;
bool to_delete = false;
{
std::lock_guard<std::mutex> lock{i->m};
assert(i->ready_to_read == false);
Expand All @@ -210,7 +210,7 @@ void SimpleEngine::OnComplete(SimpleOpr* simple_opr) {
if (i->to_delete) {
assert(head->next == nullptr);
delete head;
to_delete = i;
to_delete = true;
} else {
while (true) {
if (head->write == true) {
Expand All @@ -237,8 +237,8 @@ void SimpleEngine::OnComplete(SimpleOpr* simple_opr) {
}
}
}
if (to_delete != nullptr) {
delete to_delete;
if (to_delete) {
delete i;
}
}
{
Expand Down
5 changes: 1 addition & 4 deletions src/dag_engine/simple_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,8 @@ struct SimpleVar final : public Var {
SimpleVar() { LOG(INFO) << __func__ << " " << ++counter; }
~SimpleVar() { LOG(INFO) << __func__ << " " << --counter; }
#endif // DAG_ENGINE_DEBUG
std::atomic<std::size_t> num_pending_reads{0};
/*!
* Protects everything except `num_pending_reads`.
*/
std::mutex m;
std::size_t num_pending_reads{0};
VersionedVarBlock* head{nullptr};
VersionedVarBlock* pending_write{nullptr};
/*!
Expand Down