Newest at the top
2025-03-26 12:19:20 +0100 | <tomsmeding> | Futhark has quite the advantage of having custom syntax and a custom type system. :) |
2025-03-26 12:18:57 +0100 | <tomsmeding> | But this being embedded in haskell, it's clumsy and verbose all around |
2025-03-26 12:18:46 +0100 | <tomsmeding> | They can be used in user code too, of course; the idea there is that it sometimes makes sense to e.g. have a "batch dimension" in your computation that's any length, but then have the actual data dimensions be shape-typed because you're doing interesting things with them |
2025-03-26 12:17:52 +0100 | <tomsmeding> | the downside is that these nested arrays are not actually as flexible as you'd like: the whole thing still has to be rectangular, so it's not very different from a large multidimensional array. |
2025-03-26 12:17:20 +0100 | <Athas> | Mixed arrays sound interesting. Do they work out nicely in practice? |
2025-03-26 12:17:15 +0100 | <tomsmeding> | the goal of that was to support nested arrays too: essentially the trick that Data.Vector.Unboxed does, but then also give a `data instance` for nested arrays. If you nest ranked inside shaped, or the other way round, you end up having to represent the result using an array with mixed type information |
2025-03-26 12:17:09 +0100 | merijn | (~merijn@77.242.116.146) merijn |
2025-03-26 12:16:08 +0100 | <tomsmeding> | ox-arrays, my thing on top of orthotope, supports ranked arrays, shaped arrays, _and_ mixed arrays (indexed by [Maybe Nat]): the natural generalisation of the two |
2025-03-26 12:16:01 +0100 | <Athas> | That's nice. I find fully shaped arrays a bit awkward in Haskell, but ranked should be a nice compromise. |
2025-03-26 12:15:28 +0100 | <tomsmeding> | I linked the ranked one |
2025-03-26 12:15:23 +0100 | <tomsmeding> | orthotope has three copies of the array API: one for ranked arrays (multi-dim. arrays indexed by their rank), one for shaped arrays (~ indexed by their shape, a type-level [Nat]), and one for dynamic arrays (not indexed) |
2025-03-26 12:14:57 +0100 | <Athas> | Oh wait, 'n' is the rank? |
2025-03-26 12:14:30 +0100 | <Athas> | tomsmeding: is 'n' a shape in the multidimensional case? |
2025-03-26 12:14:08 +0100 | <Athas> | I always suspected they'd work fine as a run-time structure for an array library, so I'm happy to see that is the case. |
2025-03-26 12:13:52 +0100 | <Athas> | If you're curious, section 3.1 in https://futhark-lang.org/publications/ifl22.pdf describes how LMADs work in Futhark. |
2025-03-26 12:13:30 +0100 | <tomsmeding> | yes; this is the data type that the user sees https://hackage.haskell.org/package/orthotope-0.1.7.0/docs/Data-Array-Internal-RankedS.html#t:Array |
2025-03-26 12:13:19 +0100 | <Athas> | Ah, I see, so it's just a question of factorisation. |
2025-03-26 12:13:10 +0100 | <tomsmeding> | Athas: the size of the array is also there, one data type higher up |
2025-03-26 12:13:02 +0100 | <tomsmeding> | Athas: horde-ad was originally built on orthotope directly, but it was rather crippled by the fact that orthotope is all-Haskell, and so the stuff that should be fast is actually disappointingly slow |
2025-03-26 12:12:57 +0100 | <Athas> | Actually, there is one difference. LMADs also contain the size of each dimension. How can you get away with not knowing the size of the array? |
2025-03-26 12:11:24 +0100 | <tomsmeding> | I see |
2025-03-26 12:11:20 +0100 | <Athas> | Statically when possible, dynamically when necessary. |
2025-03-26 12:11:06 +0100 | <tomsmeding> | oh so you're doing this dynamically too! I had no idea |
2025-03-26 12:10:56 +0100 | <tomsmeding> | right |
2025-03-26 12:10:47 +0100 | <Athas> | This means you can have a branch where one returns a row-major array and the other a column-major, without any copies being necessary. |
2025-03-26 12:10:44 +0100 | <Athas> | Yeah, lift out the components where they differ. |
2025-03-26 12:10:30 +0100 | <tomsmeding> | "anti-unify"? |
2025-03-26 12:10:09 +0100 | <Athas> | One particularly nice property of this representation is that you can anti-unify representations as long as they have the same rank. |
2025-03-26 12:09:46 +0100 | <haskellbridge> | <Man of Letters> oh yes, it rocks |
2025-03-26 12:09:37 +0100 | <tomsmeding> | I have some nice CPP-generated C code in ox-arrays too. :) |
2025-03-26 12:09:19 +0100 | <Athas> | Hello Man of Letters! |
2025-03-26 12:09:17 +0100 | <tomsmeding> | Athas: cool! |
2025-03-26 12:09:15 +0100 | <Athas> | We used to have a much more elaborate representation than this, but this LMAD/orthotope-strided turns out to be a lot of bang for the buck. |
2025-03-26 12:09:03 +0100 | haskellbridge | Man of Letters is Mikolaj |
2025-03-26 12:08:55 +0100 | <haskellbridge> | <Man of Letters> hello! |
2025-03-26 12:08:46 +0100 | <Athas> | This function (well, the function generated by the macro) inspects the strides at runtime and uses that to pick a good way of copying an array: https://github.com/diku-dk/futhark/blob/master/rts/c/copy.h#L222-L249 |
2025-03-26 12:08:40 +0100 | <tomsmeding> | in any case, this is a "normal" array library in haskell, not using a compilation pipeline, so it's more flexible for integrating into a haskell program |
2025-03-26 12:08:09 +0100 | <tomsmeding> | I can imagine that it doesn't matter much in practice |
2025-03-26 12:07:51 +0100 | <Athas> | There are, actually, in the runtime system! |
2025-03-26 12:07:45 +0100 | <Athas> | Yes, but that doesn't really make much of a difference. |
2025-03-26 12:07:42 +0100 | <tomsmeding> | there are no such stride vectors at runtime any more in Futhark, I presume |
2025-03-26 12:07:25 +0100 | <tomsmeding> | but you do it statically, right? |
2025-03-26 12:07:00 +0100 | <Athas> | Yeah, it's an LMAD. We use the exact same representation in Futhark. |
2025-03-26 12:06:50 +0100 | <tomsmeding> | this probably has a name |
2025-03-26 12:06:37 +0100 | <tomsmeding> | it's this: https://hackage.haskell.org/package/orthotope-0.1.7.0/docs/Data-Array-Internal.html#t:T |
2025-03-26 12:06:13 +0100 | <Athas> | What is that representation? Is it documented anywhere? |
2025-03-26 12:06:09 +0100 | alfiee | (~alfiee@user/alfiee) (Ping timeout: 268 seconds) |
2025-03-26 12:05:55 +0100 | <tomsmeding> | and consumers of arrays can inspect what the actual strides are, to optimise their operation |
2025-03-26 12:05:35 +0100 | <tomsmeding> | replicate and transpose are O(number of dimensions) |
2025-03-26 12:05:20 +0100 | <tomsmeding> | it doesn't, the orthotope strided array representation does |