Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    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!
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    But could you use that data in the program?
    In this case ideally I would train at network in one program and apply it in another. Well I can deal with in haskell instead for now, but it would be nice for testing.
    Troels Henriksen
    @athas
    But right now it has to be as an image, which is clumsy.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Yes, that is rather inconvenient
    I mean, technically you can encode anything as an image...
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    By the way that program is pretty neat. The effect works surprisingly well.
    Troels Henriksen
    @athas
    I didn't come up with the algorithm, but I did try to create a non-optimal more parallel version.
    It has some artifacts. I suspect the sobel kernel I use for computing energy gradients is not a good choice.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Do you write somewhere when the C-header changes? Sometimes I don't work with the libraries for a while and notice later that Futhask can no longer handle it for whatever reason. It hasn't been difficult to fix or anything, but if there are any other users of Futhask, I kind of feel bad about not maintaining it properly. I suppose what I really should do is set up some proper testing, but the breakages haven't been frequent enough for my lazy self to do that.
    Troels Henriksen
    @athas
    I treat it as a breaking change, so it will be under Changes in CHANGELOG.md and only happen for major releases.
    At least I hope that's the case...
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Ah, that's good to know
    Troels Henriksen
    @athas
    I actually take the C API stability much more seriously than the language itself, which is also why I'm reluctant to add short-term convenient hacks to it.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    I very much appreciate that.
    My approach to 'testing' has basically been, if it can handle my program, it probably works.
    Snektron
    @snektron:matrix.org
    [m]
    We have some large matches on sum types (without any payload) in our code, and futhark compiles these to if-else chains
    after some investigation, it turns out that gcc and clang (at least for the c backend) don't seem to optimize those into lookup tables
    What would be the best way to get something like that?
    I assume just let A = 0 let B = 1 let C = 2 .... and let lut = ['A', 'B', 'C']