From 699f5d46ceb2c6660826e3a6cea23b46a5d62cc1 Mon Sep 17 00:00:00 2001 From: Xie Yuheng Date: Wed, 16 Oct 2024 04:50:28 +0800 Subject: [PATCH] up --- docs/diary/2023-11-30-parallel-inet.md | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 docs/diary/2023-11-30-parallel-inet.md diff --git a/docs/diary/2023-11-30-parallel-inet.md b/docs/diary/2023-11-30-parallel-inet.md new file mode 100644 index 0000000..d500c98 --- /dev/null +++ b/docs/diary/2023-11-30-parallel-inet.md @@ -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 { + node: Node + halfEdge?: HalfEdge +} + +HalfEdge { + otherHalfEdge: HalfEdge + port?: Port +} +```