Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Orestis
    @omhepia:matrix.org
    [m]
    not sure how to reduce it....
    Snektron
    @snektron:matrix.org
    [m]
    Why can i not index arrays with an unsigned type?
    Troels Henriksen
    @athas
    @snektron:matrix.org you can, but you cannot slice with them: https://github.com/diku-dk/futhark/pull/1245#issuecomment-775504691
    Snektron
    @snektron:matrix.org
    [m]
    i wasn't trying to, the issue was probably a complicated type checking case. I wanted to radix sort an array of u32 indices, and passed as get_bit function (\bit index -> i32.get_bit values[index])
    The compiler seems to restrict the possible types 't of radix_sort to any signed type due to the use of index as an array index
    Troels Henriksen
    @athas
    Hm.
    Snektron
    @snektron:matrix.org
    [m]
    no biggie to just use a cast there, but it was a bit confusing
    Troels Henriksen
    @athas
    You are right, the types must be signed.
    I don't remember the reason. It may be that since indexes are perceived as i64 in the core language, there would be trouble if you passed a a huge unsigned number that could not be represented as an i64.
    Snektron
    @snektron:matrix.org
    [m]
    that makes sense
    one idea might be to use some kind of "representable-as-i64-without-loss" semantic
    Snektron
    @snektron:matrix.org
    [m]
    Got the parser working :) parses 400 KB of test input with a very simple grammar in about 10 ms on a titan xp
    it could probably be improved though, but at least something works now
    Troels Henriksen
    @athas
    Is that fast? I would have guessed Futhark is a terrible language for writing parsers.
    Snektron
    @snektron:matrix.org
    [m]
    I'm not quite sure, i should probably write a sequential cpu parser and see what the difference is
    10ms is definitely pretty fast, but the cpu version took 0.6 sec and i feel like that could be faster
    Snektron
    @snektron:matrix.org
    [m]
    i did a bit of analysis, i think for the cpu case it comes down to to two things
    • my use of a radix sort somewhere, which is probably the largest part. I was kind of expecting that, and there are apparently faster algorithms (parallel bracket matching)
    • there are multiple passes done over the input in some cases, which could actually be merged i think
    i haven't checked whether the generated C code merges those two loops, but its basically a map in one function, and then a call to another function with a map and a reduce
    the latter map and reduce are fused fine, however
    i'm also doing a lot of table lookups which are emitted as match/cases, which i see are generated as if/else chains. I would think that c compilers can deal with that fine but maybe thats also a limitation
    snektron
    @snektron:matrix.org
    [m]
    my guess is the rotate (-1) i put for mapping in pairs makes those loops not fusable
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    I was trying out literate futhark, and got this:
    let f32greyscale min max v =
        let r = u32.f32 <| trace <| f32.round (255 * (v - min) / (max - min))
        let g = r
        let b = r
        let a = 255
        in r << 24 ^ g << 16 ^ b << 8 ^ a
    
    
    entry testImg a b
        = tabulate_2d a b (\i j -> f32.sin (f32.from_fraction i 100)
                                      * f32.sin (f32.from_fraction j 100))
        |> map (map (f32greyscale (-1) 1))
    
    -- > :img testImg 1000 500
    $ futhark literate redtest.fut
    Internal compiler error (unhandled IO exception).
    Please report this at https://github.com/diku-dk/futhark/issues
    After sending command ["restore","/tmp/futhark-server-write3472946-1","const0","i32"] to server process:fd:330: hGetLine: end of file
    Server process exited unexpectedly with exit code: 1
    Server stderr:
    ./redtest: Unknown type i32
    Troels Henriksen
    @athas
    Yes, sharp edges. In this case, no type inference. That 1000 and 500 are interpreted as i32, not i64, and since the program doesn't use i32 in any of its entry points, the compiled program doesn't even know the type well enough to give a good error message.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Ah, so that's it, thanks
    Troels Henriksen
    @athas
    That's bad, but honestly futhark literate should do a bit of dynamic type checking, because it can perfectly well interrogate the program to find the expected types.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    It's really neat to have this easy image output though. Really helps for hacking together presentations.
    Troels Henriksen
    @athas
    Yes, I agree. The cost/benefit ratio on futhark literate turned out really nice.
    It doesn't do a lot, but neither was it hard to build or maintain.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    I will give at go for a homework assignment later. I think I will try to do the full report in futhark.
    Troels Henriksen
    @athas
    Actually, my design target for futhark literate is exactly that it can be used by the students in our parallel functional programming course to do their reports.
    It's not there yet. It doesn't do benchmarking or anything of the sort.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    In my case it's overkill already
    Troels Henriksen
    @athas
    Right now it's mostly used for READMEs with graphics: https://github.com/nqpz/flowamok/
    Snektron
    @snektron:matrix.org
    [m]
    If only my uni had a parallel functional programming course
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    The course is in polymerphysics and all we are supposed to are some monte-carlo simulations of the conformations
    The primary target is chemists with almost no programming experience
    Snektron
    @snektron:matrix.org
    [m]
    Cool application
    Troels Henriksen
    @athas
    Yeah, that's pretty cool. Would you do the visualisations with literate Futhark?
    I've also considered a variant (futhark script) that is only about the side effects of directives (reading and writing images), not about the generation of a document.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Yeah, just some simple plots, possibly some histogram
    But I suppose I might cram an animation in there for fun
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    What is the logic behind the numbering of the images produced by futhark literate? I've got odd numbers starting at 3 so far, and when I removed some it now starts at 13.
    Troels Henriksen
    @athas
    It's an implementation detail. Internally, futhark literate splits the file into high-level parts (code sections, text paragraphs, directives) and the image numbering is just the part index.
    That could be done better, but I'd also like to do some content-aware addressing to avoid regenerating images needlessly. In that case, the file name would be some nasty hash.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Ok
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Is it possible to load values from a file into a literate futhark program?
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    what I'd like to do is to store some data in one program and restore it in another. The data is pretty expensive to generate and there are parameters to test so I'd like to decouple the generation of it from the rest
    The examples I see only use simple futhark expressions, and none of the futhark script specific syntax
    Troels Henriksen
    @athas
    Not yet, but I do want to add that.
    If you can encode your data as an image, then you can use $loadimg!