-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
--- | ||
title: Parallel iNet | ||
date: 2023-11-30 | ||
--- | ||
|
||
# Problem | ||
|
||
To implement parallel interaction nets, | ||
we need to let many threads share the same memory. | ||
|
||
To allocate memory of cells of the same size, | ||
we can use an array, and a stack of unused indexes | ||
(let's call this free-stack). | ||
|
||
But the stack will still be the part where multi-thread is not safe | ||
right? If any part of the implementation is not lock-free, the fine | ||
grain parallel advantage of inet might be lost. | ||
|
||
# Solution A | ||
|
||
Maybe i can just use 8 "free-stacks" for 8 threads. | ||
|
||
When a used index is to be freed, i can see which thread is having the | ||
least free indexes, and give the new freed index to it. | ||
|
||
And a "free-stack" can be viewed as a ring, i give back to the front | ||
instead of the end, thus lock-free. | ||
|
||
The query about "the least free indexes" is just heuristic, thus also | ||
lock-free. | ||
|
||
# Datatypes | ||
|
||
I need to allocate the following kinds of datatypes: | ||
|
||
``` | ||
Node { | ||
definition: NodeDefinition | ||
ports: List<Port> | ||
} | ||
Port { | ||
node: Node | ||
halfEdge?: HalfEdge | ||
} | ||
HalfEdge { | ||
otherHalfEdge: HalfEdge | ||
port?: Port | ||
} | ||
``` |