HigherOrderCO / HVM

A massively parallel, optimal functional runtime in Rust

Home Page:https://higherorderco.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Code with HVM.log hangs

crides opened this issue · comments

commented
Step = 0.5
(F2B 1.0) = 1
(F2B 0.0) = 0
(Dbg x) = (HVM.log x x)
(Gen x) = (U60.if (F2B (< x 0.0)) [] (List.cons (Dbg x) (Gen (- x Step))))
Main = (Gen 5.0)

This hangs, and also logs unordered results like:

4.0
1.0
3.0
3.5
2.5
5.0
4.5
1.5
2.0
^C
commented

more minimal example:

(Gen x) = (U60.if (< x 1) [] (List.cons (HVM.log x x) (Gen (- x 1))))
Main = (Gen 2)

This hangs in single thread with debug mode enabled, and (Gen 5) hangs without debug mode enabled.

It's unordered because you didnt force a sequential order for the logs like so

(Gen 0) = []
(Gen x) = (Data.List.cons x (Apps.HVM.log x (Gen (- x 1))))
Main = (Gen 5)

or

(Gen 0) = []
(Gen x) = (Apps.HVM.log x (Data.List.cons x (Gen (- x 1))))
Main = (Gen 5)

I think it's hanging when a thread calls log for the second time.

Running it with hvm run -t1 hangs every time when reducing the second log

(Gen 0) = []
(Gen x) = (Apps.HVM.log x (Data.List.cons x (Gen (- x 1))))
Main = (Gen 5) // Or any number higher than one

If we give it more threads to work then the iteration at which it hangs changes non-deterministically, probably due to the order that the threads are executed.
The probability of completing without hanging seems to increase with the number of threads.

commented

The behaviors are very different since the recent commits (I was previously on 5e52131). With the previous program, HVM now underflows Gen. The fix that I tried on 5e52131 also works on the new master (05a6984), which evaluates the arguments of a constructor just like those of a function and not let HVM.log do the reduction. With this commit on top of 5e52131 HVM doesn't hang ; with it on 05a6984 HVM still underflows

Edit: oops apparently U60.if also got renamed

closed as HVM is now HVM2 and this no longer pertains.