sb0 changed the topic of #m-labs to: ARTIQ, Migen, MiSoC, Mixxeo & other M-Labs projects :: fka #milkymist :: Logs http://irclog.whitequark.org/m-labs
paul___ has joined #m-labs
paul___ has quit [Client Quit]
paul___ has joined #m-labs
paul___ has quit [Client Quit]
paul___ has joined #m-labs
paul___ has quit [Client Quit]
kristianpaul has joined #m-labs
kristianpaul has quit [Client Quit]
kristianpaul has joined #m-labs
kristianpaul has quit [Quit: leaving]
kristianpaul has joined #m-labs
_whitelogger has joined #m-labs
kristianpaul has quit [Quit: leaving]
kristianpaul has joined #m-labs
klickverbot has quit [Ping timeout: 240 seconds]
sb000 has joined #m-labs
<sb000>
whitequark: you forgot the playback trigger slowness
<whitequark>
I didnot
<whitequark>
just the wrong keyword for github
<whitequark>
sb000: there's a problem though
<whitequark>
we are currently unable to create user-defined objects on the core device
<whitequark>
so that will have to be implemented first
<whitequark>
which is what I'm doing
sb000 has quit [Ping timeout: 260 seconds]
sb000 has joined #m-labs
<sb000>
is that a lot better than using integers?
sb000 has quit [Client Quit]
<whitequark>
um
<whitequark>
that's the only way to make it safe, I think
kilae has joined #m-labs
klickverbot has joined #m-labs
mumptai has joined #m-labs
<whitequark>
hrm, user-defined objects are a really hairy thing
<whitequark>
I think I should do some stopgap solution...
rohitksingh has joined #m-labs
<whitequark>
hm, there's nothing I'm super happy about
klickverbot has quit [Ping timeout: 260 seconds]
<whitequark>
the "file descriptor" solution is bad (there's an ABA problem); the "handle" solution is bad (object creation is quite hard, and addresses leak into ARTIQ Python land); the shared BTreeMap solution is bad (the people asking for fast replay will not be happy with mandatory string lookup)
<whitequark>
well, whichever way we go, safety in ARTIQ Python is more or less forfeited. e.g. adding two CoreDMA devices makes it quite easy to crash the DMA core, at least.
<whitequark>
actually, hm
<whitequark>
that's still memory-safe for now, and you can't crash the SoC anymore, but with DMA input events I think it will not be safe.
<whitequark>
I *suppose* we could make it safe for DMA input events by restricting that to some region of memory.
<whitequark>
anyway, I digress.
sb0 has joined #m-labs
rohitksingh has quit [Read error: Connection reset by peer]
<sb0>
whitequark, what ABA problem exactly? if you use the counter trick it's fine, no?
<sb0>
it's only "unsafe" because users can modify the integers manually, right?
<sb0>
but a wrong integer would only result in a detectable error, or some random DMA sequence being played, afaict
futarisIRCcloud has quit [Quit: Connection closed for inactivity]
rohitksingh has quit [Quit: Leaving.]
<whitequark>
ABA problem: let's say I give an integer to the user, then they erase it, then they get another handle, which is for a different sequence but happens to make the old one valid
<whitequark>
that is very hard to debug
<whitequark>
unsafe: it's probably safe as long as we only have playback
<whitequark>
it's probably not going to be safe once we have DMA input
<GitHub>
[artiq] cjbe commented on issue #668: Lets close it - I still think absolute imports are really useful, but this is not the right way of doing it.
kilae has quit [Quit: ChatZilla 0.9.93 [Firefox 52.0.2/20170323105023]]
klickverbot has joined #m-labs
<klickverbot>
whitequark: I'm sure you thought this through, but couldn't you completely avoid the ABA issue in practice (i.e., unless you keep a handle alive for more than a year but cycle the others with kHz rate or something like that) with an epoch tag in the descriptor?
<klickverbot>
(This is assuming that the handles are opaque on the Python side, which seems to be the only sane design decision, but I see how implementing user-defined value types might be tricky)
<whitequark>
klickverbot: well, yes, we don't have user-defined types constructable on the ARTIQ Python side
<whitequark>
value types or non-value types
<whitequark>
and what this requires is a control flow analysis to ensure that every field is initialized
<whitequark>
and that is not a project for one evening
<klickverbot>
Yah, that's what I meant. And as for initialization, you can possibly cheat by only allowing default construction (with all fields explicitly given)
<whitequark>
I don't think that works
<whitequark>
I don't actually see any way to implement that without adding some sort of implicit default value
<whitequark>
for every type
<klickverbot>
Why not? Of course, you need a canonical list of fields somewhere (which is usually implicit in Python), but if you have type Foo with fields a and b, you only ever allow Foo(a, b)
<klickverbot>
The (trivial) constructors then can't unwind, etc., so you don't have that sort of issue
<whitequark>
if you have a __init__ then semantics diverges
<whitequark>
if you don't have a __init__ then Foo(a, b) is invalid
<whitequark>
also, the constructor is the key for type inference here, I am quite sure
<klickverbot>
Oh, right, forgot about that. Make it artiqpy.make(Foo, a, b) or something like that then
<whitequark>
ew.
<whitequark>
no.
<whitequark>
that's not even significantly less work
<whitequark>
I have to add an AST (or IR) matcher for this construct, verify every corner case...
<whitequark>
it's not an evening project either
<whitequark>
conversely, verifying that all fields are initialized isn't *that* hard, it's just a lattice
<whitequark>
we actually already do that for variables
<klickverbot>
You don't need control flow analysis, and I assumed "intrinsics" like that were cheap to add. But of course, if you can do a proper job with the other option, it might be preferrable
<whitequark>
intrinsics are cheap to add, but this isn't an intrinsic
<klickverbot>
Hm, true (already doing it for variables)
<klickverbot>
I guess you are referring to needing to match/look up the type parameter on the AST level for that make construct?
<whitequark>
it's just a really weird construct overall
<whitequark>
like it's not that it doesn't fit, it's that it duplicates machinery that's already there
<whitequark>
all we're missing hs proper handling of the __init__ function
<klickverbot>
Not if you come from a language with generics – make!Foo(a, b) would be natural in D (or make<Foo>(a, b) in C++). But yeah, I agree that your proposal is probably better, since you can just constrain the admissible programs to fit your CFA (and are already doing that anyway)
<whitequark>
um, no
<whitequark>
in a language with generics type-level and value-level parameters are separate
<whitequark>
unless it's dependently-typed but those are a whole separate bag of hell
<klickverbot>
Of course (well, it's type- *and* value-level for one of them in C++/D, s/generics/templates/ if that's closer to your favourite terminology), but as I amused to reading that style of code, the make(Foo, …) thing just parses as the Python equivalent of that
<klickverbot>
(From my personal experience only of course, but that's one after reading lots of D and modern C++ code, and working on compilers for both)
<klickverbot>
Anyway, no non-trivial destructurs and being able to do with quite limited CFA definitely changes my feeling from "you don't want to be doing this" to just "not a project for one evening". So: Have fun. ;P
<klickverbot>
(Hmm, another bad idea for just requiring a trivial __init__: Use a class decorator that is recognized by the compiler and just generates the corresponding __init__ for regular Python. Probably still not worth it, though.)