-
Notifications
You must be signed in to change notification settings - Fork 0
Lessons: Nikola
What have we learned about Nikola so far?
Which limitations of Nikola has we come across?
-
folds and scans are missing from the language and without those, we have to use meta language constructs instead. These are concealed for the Nikola compiler which thus lacks valuable information about the program structure and makes certain programs harder to write.
-
We are unsure how the built-in generate function is to supposed to be used. (We should contact Geoffrey), Geoffrey's binomial pricer generates arrays on the host and transfers the to the device, which we would like to avoid.
-
There seems to be a lot of errors that aren't statically checked for. For example, the following program type checks with GHC, but Nikola fails to compile it:
example1 :: Exp Int32 -> Exp Int32 example1 n = foldl (+) 0 [1..n]```
The reason is that the value of n is first known at runtime but is necessary to expand the Enum expression ([0..n]) already at Nikola-compile time. Perhaps the instance Enum (Exp Int32) is superfluous?
But even if we fix the value of n before compilation, we still get problems. We can change the above example to:
```haskell
example1 :: Int -> Exp Int32 example1 n = foldl (\x y -> x + (lift $ fromIntegral y)) 0 [1..n]
Now we would expect that a expression such as `(0 + 1 + 2 .. + n)` would be generated as Nikola-code, but instead we get a runtime error:
```Main: embedded values are not enumerable```
Efficiency
----------
Why is Nikola that much slower than the handwritten CUDA-code for the binomial pricer? And even slower than Data.Vector in "small" instances?