Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Examples in README.md do not compile #200

Open
PhilippMDoerner opened this issue May 10, 2024 · 0 comments
Open

Examples in README.md do not compile #200

PhilippMDoerner opened this issue May 10, 2024 · 0 comments

Comments

@PhilippMDoerner
Copy link

PhilippMDoerner commented May 10, 2024

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..@s..@s.nimble@spkgs2@sweave-0.4.0-91b8ef3189383a89f75e3c35c64687b8a67bf549@sweave@sscheduler.nim.c.o /home/isofruit/.cache/nim/playground_d/@m..@s..@s..@s.nimble@spkgs2@sweave-0.4.0-91b8ef3189383a89f75e3c35c64687b8a67bf549@sweave@sscheduler.nim.c' 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant