diff options
| author | Shinya Sato <shinnya.sato@gmail.com> | 2023-03-11 12:51:02 +0900 |
|---|---|---|
| committer | Shinya Sato <shinnya.sato@gmail.com> | 2023-03-11 12:51:02 +0900 |
| commit | 3e5a883cf0b7d0a7fe024d0db0e484cc38b240b8 (patch) | |
| tree | 15831d3c5ae25f05bbcf79b3daa49ce5ebd3f70b | |
| parent | b80d7f3e05776eed407bde32ad6cde5d393fde1d (diff) | |
| parent | fcb5004baa9b19fa153e3406ec81feea4c6ac818 (diff) | |
| download | inpla-3e5a883cf0b7d0a7fe024d0db0e484cc38b240b8.tar.gz inpla-3e5a883cf0b7d0a7fe024d0db0e484cc38b240b8.zip | |
Merge branch 'develop'
Diffstat (limited to '')
| -rw-r--r-- | Changelog.md | 52 | ||||
| -rw-r--r-- | README.md | 14 | ||||
| -rw-r--r-- | pic/benchmark_reuse_v10.0.7.png | bin | 0 -> 40501 bytes | |||
| -rw-r--r-- | src/config.h | 9 | ||||
| -rw-r--r-- | src/inpla.y | 54 |
5 files changed, 106 insertions, 23 deletions
diff --git a/Changelog.md b/Changelog.md index 863fe25..91e6d70 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,16 +1,50 @@ # Change log +### v0.10.7 (released on 11 March 2023) + +| | Inpla8 | Inpla8r | +| ------------ | :-------------------------------------------------: | :----------------------------------------------------: | +| n-queens 12 | [**0.54**](comparison/Inpla/src/nqueen-12.in) | [0.36](comparison/Inpla/src/nqueen-12-reuse.in) | +| ack(3,11) | [**0.90**](comparison/Inpla/src/ack-stream_3-11.in) | [0.73](comparison/Inpla/src/ack-stream_3-11-reuse.in) | +| fib 38 | [**0.43**](comparison/Inpla/src/fib-38.in) | [**0.45**](comparison/Inpla/src/fib-38-reuse.in) | +| bsort 20000 | [**2.38**](comparison/Inpla/src/bsort-20000.in) | [1.48](comparison/Inpla/src/bsort-20000-reuse.in) | +| isort 20000 | [**0.32**](comparison/Inpla/src/isort-20000.in) | [**0.32**](comparison/Inpla/src/isort-20000-reuse.in) | +| qsort 260000 | [0.15](comparison/Inpla/src/qsort-260000.in) | [0.12](comparison/Inpla/src/qsort-260000-reuse.in) | +| msort 260000 | [0.14](comparison/Inpla/src/msort-260000.in) | [**0.16**](comparison/Inpla/src/msort-260000-reuse.in) | + +#### Polished + +- **Stop using MKAGENTn**: Generally, To make an *n*-arity agent, we need the following operation: + + - To get memory area for the agent, + - To assign ports information to the memory area. + + So, to make 3-arity agent requires 1+3 steps. But, it can be 1 step if we provide a special operation to make 3-arity agents. The bytecode`makeagent3` is just that. This time I stopped using such folding operations in order to observe a more theoretical behaviour . Some become slower (shown in bold font in the table above), but in the case of the reused ones the change seems not to be so much. In the future, the reused one will be the default setting, so I would like to accept this change for now. + + To enable `mkagentN` again, make the following line uncommented in `config.h`: + + ``` + // Use MKAGENTn codes + //#define USE_MKAGENT_N + ``` + + + + + + + ### v0.10.6 (released on 6 February 2023) -| | Haskell | OCaml | SML | Python | Inpla8 | Inpla8r | -| ------------ | :-----------------------------------------: | :-------------------------------------: | :-------------------------------------: | :----------------------------------------: | :---------------------------------------------: | :----------------------------------------------------: | -| n-queens 12 | [**0.23**](comparison/Haskell/nqueen-12.hs) | [0.44](comparison/OCaml/nqueen12.ml) | [0.60](comparison/SML/ack3-11.sml) | [3.79](comparison/Python/nqueen-12.py) | [0.53](comparison/Inpla/src/nqueen-12.in) | [0.36](comparison/Inpla/src/nqueen-12-reuse.in) | -| ack(3,11) | [2.37](comparison/Haskell/ack3-11.hs) | [0.57](comparison/OCaml/ack3_11.ml) | [**0.42**](comparison/SML/ack3-11.sml) | [-](comparison/Python/ack3-11.py) | [0.86](comparison/Inpla/src/ack-stream_3-11.in) | [0.75](comparison/Inpla/src/ack-stream_3-11-reuse.in) | -| fib 38 | [1.61](comparison/Haskell/fib-38.hs) | [**0.15**](comparison/OCaml/fib38.ml) | [0.27](comparison/SML/fib-38.sml) | [9.27](comparison/Python/fib-38.py) | [0.41](comparison/Inpla/src/fib-38.in) | [0.43](comparison/Inpla/src/fib-38-reuse.in) | -| bsort 20000 | [5.03](comparison/Haskell/bsort-20000.hs) | [6.47](comparison/OCaml/bsort20000.ml) | [2.39](comparison/SML/bsort-20000.sml) | [20.02](comparison/Python/bsort-20000.py) | [2.23](comparison/Inpla/src/bsort-20000.in) | [**1.48**](comparison/Inpla/src/bsort-20000-reuse.in) | -| isort 20000 | [2.15](comparison/Haskell/isort-20000.hs) | [1.48](comparison/OCaml/isort20000.ml) | [0.60](comparison/SML/isort-20000.sml) | [8.83](comparison/Python/isort-20000.py) | [**0.31**](comparison/Inpla/src/isort-20000.in) | [0.33](comparison/Inpla/src/isort-20000-reuse.in) | -| qsort 260000 | [0.36](comparison/Haskell/qsort-800000.hs) | [0.22](comparison/OCaml/qsort260000.ml) | [0.27](comparison/SML/qsort-260000.sml) | [10.33](comparison/Python/qsort-260000.py) | [0.15](comparison/Inpla/src/qsort-260000.in) | [**0.12**](comparison/Inpla/src/qsort-260000-reuse.in) | -| msort 260000 | [0.38](comparison/Haskell/msort-800000.hs) | [0.17](comparison/OCaml/msort260000.ml) | [0.29](comparison/SML/msort-260000.sml) | [11.09](comparison/Python/msort-260000.py) | [0.15](comparison/Inpla/src/msort-260000.in) | [**0.15**](comparison/Inpla/src/msort-260000-reuse.in) | +| | Inpla8 | Inpla8r | +| ------------ | :---------------------------------------------: | :----------------------------------------------------: | +| n-queens 12 | [0.53](comparison/Inpla/src/nqueen-12.in) | [0.36](comparison/Inpla/src/nqueen-12-reuse.in) | +| ack(3,11) | [0.86](comparison/Inpla/src/ack-stream_3-11.in) | [0.75](comparison/Inpla/src/ack-stream_3-11-reuse.in) | +| fib 38 | [0.41](comparison/Inpla/src/fib-38.in) | [0.43](comparison/Inpla/src/fib-38-reuse.in) | +| bsort 20000 | [2.23](comparison/Inpla/src/bsort-20000.in) | [**1.48**](comparison/Inpla/src/bsort-20000-reuse.in) | +| isort 20000 | [**0.31**](comparison/Inpla/src/isort-20000.in) | [0.33](comparison/Inpla/src/isort-20000-reuse.in) | +| qsort 260000 | [0.15](comparison/Inpla/src/qsort-260000.in) | [**0.12**](comparison/Inpla/src/qsort-260000-reuse.in) | +| msort 260000 | [0.15](comparison/Inpla/src/msort-260000.in) | [**0.15**](comparison/Inpla/src/msort-260000-reuse.in) | #### Polished @@ -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.10.6, released on **6 February 2023**. (See [Changelog.md](Changelog.md) for details.) +* The current version is 0.10.7, released on **11 March 2023**. (See [Changelog.md](Changelog.md) for details.) * The below graph shows speed-up ratio to threads numbers for programs in the following benchmark table.  @@ -17,13 +17,13 @@ Inpla is a multi-threaded parallel interpreter of interaction nets. Once you wri | | Haskell | OCaml | SML | Python | Inpla8 | Inpla8r | | -------------- | :------: | :------: | :----: | :----: | :------: | :------: | -| n-queens 12 | [**0.23**](comparison/Haskell/nqueen-12.hs) | [0.44](comparison/OCaml/nqueen12.ml) | [0.60](comparison/SML/ack3-11.sml) | [3.79](comparison/Python/nqueen-12.py) | [0.53](comparison/Inpla/src/nqueen-12.in) | [0.36](comparison/Inpla/src/nqueen-12-reuse.in) | -| ack(3,11) | [2.37](comparison/Haskell/ack3-11.hs) | [0.57](comparison/OCaml/ack3_11.ml) | [**0.42**](comparison/SML/ack3-11.sml) | [-](comparison/Python/ack3-11.py) | [0.86](comparison/Inpla/src/ack-stream_3-11.in) | [0.75](comparison/Inpla/src/ack-stream_3-11-reuse.in) | -| fib 38 | [1.61](comparison/Haskell/fib-38.hs) | [**0.15**](comparison/OCaml/fib38.ml) | [0.27](comparison/SML/fib-38.sml) | [9.27](comparison/Python/fib-38.py) | [0.41](comparison/Inpla/src/fib-38.in) | [0.43](comparison/Inpla/src/fib-38-reuse.in) | -| bsort 20000 | [5.03](comparison/Haskell/bsort-20000.hs) | [6.47](comparison/OCaml/bsort20000.ml) | [2.39](comparison/SML/bsort-20000.sml) | [20.02](comparison/Python/bsort-20000.py) | [2.23](comparison/Inpla/src/bsort-20000.in) | [**1.48**](comparison/Inpla/src/bsort-20000-reuse.in) | -| isort 20000 | [2.15](comparison/Haskell/isort-20000.hs) | [1.48](comparison/OCaml/isort20000.ml) | [0.60](comparison/SML/isort-20000.sml) | [8.83](comparison/Python/isort-20000.py) | [**0.31**](comparison/Inpla/src/isort-20000.in) | [0.33](comparison/Inpla/src/isort-20000-reuse.in) | +| n-queens 12 | [**0.23**](comparison/Haskell/nqueen-12.hs) | [0.44](comparison/OCaml/nqueen12.ml) | [0.60](comparison/SML/ack3-11.sml) | [3.79](comparison/Python/nqueen-12.py) | [0.54](comparison/Inpla/src/nqueen-12.in) | [0.36](comparison/Inpla/src/nqueen-12-reuse.in) | +| ack(3,11) | [2.37](comparison/Haskell/ack3-11.hs) | [0.57](comparison/OCaml/ack3_11.ml) | [**0.42**](comparison/SML/ack3-11.sml) | [-](comparison/Python/ack3-11.py) | [0.90](comparison/Inpla/src/ack-stream_3-11.in) | [0.73](comparison/Inpla/src/ack-stream_3-11-reuse.in) | +| fib 38 | [1.61](comparison/Haskell/fib-38.hs) | [**0.15**](comparison/OCaml/fib38.ml) | [0.27](comparison/SML/fib-38.sml) | [9.27](comparison/Python/fib-38.py) | [0.43](comparison/Inpla/src/fib-38.in) | [0.45](comparison/Inpla/src/fib-38-reuse.in) | +| bsort 20000 | [5.03](comparison/Haskell/bsort-20000.hs) | [6.47](comparison/OCaml/bsort20000.ml) | [2.39](comparison/SML/bsort-20000.sml) | [20.02](comparison/Python/bsort-20000.py) | [2.38](comparison/Inpla/src/bsort-20000.in) | [**1.48**](comparison/Inpla/src/bsort-20000-reuse.in) | +| isort 20000 | [2.15](comparison/Haskell/isort-20000.hs) | [1.48](comparison/OCaml/isort20000.ml) | [0.60](comparison/SML/isort-20000.sml) | [8.83](comparison/Python/isort-20000.py) | [**0.32**](comparison/Inpla/src/isort-20000.in) | [**0.32**](comparison/Inpla/src/isort-20000-reuse.in) | | qsort 260000 | [0.36](comparison/Haskell/qsort-800000.hs) | [0.22](comparison/OCaml/qsort260000.ml) | [0.27](comparison/SML/qsort-260000.sml) | [10.33](comparison/Python/qsort-260000.py) | [0.15](comparison/Inpla/src/qsort-260000.in) | [**0.12**](comparison/Inpla/src/qsort-260000-reuse.in) | -| msort 260000 | [0.38](comparison/Haskell/msort-800000.hs) | [0.17](comparison/OCaml/msort260000.ml) | [0.29](comparison/SML/msort-260000.sml) | [11.09](comparison/Python/msort-260000.py) | [0.15](comparison/Inpla/src/msort-260000.in) | [**0.15**](comparison/Inpla/src/msort-260000-reuse.in) | +| msort 260000 | [0.38](comparison/Haskell/msort-800000.hs) | [0.17](comparison/OCaml/msort260000.ml) | [0.29](comparison/SML/msort-260000.sml) | [11.09](comparison/Python/msort-260000.py) | [**0.14**](comparison/Inpla/src/msort-260000.in) | [0.16](comparison/Inpla/src/msort-260000-reuse.in) | diff --git a/pic/benchmark_reuse_v10.0.7.png b/pic/benchmark_reuse_v10.0.7.png Binary files differnew file mode 100644 index 0000000..e4106ca --- /dev/null +++ b/pic/benchmark_reuse_v10.0.7.png diff --git a/src/config.h b/src/config.h index 7d3ea52..ed6c624 100644 --- a/src/config.h +++ b/src/config.h @@ -66,7 +66,10 @@ // ------------------------------------------------ // Comment out definitions if not needed. -// +// Use MKAGENTn codes +//#define USE_MKAGENT_N + + // Optimisation inspired by Tail Call Optimisation // #define OPTIMISE_IMCODE_TCO @@ -118,8 +121,8 @@ // comes with compile errors. //#define OLD_REUSEAGENT // Use the old mechanism to reuse agents. -// // Thus, `REUSEAGENT' is used -// // instead of `CHID_L`, `LOADP_L` and so on. + // Thus, `REUSEAGENTn' is used + // instead of `CHID_L`, `LOADP_L` and so on. diff --git a/src/inpla.y b/src/inpla.y index 47a2242..7bf496d 100644 --- a/src/inpla.y +++ b/src/inpla.y @@ -22,8 +22,8 @@ // ---------------------------------------------- -#define VERSION "0.10.6" -#define BUILT_DATE "6 February 2023" +#define VERSION "0.10.7" +#define BUILT_DATE "11 March 2023" // ------------------------------------------------------------------ @@ -2884,6 +2884,7 @@ void VMCode_puts(void **code, int n) { (unsigned long)code[i+3], (unsigned long)code[i+4], (unsigned long)code[i+5]); + i+=5; #endif } else if (code[i] == CodeAddr[OP_MKAGENT5]) { @@ -6317,8 +6318,18 @@ int Compile_term_on_ast(Ast *ptr, int target) { if (target == -1) { result = CmEnv_newvar(); + +#ifdef USE_MKAGENT_N mkagent = OP_MKAGENT2; IMCode_genCode4(mkagent, ID_CONS, alloc[0], alloc[1], result); + +#else + // expanded operations + IMCode_genCode2(OP_MKAGENT0, ID_CONS, result); + IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + IMCode_genCode3(OP_LOADP, alloc[1], 1, result); +#endif + } else { result = target; @@ -6397,9 +6408,16 @@ int Compile_term_on_ast(Ast *ptr, int target) { case 2: if (target == -1) { +#ifdef USE_MKAGENT_N mkagent = OP_MKAGENT2; IMCode_genCode4(mkagent, GET_TUPLEID(arity), alloc[0], alloc[1], result); +#else + // expanded operations + IMCode_genCode2(OP_MKAGENT0, GET_TUPLEID(arity), result); + IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + IMCode_genCode3(OP_LOADP, alloc[1], 1, result); +#endif } else { mkagent = OP_REUSEAGENT2; IMCode_genCode4(mkagent, result, GET_TUPLEID(arity), @@ -6409,9 +6427,17 @@ int Compile_term_on_ast(Ast *ptr, int target) { case 3: if (target == -1) { +#ifdef USE_MKAGENT_N mkagent = OP_MKAGENT3; IMCode_genCode5(mkagent, GET_TUPLEID(arity), alloc[0], alloc[1], alloc[2], result); +#else + // expanded operations + IMCode_genCode2(OP_MKAGENT0, GET_TUPLEID(arity), result); + IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + IMCode_genCode3(OP_LOADP, alloc[1], 1, result); + IMCode_genCode3(OP_LOADP, alloc[2], 2, result); +#endif } else { mkagent = OP_REUSEAGENT3; IMCode_genCode5(mkagent, result, GET_TUPLEID(arity), @@ -6421,9 +6447,18 @@ int Compile_term_on_ast(Ast *ptr, int target) { case 4: if (target == -1) { +#ifdef USE_MKAGENT_N mkagent = OP_MKAGENT4; IMCode_genCode6(mkagent, GET_TUPLEID(arity), alloc[0], alloc[1], alloc[2], alloc[3], result); +#else + // expanded operations + IMCode_genCode2(OP_MKAGENT0, GET_TUPLEID(arity), result); + IMCode_genCode3(OP_LOADP, alloc[0], 0, result); + IMCode_genCode3(OP_LOADP, alloc[1], 1, result); + IMCode_genCode3(OP_LOADP, alloc[2], 2, result); + IMCode_genCode3(OP_LOADP, alloc[2], 3, result); +#endif } else { mkagent = OP_REUSEAGENT4; IMCode_genCode6(mkagent, result, GET_TUPLEID(arity), @@ -6433,11 +6468,13 @@ int Compile_term_on_ast(Ast *ptr, int target) { #if MAX_PORT > 4 default: + // We support upto 5-tuples. if (target == -1) { mkagent = OP_MKAGENT5; IMCode_genCode7(mkagent, GET_TUPLEID(arity), alloc[0], alloc[1], alloc[2], alloc[3], alloc[4], result); + } else { mkagent = OP_REUSEAGENT5; IMCode_genCode7(mkagent, result, GET_TUPLEID(arity), @@ -6538,6 +6575,15 @@ int Compile_term_on_ast(Ast *ptr, int target) { } #endif +#ifndef USE_MKAGENT_N + if (target == -1) { + IMCode_genCode2(OP_MKAGENT0, id, result); + for (i=0; i<arity; i++) { + IMCode_genCode3(OP_LOADP, alloc[i], i, result); + } + return result; + } +#endif switch (arity) { case 0: @@ -10775,12 +10821,12 @@ int check_ast_arity(Ast *ast) { } } else if (ast->id == AST_TUPLE) { + // We support upto 5-tuples. if ((ast->intval <= MAX_PORT) && (ast->intval <= 5)) { return 1; } else { if (MAX_PORT <= 5) { - printf("Error: A tuple has too many arguments. It should be MAX_PORT(=%d) or less.\n", - MAX_PORT); + printf("Error: A tuple has too many arguments. It should be MAX_PORT(=%d) or less.\n", MAX_PORT); } else { printf("Error: A tuple has too many arguments. It should be 5 or less.\n"); } |
