Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V extension #75

Open
liangkaiwang opened this issue Oct 31, 2021 · 18 comments
Open

V extension #75

liangkaiwang opened this issue Oct 31, 2021 · 18 comments

Comments

@liangkaiwang
Copy link

Does the current version support the vector extension?

I try running this:

riscv64-unknown-elf-gcc main.c asm_func.s -o ./a.out -march=rv64gcv
and getting this:

Assembler messages:
Error: cannot find default versions of the ISA extension v' /var/folders/qk/896_3mtn7ls3t09tdm0lr2jr0000gn/T//ccIFKgs2.s:3: Error: cannot find default versions of the ISA extension v'
Assembler messages:
Error: cannot find default versions of the ISA extension `v'

@GPSBabelDeveloper
Copy link

GCC trunk doesn't support draft extensions. V is in the very final ("weeks"? There's a big RISC-V conference in early December that may help push things along) stages of support, but it's not final so it can't go in GCC trunk.

There are various forks in vendor chains (sifive, allwinner/alibaba) that support some given draft of V, but it's kind of a messy since there is no silicon at this time that supports V because a ratified version of V doesn't exist.

SiFive produces Mac binaries for their cores, but the V support is mostly for their own customers doing silicon work with their cores or on a simulator. See https://lists.riscv.org/g/tech-vector-ext/message/364

Since the various drafts of V are incompatible with each other, prepare to be meticulous about matching whatever V support is produced by whatever branch you find with whatever V support is supported by your emulator or whatever pre-release version is supported by your use case.
Nezha/C906 is about the only volume device with V at all and it's draft version 0.7.1. Andes and CSky also have their own branches for whatever vendor extensions (it's not official RISC-V V since that doesn't exist yet as of this writing) that you may need to chase down. They are, of course, somewhat incompatible with each other.

It's probably still too much of a wild west for Homebrew. Someday, 1.0 will be passed and it'll get integrated into GCC upstream. See Jim's comments in https://lists.riscv.org/g/tech-vector-ext/topic/74053961?p=Created,,,20,2,0,0 for one of the many discussions on how messy this situation is. Until then, integration really is left to those working with prerelease drafts.

@sbeamer
Copy link
Collaborator

sbeamer commented Dec 17, 2021

Thank you @GPSBabelDeveloper for your thorough and very correct comment!

Yes, the homebrew only pulls from the riscv-gnu-toolchain repo, and even that sometimes doesn't quite keep up anymore. Perhaps it is time to build from gcc proper such as #36.

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Dec 17, 2021

You're welcome. Keeping all the parts of the chain in sync has been a problem since I first started messing with GNU chain builds in the late 80's. On some obscure target, GCC does something AS doesn't like. On another, AS does something LD doesn't like. On a third, LD does something GDB doesn't like, etc... (We had this close to home about this time last year when I was the first one that tried this tap on M1 and we got into trouble with host OS issues, while a relevant patch had been upstreamed for a while, but we were too old for that change to work so we just dropped a big hammer on it.)

My guess is that people doing RISC-V work on a Mac are probably capable of building their own packages and doing the integration themselves. (Maybe Homebrew helps installing dependencies...) Slotting in development builds of any of them individually would be dangerous, but building the four I mentioned earlier (I don't use their libc, so I can't speak there) from release trees independently from their sources and then overlaying the install either via a different --exec-prefix that's $PATHed first (doesn't always work) or one that's on an fsoverlay (do Macs even have that?) would let the packages seem like merges.

Even THAT only helps with #36 and not #75. Here, assuming the person is on real (not simulated) hardware needed a GCC from another vendor completely and it's not all clear that you can just match that willy-nilly with its other siblings. Mixing a Allwinner V0.7.1 GCC would require an allwinner assembly to eat the new opcodes, a new debugger to display the V registors, and a new libc-like substance to provide the macro-op magic needed to represent loops in V.

Time has changed the nature of this question, though. The previous remains true. You still need Allwinner's tools to work with D1 and D1s and those are about to become Very Popular devices now that they're $11 boards using a V that GCC, etc. has no interest in supporting. However, V 1.0 was ratified last week (Maybe early this week.) and Vector 1.0 support should now be the NEXT release of all the GNU stuff.

I've heard that LLVM is further along in integration (i.e. auto loop vectorization) but I don't know their stance on the old, should-be-unsupported-but-now-we-have-to 0.7.1.

To make it extra ugly, getting the 071 chain from T-Head requires signing an NDA and pulling it from China, with all that entails. I haven't seen the source separately, but maybe once someone extracts the source of those RPMS or APKs, distribution for other hosts gets easier.

GCC 12 comes in a few momths and should have V. By approximately then, Binutils and GDB should have new releases in the queue or already fired to handle the missing pieces. RISC-V parts are gonig to be powerful enough to run Linux on them natively; anyone developing Linux code can just use that set. Developers of other OSes still ned their own Mac-native ports. For your own sanity, unless you want to start offering completely alternative versions of everything in this package, I'd just wait for the dust to settle and answer "when GNU releases have them we will , too." It's just messy out there.

Even with a prod, our OP hasn't said exactly what they want to generate.

@victoryang00
Copy link

See my homebrew-riscv.

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Dec 23, 2021 via email

@hossein1387
Copy link

hossein1387 commented Feb 8, 2022

@victoryang00

I installed riscv-gnu-toolchain using brew reinstall --build-from-source riscv-gnu-toolchain and I was hoping to be able to compile for a vector machine. However, It seems the command above does not enable the vector extension and I am keep getting errors like this:

Error: cannot find default versions of the ISA extension v

Here is my build command:

/opt/homebrew/bin/riscv64-unknown-elf-gcc -mcmodel=medany -march=rv64gcv -mabi=lp64d -static -std=gnu99 -O3 -ffast-math -fdiagnostics-color=always -g simple_vector_add.c -o simple_vector_add

Any suggestions on?

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Feb 8, 2022 via email

@hossein1387
Copy link

Thanks for your answer, Is there any homebrew tap that I can use? I tried to compile LLVM with vector extension using instructions provided in Ara: https://github.com/pulp-platform/ara
it worked perfectly on a linux machine but on my Mac, it fails when it tries to compile toolchain-llvm-rt: https://github.com/pulp-platform/ara/blob/ede4c58bf6a4153b0adba7f3561800383e9b4ca8/Makefile#L95

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Feb 8, 2022 via email

@hossein1387
Copy link

Thanks again for your reply. Here is the error log when I try to compile llvm-rt:
error_llvm_rt.log

Keep in mind that r Ara is a 64-bit Vector Unit, compatible with the RISC-V Vector Extension Version 0.10. And again, I am able to compile llvm and llvm-rt on a linux machine but I get the above error when I try to compile it on my Mac (I have a Mac with M1 chip).

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Feb 8, 2022 via email

@victoryang00
Copy link

For D1 board, you could just download T-head toolchains with options -march=ck806, they have other modifications to the spec other than VExt.

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Feb 8, 2022 via email

@GPSBabelDeveloper
Copy link

GPSBabelDeveloper commented Feb 10, 2022 via email

@rkabrick
Copy link

Hello! Sorry to resurrect this... Just wanted to clarify:

Is there a homebrew command that will use this tap in conjunction with the LLVM trunk for V-extension support? I apologize if this is a dumb question, I am not at all familiar with homebrew beyond brew install

@victoryang00
Copy link

Hello! Sorry to resurrect this... Just wanted to clarify:

Is there a homebrew command that will use this tap in conjunction with the LLVM trunk for V-extension support? I apologize if this is a dumb question, I am not at all familiar with homebrew beyond brew install

No, but I could make a homebrew formula using https://chocopy-llvm.github.io/chocopy-llvm/#/common/build.

@rkabrick
Copy link

rkabrick commented May 26, 2022 via email

@victoryang00
Copy link

If it’s not too much trouble that would be fantastic! :)

On Thu, May 26, 2022 at 03:10 victoryang00 @.> wrote: Hello! Sorry to resurrect this... Just wanted to clarify: Is there a homebrew command that will use this tap in conjunction with the LLVM trunk for V-extension support? I apologize if this is a dumb question, I am not at all familiar with homebrew beyond brew install No, but I could make a homebrew formula using https://chocopy-llvm.github.io/chocopy-llvm/#/common/build. — Reply to this email directly, view it on GitHub <#75 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHT3VHOXUS75LQPARQOJK23VL4PWPANCNFSM5HCRQ4EA . You are receiving this because you commented.Message ID: @.>

checkout https://github.com/victoryang00/homebrew-riscv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants