futhark-benchmarks icon indicating copy to clipboard operation
futhark-benchmarks copied to clipboard

Gram matrix initialization

Open UnixJunkie opened this issue 5 years ago • 7 comments

Dear futharckers, I wrote this recently: https://github.com/ocaml-bench/sandmark/blob/master/benchmarks/multicore-grammatrix/grammatrix.ml The Gram matrix is quite useful in several machine learning settings. I think it might be a nice, real-world, addition to the futhark benchmarks. Futharkly yours, F.

UnixJunkie avatar Sep 01 '20 09:09 UnixJunkie

Some people wrote a multithread version of it: https://github.com/ocaml-bench/sandmark/blob/master/benchmarks/multicore-grammatrix/grammatrix_multicore.ml I have a parallel (multicore) version of it there: https://github.com/UnixJunkie/gram-matrix-bench/blob/master/src/gram.ml

UnixJunkie avatar Sep 01 '20 09:09 UnixJunkie

My bench results can be seen there: https://github.com/UnixJunkie/gram-matrix-bench

UnixJunkie avatar Sep 01 '20 09:09 UnixJunkie

Is there much to gain by exploiting the symmetry, when compared to just doing a normal matrix multiplication? It seems like it would only reduce the work by a factor of two.

athas avatar Sep 01 '20 13:09 athas

The matrix is diagonal symmetric. Usually, I only compute one half plus the diagonal. Also, this matrix can be quite big quite fast, because of the dataset size.

UnixJunkie avatar Sep 02 '20 00:09 UnixJunkie

Also, probably stupid question, can we read a file in Futhark, and write to one? I have read that there is no IO in the futhark doc, so I am really wondering.

UnixJunkie avatar Sep 02 '20 03:09 UnixJunkie

No, Futhark is pure. For testing and benchmarking programs, the compiler automatically inserts IO for reading input and writing results (see here), but for actual production use, Futhark code must be invoked from a conventional programming language (discussed here).

athas avatar Sep 02 '20 07:09 athas

Wow, amazing. Thanks for the pointers. I read that: "Simplicity. I think modern computers are too slow, too fragile, and too incorrect, and I believe the root cause is uncontrolled complexity. Attempts to introduce simplicity by mindlessly adding abstraction layers are ultimately counterproductive. Simplicity is best achieved by lowering feature count and flexibility." Now, I feel less lonely. :)

UnixJunkie avatar Sep 02 '20 07:09 UnixJunkie