Better HN
topnewbestaskshowjobs
Log inSign up

FullyFunctional

3,566 karma · joined May 8, 2013 (13y ago) · 1,534 submissions

Submissions

comment 4y ago · link · parent

I think you are spot on and it's IMO unfortunate that John overreaches wrt. the benefits of posit as it distracts from the actual major advantages:

* A much more consistent and sane floating point (most arithmetic rules _do_ apply for posits unlike for IEEE Std 754 and you never round to infinity).

* Much greater range and precision for the same bits.

posit32 falls somewhere between floats and double in precision and the hardware implementation will reflect this (which isn't a bad thing given the much higher space efficiency).

I'm not sure about the quire as it looks expensive to me, but I haven't tried implementing it. However what it does provide is pretty remarkable: zero rounding errors for reasonable sized dot-products (IIRC < 2^32 elements).

512.

The Cult of Posits(cs.cornell.edu ↗)

105 points · by FullyFunctional · 4y ago · 72 comments

comment 4y ago · link · parent

Ha, writing a minimalist editor is one of my "hello world" tasks and I've been meaning to redo it in Rust as so many things would be much easier than in C.

The major thing I would want differently, breaking tradition from emacs is not waste the bottom two lines for modeline and a usually-empty prompt line and instead only show it on demand. Emacs can sort of do this, but in my experience, it doesn't work very well.

ADD: I know some HNers feel there's too much Rust here, but let me just add how I love that I can do `cargo install zee` on macOS, FreeBSD, and Linux (AMD64, Arm64, RISC-V) and it just works. Cargo is my favorite package manager (where available).

comment 4y ago · link · parent

Do you have a pointer to Bluespec Classic (not the "modern" Bluespec)?

I would make a distinction between "generator HDLs" like Verilog, Lava, Chisel, MyHDL, nMigen, etc and languages that actually are interpreted as logic (Verilog, Bluespec, Clash, Silice, Handel-C, ...). Yes, Verilog can do both and is a ghastly language. The former class doesn't really raise the abstraction, it just makes generators easier to write.

As I've been saying for decades, I really want a language in which it is as easy to write an implementation as it is to write a [timing] software model; ideally I can use the same language for both! I know it can be done and I have been trying to scratch that itch a few times.

comment 4y ago · link · parent

Indeed why use unsigned? Go take a look at a lot of C code (hint, look at SPEC benchmarks). They do that. Decades of pointer == int == unsigned have let to a lot of horrific code. But we still compile it.

The sins of the original RISC-V was spending too much time looking at RV32 and not realizing how big a problem this is in practice. Zba (slipped in as it’s not really “bit manipulation”) fixes the worst of this.

ADD: The problem in this HN thread is the same reason we got compressed it in the first place. The vast majority of people aren’t doing high performance wide implementation so the true cost isn’t widely appreciated. The people holding the decision power certainly didn’t understand it. I really think you have to live it to understand it.

comment 4y ago · link · parent

This biggest issue is one instruction spanning two cache lines, and even two pages. This means a bunch of tricky cases that is the source of bugs and overheads.

It also means you cannot tell instruction boundaries until you directly fetch instructions, so you cannot do any predecode in the cache that would help you figure out dependencies, branch targets, etc. These things matter when you are trying to fetch 8+ instructions per cycle.

comment 4y ago · link · parent

I am obviously aware and I'm here to tell you that the overhead of variable length instructions matters more. Arm agrees. M1 has a 192 KiB I$ btw.

ADD: had RISC-V just disallowed instructions from spanning cache lines and disallowing jumping into the middle of instructions then almost all of the issues would have gone away. Sigh.

comment 4y ago · link · parent

EDIT: Hmm, I seem to have picked a bad example. Try this one:

    int get(int *base, unsigned index) {return base[index];}
Arm64:

    update:
        ldr     w0, [x0, w1, uxtw 2]
        ret
RV64GC (vanilla):

    update:
        slli    a5,a1,32
        srli    a1,a5,30
        add     a0,a0,a1
        lw      a0,0(a0)
        ret

RV64GC+Zba:

    update:
        sh2add.uw  a0,a1,a0
        lw      a0,0(a0)
        ret
Arm64 is able to do some indexed loads in a single instruction that might take two in RISC-V w/Zba (and up to 4+ in regular RISC-V). However, calling that a win for Arm64 is not so clear as the more complicated addressing modes could become a critical timing path and/or require an extra pipeline stage. However, as a first approximation, for a superscalar dynamically scheduled implementation, fewer ops is better so I would say it's a slight win.

I don't understand the obsession with bytes. 25% fewer bytes has only very marginally impact on a high-performance implementation and the variable length encoding has some horrendous complications (which is probably why Arm64 _dropped_ variable length instructions). Including compressed instruction in the Unix profile was the biggest mistake RISC-V did and I'll die on that hill.

ADD: Don't forget that every 32-bit instruction is currently wasting the lower two bits to allow for compressed, thus any gain from compress must be offset by the 6.25% tax that is forced upon it.

comment 4y ago · link · parent

This comes up a lot and I'm sympathetic to your plea, really (I enjoy fantasizing about a different reality where CPUs weren't just "machines to run C programs"), but in computer architecture, what really matters for one application or a class of applications might not be important when viewed across millions of programs.

The fact is that integer operations and floating point are two completely different beasts, so much so that we have different benchmark suites for each.

Integer operations are critically latency sensitive and bagging on extra semantics doesn't come for free and for most code this would be a tax. The "overflow bit" represents an implicit result that would have to be threaded around (I'm assuming that you aren't asking for exceptions which literally nobody wants). For FP we do that, but the cost and latency of FP ops is already high so it doesn't hurt quite as much.

The RISC-V spec [1] (which I assume you have seen) already discusses all these trade offs:

"We did not include special instruction-set support for overflow checks on integer arithmetic operations in the base instruction set, as many overflow checks can be cheaply implemented using RISC-V branches. Overflow checking for unsigned addition requires only a single additional branch instruction after the addition:

    add t0, t1, t2
    bltu t0, t1, overflow
For signed addition, if one operand’s sign is known, overflow checking requires only a single branch after the addition:

     addi t0, t1, +imm
     blt t0, t1, overflow
This covers the common case of addition with an immediate operand. For general signed addition, three additional instructions after the addition are required, leveraging the observation that the sum should be less than one of the operands if and only if the other operand is negative.

     add t0, t1, t2
     slti t3, t2, 0
     slt t4, t0, t1
     bne t3, t4, overflow
In RV64I, checks of 32-bit signed additions can be optimized further by comparing the results of ADD and ADDW on the operands."

I do think that it might have been worth adding an single instruction version for the last one (excluding the branch), but I'm not aware of it getting accepted.

[1] https://github.com/riscv/riscv-isa-manual

comment 4y ago · link · parent

I'm heavily invested in RISC-V, both personally and professionally, and I think the story is much more complicated than this makes it out to be, but I'm not going to rehash the discussion yet again.

However, I do want to point out that a real issue (especially with legacy code) is the scaled address calculation with 32-bit unsigned values. Thankfully the Zba extension adds a number of instructions that help a lot, but still would require fusion to get complete parity with Arm64

For

    int update(int *base, unsigned index) { return base[index]++; }
We get

    update:
            sh2add.uw  a1,a1,a0
            lw         a0,0(a1)
            addiw      a5,a0,1
            sw         a5,0(a1)
            ret
Zba is included in the next Unix profile and will _likely_ be adopted eventually by all serious implementations.

EDIT: grammar and spacing

comment 4y ago · link · parent

I feel a little sick every time I see this regurgitated; McCarthy's interpreter is not remotely in the same class as Maxwell's equations (and the Church-Turing thesis). It's neither axiomatic, universal, nor minimal. Good ol' lambda calculus does a much better job. For example, here's the lambda calculus self-interpreter [1]

  (\f. (\x.f(xx)) (\x.f(xx)) (\em.m(\x.x)(\mn.em(en)) (\mv.e(mv)))
[1] https://crypto.stanford.edu/~blynn/lambda/

comment 4y ago · link · parent

I immediately looked for haptic feedback support but alas it's not there. I get that it could be abused so I'd want it as an opt-in feature. It's really useful for soft keyboards (of all kinds).

comment 4y ago · link · parent

Thanks for the insight. I'll can try that. Note however that reading from the raw device on the same hardware & OS I hit 5+ GiB/s (IIRC).

comment 4y ago · link · parent

I hope it won't be a decade, but remember the (original) Raspberry Pi launched on a very mature part, with a _very_ mature (ancient) ISA.

Outside the discount pricing, Intel has promised to tape out SiFive's P650. Revos, Tenstorrent, and others are also working on fast cores, but it'll be at least 2-3 years before they hit the market if at all.

So far SiFive's dual issue in-order core (~ 40 GeekBench 5.4.1) (like on now-cancelled BeagleV) is the fastest chip you can buy as a lay person. The D1 (~ 32 GB 5.4.1) is cheaper but less powerful.

comment 4y ago · link · parent

Does anyone actually use dedup? I think even the OpenZFS documentation says compression is more useful in practice. If at all, dedup should be an offline feature, to be run as scheduled by the operator.

My setup tries to get the absolute highest bandwidth and uses NVMe sticks in a stripe (I get my redundancy elsewhere), no compression, no dedup and yet can only hit ~ 3.5 GB/s reads (TrueNAS Core, EPYC 7443P, Samsung 980PRO, 256 GiB). I hope TrueNAS SCALE will perform better.

comment 4y ago · link · parent

Ha, this is awesome, thanks for checking that out. One point of note though, I'm pretty sure it would have been faster to build the kernel + OpenZFS on the Debian/RISC-V in QEMU. QEMU on decent hardware runs very fast and much faster than the D1.

ADD: Geekbench 5.4.1 on RISC-V

- under QEMU/Ryzen 9 3900XT: 82

- under QEMU/M1: 76

- Native D1: 32 (https://browser.geekbench.com/v5/cpu/13259016)

The M1 result is skewed because for some reason AES emulation is much faster on Ryzen. The rest of the integer stuff is faster on the M1, up to 30% faster.

comment 4y ago · link · parent

They (the Fastrack rep) literally told me to wait for days. In my experience there's at least a 24 hour latency.

comment 4y ago · link · parent

That's awful but is pretty much confirming my experience. At the revenue level they have, you'd assume they could do better, but presumably having a monopoly means they don't have to care.

comment 4y ago · link · parent

Ah, that's interesting. I've never heard a beep from any of my transponders, including crossing bridges. Is yours the "gumstick" one? (Thin rectangular one). A beep would be a step in the right direction (but doesn't solve my other grievances).

comment 4y ago · link · parent

Ough, this touches a nerve. The Fastrak system is atrocious and I have been battling it for years. Let me count the ways:

- They took my CC number and just kept replenishing $25 every so often even though it had a big balance already. Thankfully my card expired so now I'm sloooowly (don't drive much anymore) working my way through the $100+ credit on my account.

- It is so hard to check and contest charges. I had to sent in my complaint with snail mail and IIRC it took a month before I got a reply back that requested information that I already wrote in the first letter doesn't apply. I gave up at this point.

- There is _NO_ way to check the transponder short of just using it and waiting a week for the event to show up on the bill. My windshield was apparently blocking radio transmissions (I know why, don't tell me) and experimenting with a different location has a crazy long cycle time due to the above. There days I guess I could do it with a car driving behind me reading what the sign say, but that only works when there isn't much traffic.

I hate Fastrak.

comment 4y ago · link · parent

sorry you are right, that’s what I meant

comment 4y ago · link · parent

FYI, VIA (or whatever it was renamed to) just got acquired by Intel a few months back. I'm long AMD, but I also agree with the analysis that hold INTC a strong buy right now.

comment 4y ago · link · parent

I've been exclusively using my $HOME over NFSv4 across many boxen for years. My NFS is exported by TrueNAS CORE [1] powered by an EPYC 7443P (recent upgrade). I can saturate my 100 GbE (~ 12.6 GiB/s) with NFS traffic.

In my testing, NFS meaningfully but not substantially beat Samba in bandwidth and with much less server load (sorry I didn't keep data).

Even though using a NAS is slower than a native RAID0 of NVMe/PCIeG4 drives, it gives me shared, automatic snapshots, automatic replications, etc. It's totally worth it.

NFSv4 rules.

ADD: [1] TrueNAS SCALE was _just_ released and I'll be evaluating this seriously and expect to migrate to it.

comment 4y ago · link · parent

This is a fascinating topic and is related to the Kolomogorov complexity [1] and the densest I'm aware of is John Tromp's Binary lambda calculus [2]. I don't see a reason why the implementation would be larger than the Java NanoVM.

However programs in the pure λ-calculus are likely to be slower than necessary and I'd go with one enriched with at least basic integers and integer ops.

ADD: yes I know that Kolomogorov just measures self-replication, but I think it's a good proxy for code entropy. At least, I don't know of a better one.

[1] https://en.wikipedia.org/wiki/Kolmogorov_complexity

[2] https://tromp.github.io/cl/Binary_lambda_calculus.html

comment 4y ago · link · parent

I’ve said that repeatedly; the contents is good but it’s needlessly repeated throughout the videos. I feel most of Steves review could be presented in half the time without loosing much. And to be frank, most of the time there is just too much details.

comment 4y ago · link · parent

I wonder how they compare (but I'm not willing to spend hours comparing for myself).

I do note in passing that S2n-QUIC has a really nice set of examples of how to use right up front in the README. All libraries should ideally have that. Without reading anything else, I already have a good idea of how hard it would be to use S2n-QUIC (looks easy).

comment 4y ago · link · parent

Where did the "had no faith in" come from? I had order from them for 20 years. I had faith in them. I had only ever had to return something once before (years ago) and it was fine. This experience wasn't.

I'm reporting my experience and you are attacking the victim. Classy.

comment 4y ago · link · parent

You literally have no idea of what happened, but happily makes assumptions on my part.

comment 4y ago · link · parent

I really didn't want to expose the whole ordeal, but that didn't stop you from assuming you knew the situation. That's really impressive!

I had to badger them every other day because the return label they gave me was wrong and UPS couldn't deliver and kept waiting for an update from them. It sat for ~ 4 days with nothing happening before being returned. I can guarantee you nothing would have happened as every time I spoke with a representative, they were discovering everything anew. I even had to teach them how to use their own tracking tools. Frustratingly, the official UPS site didn't have the same information as their internal site.

comment 4y ago · link · parent

I'm definitely in the camp that worry about the feature/complexity creep. I saw it with Haskell. Haskell 98 is a pretty nice and simple language. GHC Haskell is a monster. This matters when you try to read other people code and the overuse of experimental cool new features becomes a major burden for comprehension.

Rust is already a very large language and for intrinsic reasons pile on a load more complexity than Haskell (just look at the iterators).

I write this as a fan and advocate of Rust.

1
171819
52