From 74ae5a71fa2148d6d4eb0b6231e8e090315d466c Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Tue, 22 Nov 2022 01:02:17 +0800 Subject: [PATCH] patches for stricteffects (#24) --- benchmarks/dfs/taskpool_dfs.nim | 2 +- benchmarks/heat/taskpool_heat.nim | 4 ++-- benchmarks/nqueens/taskpool_nqueens.nim | 2 +- examples/e01_simple_tasks.nim | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/benchmarks/dfs/taskpool_dfs.nim b/benchmarks/dfs/taskpool_dfs.nim index b08edb2..4ce670c 100644 --- a/benchmarks/dfs/taskpool_dfs.nim +++ b/benchmarks/dfs/taskpool_dfs.nim @@ -17,7 +17,7 @@ when not defined(windows): var tp: Taskpool -proc dfs(depth, breadth: int): uint32 = +proc dfs(depth, breadth: int): uint32 {.gcsafe.} = if depth == 0: return 1 diff --git a/benchmarks/heat/taskpool_heat.nim b/benchmarks/heat/taskpool_heat.nim index 8275bfe..e0be5d3 100644 --- a/benchmarks/heat/taskpool_heat.nim +++ b/benchmarks/heat/taskpool_heat.nim @@ -133,7 +133,7 @@ var odd: Matrix[float64] even: Matrix[float64] -proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable.}= +proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable, gcsafe.}= # TODO to allow awaiting `heat` we return a dummy bool # The parallel spawns are updating the same matrix cells otherwise if iu - il > 1: @@ -160,7 +160,7 @@ proc heat(m: Matrix[float64], il, iu: int32): bool {.discardable.}= row[j] = f(xu + i*dx, yu + j*dy) row[ny - 1] = randb(xu + i*dx, 0) -proc diffuse(output: Matrix[float64], input: Matrix[float64], il, iu: int32, t: float64): bool {.discardable.} = +proc diffuse(output: Matrix[float64], input: Matrix[float64], il, iu: int32, t: float64): bool {.discardable, gcsafe.} = # TODO to allow awaiting `diffuse` we return a dummy bool # The parallel spawns are updating the same matrix cells otherwise if iu - il > 1: diff --git a/benchmarks/nqueens/taskpool_nqueens.nim b/benchmarks/nqueens/taskpool_nqueens.nim index 1c55262..879da21 100644 --- a/benchmarks/nqueens/taskpool_nqueens.nim +++ b/benchmarks/nqueens/taskpool_nqueens.nim @@ -111,7 +111,7 @@ proc nqueens_ser(n, j: int32, a: CharArray): int32 = if isValid(j+1, a): result += nqueens_ser(n, j+1, a) -proc nqueens_par(n, j: int32, a: CharArray): int32 = +proc nqueens_par(n, j: int32, a: CharArray): int32 {.gcsafe.} = if n == j: # Good solution, count it diff --git a/examples/e01_simple_tasks.nim b/examples/e01_simple_tasks.nim index e415316..b306c39 100644 --- a/examples/e01_simple_tasks.nim +++ b/examples/e01_simple_tasks.nim @@ -21,7 +21,7 @@ block: # Async/Await var tp: Taskpool - proc asyncFib(n: int): int = + proc asyncFib(n: int): int {.gcsafe.} = if n < 2: return n