diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2022-02-24 14:24:33 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2022-02-24 14:24:33 +0900 |
| commit | dba967f211b337a18c8edfecd79457f8f76d771b (patch) | |
| tree | f43f002b20b142bd983325b60f43862cc20375df | |
| parent | cba576f73e8ee7e27c95ae6f7d84882df54b7d37 (diff) | |
| parent | 85872e2da9e2616670f1920894d25d577c8b55f7 (diff) | |
| download | inpla-dba967f211b337a18c8edfecd79457f8f76d771b.tar.gz inpla-dba967f211b337a18c8edfecd79457f8f76d771b.zip | |
Merge branch 'develop'
Diffstat (limited to '')
| -rw-r--r-- | Changelog.md | 20 | ||||
| -rw-r--r-- | README.md | 2 | ||||
| -rw-r--r-- | src/inpla.y | 29 |
3 files changed, 40 insertions, 11 deletions
diff --git a/Changelog.md b/Changelog.md index cb48545..07c156c 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,11 +1,21 @@ # Change log +### v0.7.3-1 (released on 24 February 2022) + +#### Bug Fix: +* **TRO Bytecode Optimisation for empty connection sequences**: The optimisation for empty connection sequence had caused Segmentation fault, and it was fixed. +* **Bytecode instruction execution**: The following error were fixed. + * Execution of an instruction of TRO for general agents: Indirection was not correctly applied. + * Execution of an instruction for substitutions of global names: `pc++` was applied to a macro argument, and it caused some increments. + + + ### v0.7.3 (released on 20 February 2022) -#### Polished: -* **Bytecode optimisation inspired by Tail Recursive Optimisation**: As a result, this optimisation brings about faster computation up to about twice in comparison with no reuse-annotated computation. +#### New Features: +* **Bytecode optimisation inspired by Tail Recursive Optimisation**: As a result this optimisation brings about faster computation up to about twice in comparison with no reuse-annotated computation. - * When an interaction rule has a connection whose both sides agents have the same IDs to the active pair, computation of the connection can be realised by applying the same bytecode sequence of the rule to the connection after replacing ports of the active pair into agent ports of the connection. Moreover, when the connection is placed at the tail of a connection sequence, we can restart the same bytecode sequence after replacing these ports. For instance, take the following rule for Fibonacci number: + * When interaction rules have a connection whose the left and the right hand sides have the same IDs to the active pair, computation of the connection can be realised by a loop operation that applies the same bytecode sequence of the rule with replacing ports of active pairs. For instance, take the following Fibonacci number: ``` fib(ret) >< (int n) @@ -13,14 +23,14 @@ | n == 1 => ret~1 | _ => Add(ret, cnt2)~cnt1, fib(cnt1)~(n-1), fib(cnt2)~(n-2); ``` - This rule has a connection `fib(cnt2)~(n-2)` at the tail of the third connection sequence. The connection is computable by using the same bytecode sequence of `fib(ret)><(int n)` with replacing these ports `ret`, `n` into `cnt2`, `n-2`, respectively. So, the computation of the third connection sequence is realised by bytecode sequences of the other connections and the port replacing, and a loop operation to start execution from the top of the rule sequence. + This rule has `fib(cnt2)~(n-2)` as the connection for the loop, and it is possible to be applied the same bytecode sequence of `fib(ret)><(int n)` with replacing these ports `ret`, `n` into `cnt2`, `n-2`, respectively. So, this rule computation is realised by execution of the other connections and the loop operation for the connection `fib(cnt2)~(n-2)`. * This is also possible not only for agents like `(int n)`, but also other constructor agents such as `Cons(x,xs)`, `S(x)`. The following is a part of rules for insertion sort: ``` isort(ret) >< x:xs => insert(ret, x)~cnt, isort(cnt)~xs; ``` - When the `xs` connects to an `Cons(y,ys)` agent, then the computation is also realised by the loop operation because the `isort(cnt)~xs` can be regarded as `isort(cnt)~y:ys`, whose agents have the same IDs of the active pair. So, by introducing a conditional branch whether the `xs` connects to a `Cons` agent or not, this rule computation is also realised by the loop operation. + When the `xs` connects to an `Cons(y,ys)` agent, then the computation is also realised by the loop operation because the `isort(cnt)~xs` can be regarded as `isort(cnt)~y:ys`, whose agents have the same IDs of the active pair. So, by introducing a conditional branch if the `xs` is connected to a `Cons` agent or not, this rule computation is also realised by the loop operation. * In this version, this optimisation will be triggered when such the connection is placed at the tail of a sequence of connections. @@ -6,7 +6,7 @@ Inpla is a multi-threaded parallel interpreter of interaction nets. Once you write programs for sequential execution, it works also in multi-threaded parallel execution. Each thread is managed on each CPU-core with POSIX-thread library. -* The current version is 0.7.3 released on **20 February 2022**. (See [Changelog.md](Changelog.md) for details.) +* The current version is 0.7.3-1 (BugFix) released on **24 February 2022**. (See [Changelog.md](Changelog.md) for details.)  diff --git a/src/inpla.y b/src/inpla.y index 3550102..87e39b8 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -49,8 +49,8 @@ //#define COUNT_MKAGENT // count of execution fo mkagent -#define VERSION "0.7.3" -#define BUILT_DATE "20 Feb. 2022" +#define VERSION "0.7.3-1" +#define BUILT_DATE "24 Feb. 2022" // ------------------------------------------------------------------ @@ -4881,8 +4881,11 @@ void Ast_make_annotation_TailRecursionOptimisation(Ast *mainbody) { Ast *agent_TRO = NULL; AST_ID astID_of_TRO = idL; // idL is dummy + + if (mainbody == NULL) + return; - if ((mainbody == NULL) || (mainbody->id == AST_BODY)) { + if (mainbody->id == AST_BODY) { Ast *body = mainbody; // int idR = CmEnv.idR; @@ -7478,9 +7481,9 @@ void *exec_code(int mode, VirtualMachine * restrict vm, void * restrict *code) { VALUE a2 = NAME(a1)->port; free_Name(a1); a1 = a2; + reg[(unsigned long)code[pc+1]] = a1; } - reg[(unsigned long)code[pc+1]] = a1; if (BASIC(a1)->id == (unsigned long)code[pc+2]) { #ifdef COUNT_CNCT @@ -7551,6 +7554,7 @@ void *exec_code(int mode, VirtualMachine * restrict vm, void * restrict *code) { E_CNCTGN: // puts("CNCTGN reg reg"); // "x"~s, "x"->t ==> push(s,t), free("x") where "x" is a global name. + /* { pc++; VALUE x = reg[(unsigned long)code[pc++]]; @@ -7559,7 +7563,22 @@ void *exec_code(int mode, VirtualMachine * restrict vm, void * restrict *code) { PUSH(vm, reg[(unsigned long)code[pc++]], a1); } goto *code[pc]; - + */ + { + VALUE x = reg[(unsigned long)code[pc+1]]; + a1 = NAME(x)->port; + free_Name(x); + VALUE t = reg[(unsigned long)code[pc+2]]; + + puts("============================================"); + puts_term(t);printf("\n~");puts_term(a1);puts(""); + puts("============================================"); + + PUSH(vm, t, a1); + } + pc +=3; + goto *code[pc]; + E_SUBSTGN: |
