HigherOrderCO / HVM

A massively parallel, optimal functional runtime in Rust
https://higherorderco.com
Apache License 2.0
10.42k stars 392 forks source link

Simple program hanging on HVM-CUDA #406

Closed VictorTaelin closed 4 weeks ago

VictorTaelin commented 1 month ago

Reproducing the behavior

Bend:

Bits/E     = λo λi λe e
(Bits/O x) = λo λi λe (o x)
(Bits/I x) = λo λi λe (i x)

def Count(n, bs):
  switch n:
    case 0:
      return 1
    case _:
      return Count(n-1, Bits/O(bs)) + Count(n-1, Bits/I(bs))
      # return Count(n-1, λt:t(1,bs)) + Count(n-1, λt:t(2,bs)) # <- works like this

def Main:
  return Count(8, Bits/E)

HVM:

@Bits/E = (* (* (a a)))

@Bits/I = (a (* ((a b) (* b))))

@Bits/O = (a ((a b) (* (* b))))

@Count = (?(((* 1) @Count__C0) a) a)

@Count__C0 = ({a d} ({b e} h))
  &!@Count ~ (a (((1 (b c)) c) $([+] $(g h))))
  &!@Count ~ (d (((2 (e f)) f) g))

@main = a
  & @Count ~ (8 (@Bits/E a))

Fails to halt on HVM-CUDA. Same if you use native constructors.

VictorTaelin commented 1 month ago

@enricozb @developedby any ideas why?

enricozb commented 1 month ago

What version of HVM / Bend are you using

enricozb commented 4 weeks ago

This looks to be fixed as of a5e6788f3b377f28be91d27a4d7f6d4f6712c0bb, returning a Result: 256. If this was being run through the IO (run.c), it's possible the bug fixed in this commit was the culprit.