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]
    in fact, the amdgpu-pro implementation doesn't have these problems. I just think its sad that AMD doesn't upstream their improvements, its the least they could do really.
    Troels Henriksen
    @athas
    I think AMD has more or less ditched their own OpenGL/Vulkan stack and just use Mesa on Linux.
    Snektron
    @snektron:matrix.org
    [m]
    Anyway
    For my current iteration of the parser generator stuff, i generate a module that a parser module accepts. That module defines some other modules in turn, like which type is used to represent productions, for example.
    The thing is though, that i only use that module structure because i'd like to use those types to index some generated arrays, so i pretty much only use to_i64
    Do you think there's a way around that, or should i just take the L and keep the module structure?
    (the types are unsigned, which is why i can't use them as indices already)
    Troels Henriksen
    @athas
    What is the problem?
    You don't need an module just to carry a single type.
    Snektron
    @snektron:matrix.org
    [m]
    I'd like to call to_i64 on the type so i can use it as an array index
    Troels Henriksen
    @athas
    Your top module could just include
    type t
    val to_i64 : t -> i64
    No need for a module.
    Or if you want to abstract it futher:
    type t
    val index [n] 'a : [n]a -> t -> a
    Snektron
    @snektron:matrix.org
    [m]
    I'd like to not have to have that module at all, and just say "use this value as index"
    For signed values, this is already possible, but i have some unsigned values as well
    Troels Henriksen
    @athas
    I think you need to show me some code. I have a hard time visualising this.
    Snektron
    @snektron:matrix.org
    [m]
    While thinking of an example i realized one needs to have a module anyway to restrict a type parameter

    I was originally thinking of something like

    let index [n] 't 'i (ts: [n]t) (index: i) = ts[i]

    but that won't compile regardless

    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab

    @Gusten_Isfeldt_gitlab Also, be careful in general. I never finished implementing proper synchronisation for accumulator operators that cannot be implemented with hardware atomics (basically, primitive operators).

    @athas would this manifest as incorrect results, and if so, would the errors in general be small, like missed values in the accumulation?

    Troels Henriksen
    @athas
    @Gusten_Isfeldt_gitlab Yes, that seems like a likely outcome.
    Especially if you get the right results with the c backend.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    To be clear, I have not yet confirmed this. At the moment precise results are not critical in a sense, since I am not creating true production data. As long as the visuals are good enough for my presentations, it's okay, basically.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    (now I also have a scapegoat if an obvious artifact turns up in my presentation)
    Troels Henriksen
    @athas
    What are you visualising?
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    particle coordinates. The potential error is in the particle interaction.
    I will both show the particles in a simulation box and some more condensed statistics. Neither is particularly sensitive to errors, in terms of how they look.
    Troels Henriksen
    @athas
    That's the nice thing about graphics.
    Even the bugs can be attractive.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Yes, particularly in raytracing, though this is not.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    let lj (sigma:f32) (epsilon:f32) (r:f32) =
        let sdr = sigma/r
        let sdr2 = sdr*sdr
        let sdr6 = sdr2*sdr2*sdr2
        let sdr12 = sdr6*sdr6
        in 4*epsilon*(sdr12-sdr6)
    
    let k_B:f32 = 8.617333262125e-5  -- eV/K
    
    let p T V = f32.exp (-V/(k_B*T))
    
    let sigma:f32 = 1
    
    let epsilon:f32 = 1
    
    let n:i64 = 100
    
    let rs = tabulate n (\i -> 3*sigma* f32.from_fraction i n)
    
    let vs = map (\r -> let v = lj sigma epsilon r in (v, p 300 v)) rs
    
    let rvs = zip (zip rs rs) vs
    
    -- > :plot2d rvs

    results in

    Internal compiler error (unhandled IO exception).
    Please report this at https://github.com/diku-dk/futhark/issues
    After sending command ["store","/tmp/futhark-server-read1763236-1","out0"] to server process:fd:330: hGetLine: end of file
    Server process exited unexpectedly with exit code: -11
    Server stderr:
    
    CallStack (from HasCallStack):
      error, called at src/Futhark/Server.hs:141:7 in futhark-0.20.0-7O7l1SWHThQFOpbzz8q8kj:Futhark.Server

    What am I doing wrong?

    oh, I see it now...
    the x and y values should not be zipped
    after changing that I get
    > :plot2d rvs failed:
    Invalid data file produced by Futhark server.
    futhark: testplot-img: getDirectoryContents:openDirStream: does not exist (No such file or directory)
    Troels Henriksen
    @athas
    That should not happen.
    Troels Henriksen
    @athas
    @Gusten_Isfeldt_gitlab The error message is of course awful, but the problem is that the expression you have to pass to plot2d must be of some type ([]t, []t), where t is some kind of numeric type.
    That part is documented. futhark literate is just terrible at handling errors.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    The documentations says it can also handle records of said type, but I had no luck with that either.
    let rs = tabulate n (\i -> 3*sigma* f32.from_fraction i n)
    
    let vs = map (lj sigma epsilon) rs
    let ps = map (p 300) vs
    
    let rvs = {potential = (rs, vs), probability = (rs, ps)}
    -- > :plot2d rvs
    Internal compiler error (unhandled IO exception).
    Please report this at https://github.com/diku-dk/futhark/issues
    After sending command ["store","/tmp/futhark-server-read1951878-1","out0"] to server process:fd:330: hGetLine: end of file
    Server process exited unexpectedly with exit code: -11
    Server stderr:
    
    CallStack (from HasCallStack):
      error, called at src/Futhark/Server.hs:141:7 in futhark-0.20.0-7O7l1SWHThQFOpbzz8q8kj:Futhark.Server
    Troels Henriksen
    @athas
    I have no clue why that makes the server process segfault. I can't reproduce that part.
    I see. This is because records are not exposed in the C API. If you want to plot records, you need to use a record expression directly in the directive: :plt2d {potential = (rs, vs), probability = (rs, ps)}.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    ah, I see
    Troels Henriksen
    @athas
    These are the kinds of sharp edges that make futhark literate a bit of a clumsy tool.
    It's really a hack.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    Maybe one day it won't be(to the same extent)
    Troels Henriksen
    @athas
    There's no deep reason this can't be fixed, but it would take some time to define a protocol for how to communicate values of more complex types.
    The C interface actually supports obtaining the raw data (in the binary data format) underlying any opaque value. What would be needed is a description of how those parts map to the high-level type.
    This would be interesting for sum types, but not so hard for records.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    For now as long as I know how it works, it's ok.
    Gusten Theodor Isfeldt
    @Gusten_Isfeldt_gitlab
    -- > :plot2d { potential=(rs, vs) , probability = (rs, ps) }
    fails with
    unexpected space
    expecting '='
    removing all the whitespace in the record declaration works
    but my guess is that it is not supposed to be whitespace-sensitive