[HN Gopher] XiangShan - open-source high performance RISC-V proc...
___________________________________________________________________
XiangShan - open-source high performance RISC-V processor
Author : gjvc
Score : 108 points
Date : 2025-01-02 17:08 UTC (5 hours ago)
(HTM) web link (github.com)
(TXT) w3m dump (github.com)
| fithisux wrote:
| Bravo guys! Tremendous piece of work.
| paulsutter wrote:
| It important to be aware of the significant progress that China
| is making in AI, robotics, and processors, and admirable that
| they are open sourcing so much of it.
|
| It's great work and an inspiration
| nine_k wrote:
| Quite possibly the open-sourcing is a part of the success
| story. The Chinese culture is built around incessant
| reproducing and gradual improvement, which dates back at least
| to the times of Confucius. Some think it's mindless
| copycatting, but it's more about learning deeply and then
| standing on others' shoulders. It's the "fork this" attitude
| that meshes quite well with open source, but is understandably
| infuriating for IP-licensing / patents crowd.
|
| This doesn't mean that the openness extends easily to those
| outside China, its culture, and especially its language though.
| bpfrh wrote:
| I don't see that much opensource coming from china.
|
| For example the popular arm rockchip offerings are so bad at
| contributing to mainline linux or even sharing documentation
| that the single person supporting them dropped it due to lack
| of fund and being unable to get any contact to share
| documentation.
|
| IMHO, chinese opensource does at best the same thing many
| western companies do:
|
| Opensource the things that are not you secret sauce/income,
| or things which would benefit you if people adopt them.
|
| With the added caveat that china in generally is notorious
| for not abiding by patent laws and copying.
| wakawaka28 wrote:
| Indeed, the Chinese often violate open source licenses and
| outright steal proprietary code from non-Chinese companies.
| holoduke wrote:
| Huggingface rings a bell? 80% is coming from chinese
| reaearch.
| nine_k wrote:
| I suspect that Rockchip has better documentation in
| Chinese, which may be not easy to locate if you're not
| fluent in Chinese and are not inside China.
|
| Upstreaming the kernel support has never been a breeze for
| any ARM designs, IIRC. But the custom kernels are GPL [1],
| aren't they?
|
| [1]:https://github.com/radxa/rockchip-bsp
| Barrin92 wrote:
| >The Chinese culture is built around incessant reproducing
| and gradual improvement
|
| all successful cultures are, they're just divided on whether
| they admit it or not. Germany was late to industrialization
| and a lot of our businesses went to Britain under the
| pretense of doing business and copied chemical plant factory
| layouts one-to-one, but we like the "we're the country of
| engineers and thinkers" story much better than "we were a bit
| slow and ripped the British and French off".
|
| The Chinese just don't pretend. I've spent a lot of time in
| China and around FB's attempted Snapchat acquisition in tech
| circles there used to be the joke that FB is the most Chinese
| American company because of Zuckerberg's relentless copying.
| The valley works the exact same way, they're just more likely
| to pretend everything is the result of some boy genius making
| it up.
| lenerdenator wrote:
| Isn't RISC-V FOSS to begin with?
| gdiamos wrote:
| The instruction set is, not necessarily the implementation.
| Arnavion wrote:
| That said, an open ISA certainly invites people amenable to
| open-sourcing their implementations, which is why more
| exist for RISC-V than for x86 or ARM.
| m3kw9 wrote:
| What's the strategy in open sourcing this?
| slongfield wrote:
| They presented at HotChips 2024:
| https://www.youtube.com/watch?v=4_R0S6piLA0&t=2114s
|
| There, one of the things they mentioned was that they were
| hoping that RISC-V in general, and their cores in particular,
| becomes a platform for academic research. That way, cutting-
| edge things are shared in the open and the industry benefits
| globally.
|
| The optimistic view of this is that it's hoping for a better
| future for all. The cynical view is that open source is much
| harder to sanction/export control. The truth is probably
| somewhere in the middle.
| blackeyeblitzar wrote:
| The strategy is to do PR for China, market for adoption (to
| break chip duopoly), get contributions (free work), and build
| momentum to a point where the tech is commoditized (so they can
| be immune to sanctions).
| szundi wrote:
| Other motive could be to undermine western dominance in chip
| design. You give away free a good enough thing that is
| competing with your competitor's moat. If the gap is not that
| significant this can ruin the business for your competitor.
|
| You can see the same with Apple and all big tech funding
| OpenStreetMap for example vs Google Maps. Even decreasing
| income for the competitor is worth it strategically. Or Satya
| Nadella saying in an interview that if ChatGPT just makes
| Google's costs higher for search is a big win for Microsoft.
| crvdgc wrote:
| Realistically, it's probably the group inside the Chinese
| Academy of Sciences wanting for a larger impact factor for
| their review, similar to all other state sponsored researching
| institutes.
| camel-cdr wrote:
| If anyone wants to play arround with simulating it, here is a
| Dockerfile I use: # Dockerfile FROM
| ubuntu:24.04 RUN apt-get update && apt-get install
| -y build-essential clang libclang-dev llvm-dev cmake libspdlog-
| dev vim git curl wget time default-jre default-jdk RUN
| git clone --recursive https://github.com/OpenXiangShan/xs-env
| WORKDIR /xs-env RUN sed 's/apt\S* install/\0
| -y/g;s/source /. /g;s/sudo //g' -i ./*.sh RUN . ./env.sh
| && sed 's/\/master/\/master/g;s/$/; cd \/xs-env/g' -i ./update-
| submodule.sh && ./update-submodule.sh RUN .
| ./env.sh && ./setup-tools.sh RUN . ./env.sh && .
| ./install-verilator.sh RUN . ./env.sh && sed 's/^git
| submodule.*$//g;s/env.*$//g' -i ./setup.sh && . ./setup.sh
| RUN . ./env.sh && make -C XiangShan init RUN . ./env.sh
| && cd DRAMsim3 && mkdir build && cd build && cmake -D COSIM=1 ..
| && make -j 8 RUN . ./env.sh && make -C XiangShan emu
| CONFIG=DefaultConfig WITH_DRAMSIM3=1 MFC=1 -j 8 RUN
| . ./env.sh \ && sed
| 's/unknown-//g;s/rv64gc/rv64gcv/g' -i $AM_HOME/am/arch/*.mk
| $AM_HOME/am/arch/isa/*.mk \ && sed 's/define
| MSTATUS_FS.*$/define MSTATUS_FS 0x6600/g' -i
| $AM_HOME/am/src/*/isa/riscv/boot/*.S WORKDIR
| nexus-am/apps/hello RUN make ARCH=riscv64-xs
| # $NOOP_HOME/build/emu --no-diff -i ./build/hello-riscv64-xs.bin
| 2>/dev/null
|
| Make sure you have 64GB of RAM. I only had 16GB, but allocating
| additional 48GB of swap worked.
|
| There are probably some redundant steps, but this worked for me
| last time I tried.
| ge96 wrote:
| why so much ram?
| chrsw wrote:
| 64GB of RAM isn't that much for full chip simulation of a
| "high performance" CPU.
| ge96 wrote:
| yeah I'm super ignorant here, wondering, say you simulated
| this, could you run a VM OS against it? What kind of scale
| it it, personal computer or server (i7/xeon)?
|
| Or you just use it to compile programs against it?
|
| edit: I did skim the readme, I saw verilog makes me think
| FPGA
| chrsw wrote:
| You could simulate this on an FPGA platform, those aren't
| going to be cheap to hold a large design. Usually by
| running simulations on a PC you're just running very
| specific test cases.
|
| I've run CPU simulations on machines with 64GB of RAM
| before and it took several hours just to get to single-
| user shell in Linux. Different CPU design and computer,
| but the point is it's not something you'd typically use
| interactively.
| IshKebab wrote:
| That's a pretty huge amount of RAM even for a high
| performance core. The medium performance cores I've
| simulated use more like 300MB.
|
| I suspect it is the Scala compilation that requires all the
| RAM rather Verilator or the simulator.
| chrsw wrote:
| Maybe, I've never used Scala before. But in my experience
| simulations are way more resource intensive than
| compilation.
| luyu_wu wrote:
| I posted a link to this project a few weeks ago as well! It's
| really interesting to see an academic project like this one.
|
| For people interested, there's bi-weekly blogs (some in English)
| linked here: https://docs.xiangshan.cc/zh-cn/latest/blog/
| omolobo wrote:
| Free hardware is the dream. I want to replace the proprietary,
| DRM-bloated CPU on my PC yesterday.
| luyu_wu wrote:
| Here is a commercial product using the older 'Nanhu' architecture
| by XiangShan. Doesn't seem to be released yet, but interesting
| nonetheless!
|
| https://milkv.io/ja/ruyibook
___________________________________________________________________
(page generated 2025-01-02 23:00 UTC)