Skip to content

Commit

Permalink
fix arraymancer for nim-lang/Nim#18050 (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheecour authored Jun 30, 2021
1 parent 2c4a39f commit f8b982b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/arraymancer/laser/tensor/initialization.nim
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ proc copyFromRaw*[T](dst: var Tensor[T], buffer: ptr T, len: Natural) =
## Destination tensor size and buffer length should be the same
when T is KnownSupportsCopyMem:
withCompilerOptimHints()
mixin size
# either this or `from ../../tensor/data_structure import size` is needed
# as can be seen with: `type tmp = typeof(Tensor[int].default.size)` which
# would fail at top-level
doAssert dst.size == len, "Tensor size and buffer length should be the same"
let buf{.restrict.} = cast[ptr UncheckedArray[T]](buffer)
omp_parallel_chunks(
Expand Down Expand Up @@ -167,6 +171,7 @@ proc setZero*[T](t: var Tensor[T], check_contiguous: static bool = true) =
t.storage.raw_buffer.reset()
t.storage.raw_buffer.setLen(t.size)
else:
mixin size
omp_parallel_chunks(
t.size, chunk_offset, chunk_size,
OMP_MEMORY_BOUND_GRAIN_SIZE * 4):
Expand Down

0 comments on commit f8b982b

Please sign in to comment.