OK, I've racked my brain enough and need help. Using 0.17.2 on Linux, I have 
this `proc` below.
    
    
    proc segcount(row, Kn: int): int =
      var cnt = 0
      for k in 0..<Kn: cnt += seg[row + k].int
      result = cnt
    

It works when I use it as below.
    
    
    proc segsieve(Kn: int) =             # for Kn resgroups in segment
      ...
      ...
      
      var cnt = 0                        # count for the segment primes '1' 
bytes
      for i in 0..<rescnt:               # count Kn resgroups|bytes each 
restrack
          cnt += segcount(i*KB, Kn)
      primecnt += cnt.uint               # update primecnt for the segment
    

But when I try to parallelize this using spawn I get this error.
    
    
    proc segsieve(Kn: int) =             # for Kn resgroups in segment
      ...
      ...
      
      var cnt = 0                        # count for the segment primes '1' 
bytes
      for i in 0..<rescnt:               # count Kn resgroups|bytes each 
restrack
          cnt += spawn segcount(i*KB, Kn)  <-- error points to start of '+='
      sync()
      primecnt += cnt.uint               # update primecnt for the segment
    
    -------------------------------------------------------------
    [jzakiya@localhost nim]$ nim c --cc:gcc --threads:on --d:release 
ssozp5x1c1par.nim
    Hint: used config file '/home/jzakiya/nim-0.17.2/config/nim.cfg' [Conf]
    Hint: system [Processing]
    Hint: ssozp5x1c1par [Processing]
    Hint: math [Processing]
    Hint: strutils [Processing]
    Hint: parseutils [Processing]
    Hint: algorithm [Processing]
    Hint: typetraits [Processing]
    Hint: threadpool [Processing]
    Hint: cpuinfo [Processing]
    Hint: os [Processing]
    Hint: times [Processing]
    Hint: posix [Processing]
    Hint: ospaths [Processing]
    Hint: linux [Processing]
    Hint: cpuload [Processing]
    ssozp5x1c1par.nim(154, 16) Error: type mismatch: got (uint64, 
FlowVar[system.int])
    but expected one of:
    proc `+=`[T: SomeOrdinal | uint | uint64](x: var T; y: T)
    proc `+=`[T: float | float32 | float64](x: var T; y: T)
    
    [jzakiya@localhost nim]$
    
    

Reply via email to