Skip to content

Examples in README.md do not compile #200

Open
@PhilippMDoerner

Description

@PhilippMDoerner

Given that I was playing around and noticed it:
I was unable to compile any of the examples. Sporadically I tested

import weave

func initialize(buffer: ptr UncheckedArray[float32], len: int) =
  for i in 0 ..< len:
    buffer[i] = i.float32

proc transpose(M, N: int, bufIn, bufOut: ptr UncheckedArray[float32]) =
  ## Transpose a MxN matrix into a NxM matrix with nested for loops

  parallelFor j in 0 ..< N:
    captures: {M, N, bufIn, bufOut}
    parallelFor i in 0 ..< M:
      captures: {j, M, N, bufIn, bufOut}
      bufOut[j*M+i] = bufIn[i*N+j]

proc main() =
  let M = 200
  let N = 2000

  let input = newSeq[float32](M*N)
  # We can't work with seq directly as it's managed by GC, take a ptr to the buffer.
  let bufIn = cast[ptr UncheckedArray[float32]](input[0].unsafeAddr)
  bufIn.initialize(M*N)

  var output = newSeq[float32](N*M)
  let bufOut = cast[ptr UncheckedArray[float32]](output[0].addr)

  init(Weave)
  transpose(M, N, bufIn, bufOut)
  exit(Weave)

main()

On nim 2.0.0, 2.0.4 and 1.6.20, all of them have various versions of compiler errors:
With 1.6.20: nim r -f --cc:clang -d:useMalloc --threads:on src/playground.nim:

/home/isofruit/.cache/nim/playground_d/@m..@s..@s..@s.nimble@spkgs2@sweave-0.4.0-91b8ef3189383a89f75e3c35c64687b8a67bf549@sweave@sscheduler.nim.c:450:17: error: incompatible function pointer types assigning to 'tyProc__4SVlZZPmetqBimNsH9cHcOA' (aka 'void (*)(void *)') from 'void (tyObject_LookAsideList__heA8P1gVJ9ac9by6gcye6wkQ *)' (aka 'void (struct tyObject_LookAsideList__heA8P1gVJ9ac9by6gcye6wkQ *)') [-Wincompatible-function-pointer-types]
  450 |         (*hook).Field0 = cacheMaintenanceEx__OOZOOZOOZOnimbleZpkgs50Zweave4548O52O48455749b56ef51495657515651a5657f5553e51c5153c5452545655b56a5455bf535257ZweaveZscheduler_u79;
      |                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: execution of an external compiler program 'clang -c -w -ferror-limit=3 -pthread   -I/home/isofruit/.choosenim/toolchains/nim-1.6.20/lib -I/home/isofruit/dev/playground/src -o /home/isofruit/.cache/nim/playground_d/@m..@s..@[email protected]@[email protected]@[email protected] /home/isofruit/.cache/nim/playground_d/@m..@s..@[email protected]@[email protected]@[email protected]' failed with exit code: 1

With 2.0.0: nim r -f --cc:clang -d:useMalloc src/playground.nim

/home/isofruit/.nimble/pkgs2/weave-0.4.0-91b8ef3189383a89f75e3c35c64687b8a67bf549/weave/parallel_tasks.nim(166, 16) Error: type mismatch: got 'proc (param`gensym1: pointer){.nimcall.}' for 'async_fib' but expected 'proc (param: pointer){.nimcall, gcsafe.}'
  Pragma mismatch: got '{..}', but expected '{.gcsafe.}'.

Similar issues appear with the other examples I sporadically tested, leading me to assume that none of them currently work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions