mirror of
https://github.com/nim-lang/Nim.git
synced 2026-09-17 18:44:53 +00:00
The Microsoft-hosted Azure agents are 2-core; the GitHub-hosted runners are 4-core (3-core on macOS arm64). Measured on an identical `koch boot -d:release` against our own Docs CI, the GitHub runners are ~2.3x faster: Linux boot 8.2 min -> 4.5 min Windows boot 11.4 min -> 4.9 min macOS boot 4.2 min -> 1.7 min csources 2.0 min -> 0.8 min `.github/workflows/ci_main.yml` keeps the same six jobs, the same runner images, the same dependency installation and the same `ci/funs.sh` entry points, so this is a move, not a redesign. Differences forced by the platform: * `[skip ci]` is handled natively by GitHub, so the `nimIsCiSkip` step and the `skipci` variable that gated every step are gone. `nimIsCiSkip` stays in `ci/funs.sh` for the version branches. * `SYSTEM_ACCESSTOKEN` is gone: `testament/azure.nim` activates on `TF_BUILD`, which is unset here, so it no-ops. This also removes a flake source, where a failure to create the Azure test run cancelled an otherwise green job. * `concurrency: cancel-in-progress` replaces Azure's `pr.autoCancel`. * `NIM_TESTAMENT_BATCH` defaults to `_` explicitly: a matrix-derived env var is set to the empty string rather than left unset, so `getEnv`'s default would not have applied. `disabled: "azure"` was the only way to skip a test on the main pipeline, so add `disabled: "github"` (`isGithubActions`) to replace it; `azure` is kept as deprecated, alongside `travis` and `appveyor`. Two manual steps remain: disabling the Azure pipeline definition, and pointing the required status checks at the new job names. --------- Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
62 lines
1.5 KiB
Nim
62 lines
1.5 KiB
Nim
discard """
|
|
matrix: "--mm:refc"
|
|
disabled: "win"
|
|
output: '''
|
|
'''
|
|
"""
|
|
|
|
# parallel convex hull for Nim bigbreak
|
|
# nim c --threads:on -d:release pconvex_hull.nim
|
|
import algorithm, sequtils, threadpool
|
|
|
|
type Point = tuple[x, y: float]
|
|
|
|
proc cmpPoint(a, b: Point): int =
|
|
result = cmp(a.x, b.x)
|
|
if result == 0:
|
|
result = cmp(a.y, b.y)
|
|
|
|
template cross[T](o, a, b: T): untyped =
|
|
(a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x)
|
|
|
|
template pro(): untyped =
|
|
while lr1 > 0 and cross(result[lr1 - 1], result[lr1], p[i]) <= 0:
|
|
discard result.pop
|
|
lr1 -= 1
|
|
result.add(p[i])
|
|
lr1 += 1
|
|
|
|
proc half[T](p: seq[T]; upper: bool): seq[T] =
|
|
var i, lr1: int
|
|
result = @[]
|
|
lr1 = -1
|
|
if upper:
|
|
i = 0
|
|
while i <= high(p):
|
|
pro()
|
|
i += 1
|
|
else:
|
|
i = high(p)
|
|
while i >= low(p):
|
|
pro()
|
|
i -= 1
|
|
discard result.pop
|
|
|
|
proc convex_hull[T](points: var seq[T], cmp: proc(x, y: T): int {.closure.}) : seq[T] =
|
|
if len(points) < 2: return points
|
|
points.sort(cmp)
|
|
var ul: array[2, FlowVar[seq[T]]]
|
|
parallel:
|
|
for k in 0..ul.high:
|
|
ul[k] = spawn half[T](points, k == 0)
|
|
result = concat(^ul[0], ^ul[1])
|
|
|
|
var s = map(toSeq(0..9999), proc(x: int): Point = (float(x div 100), float(x mod 100)))
|
|
# On some runs, this pool size reduction will set the "shutdown" attribute on the
|
|
# worker thread that executes our spawned task, before we can read the flowvars.
|
|
setMaxPoolSize 2
|
|
|
|
for i in 0..2:
|
|
doAssert convex_hull[Point](s, cmpPoint) ==
|
|
@[(0.0, 0.0), (99.0, 0.0), (99.0, 99.0), (0.0, 99.0)]
|