dzaima / CBQN

a BQN implementation in C
GNU General Public License v3.0
329 stars 46 forks source link

Mention packaging in GNU Guix #45

Closed yewscion closed 2 years ago

yewscion commented 2 years ago

Hello,

CBQN is now packaged for GNU Guix.

It might be worthwhile to add a note saying as much to README.md, to spread awareness that manual compilation is unnecessary if a user wants to use CBQN.

If a user has GNU Guix installed, they only need to run the following command to install and then use CBQN, eliminating all other setup needed by the user: guix install cbqn. It is currently tested on x86_64 and confirmed working (by me and our CI backends), but not for aarch64 due to an issue with a dependency of librsvg (gdk-pixbuf-query-loaders) failing to build properly (outside of my control and experience).

There is a badge that can be utilized if You prefer; it looks like this: Packaged in GNU Guix If You'd like to use it, feel free to add it as a file to Your repo so it doesn't move around; It is licensed under GPLv3/FDLv1.3, which is compatible with this project.

dzaima commented 2 years ago

Given that CBQN is also on (at least as far as my knowledge goes) nixpkgs and AUR, I'd want some uniform listing across those, probably just links in some section (also mentioning WinBQN).

The running page currently has this information (including what I guess might be outdated now? "and bqn in development Guix (not 1.3.0)"), but it might be worth moving to here? @mlochbaum

yewscion commented 2 years ago

That makes sense to me, just wanted to report that it is in the distribution now for the most part.

Incidentally, GNU Guix is a rolling release distribution; though there are unstable/user channels You can add, the 'development' version of GNU Guix would probably be some branched-off version that only <10 people use.

The releases are more about OOTB experience than they are about versioned updates a la Ubuntu or Fedora.

I guess what I'm saying is that it's fine to drop the "development" qualifier, if You want.

mlochbaum commented 2 years ago

So presumably you download Guix 1.3.0 and then update the packages? The Guix website completely fails to mention anything about rolling release as far as I can tell.

mlochbaum commented 2 years ago

Here's my understanding of the package situation. Is this correct?

The package has been built for the architectures listed under "Builds:" but has only been tested on x64_64. Installing just downloads the binary but an advanced user would be able to figure out how to build from source with bqn.scm, and possibly get it running on other architectures that way. bqn.scm defines a few packages including cbqn and dbqn, but none of them are called bqn.

mlochbaum commented 2 years ago

Planning to add this table to running.md. I think it has everything a user of one of these OSs would want to know? The Nix and Guix packages bootstrap the bytecode but I wouldn't expect someone downloading to care whether this step has been done by dzaima or the packager.

OS/distro Package Type Singeli
Windows download WinBQN Binary No
Arch AUR cbqn-git Source No
Nix cbqn Binary No
Guix cbqn Binary Yes
yewscion commented 2 years ago

Let me outline a few things, as a person who uses GNU Guix as my daily driver:

yewscion commented 2 years ago

@mlochbaum That looks fine to me, aside from the Binary/Source concern in my last two bulletpoints above.

mlochbaum commented 2 years ago

Yeah, it's pretty much the same as Nix, and if I had gone with that background knowledge I wouldn't have been confused. The website is very misleading with how it keeps saying version 1.3.0 everywhere (it doesn't matter!) and describes it as a "standalone Guix System" when the thing you actually care about are the latest packages, which won't be included.

mlochbaum commented 2 years ago

Wait, is there only one build for generic x86-64? The Singeli code is only used if AVX2 is enabled at compile time, so it's kind of useless if that's the case.

dzaima commented 2 years ago

Wait, is there only one build for generic x86-64? The Singeli code is only used if AVX2 is enabled at compile time, so it's kind of useless if that's the case.

Been trying to understand that right now too; the o3n-singeli target includes -march=native (which is fine for a local build, but definitely not appropriate for a downloadable binary release), and singeli means it requires the x86-64 extension AVX2 (i.e. won't compile on older CPUs, or non-x86-64 ones); that is to say, o3n-singeli can only be used for a local build on the CPU you'll run it on, and only on modern x86-64; unless guix can specialize for that, staying on o3 is best for now (though it will come with losing many optimizations)

yewscion commented 2 years ago

Interesting, I was unaware of these particulars when I packaged CBQN before. Reaching out to see if I can get some advice; Might submit a patch to fall back to o3. Is o3-shared alright to use in this case, or do the AVX2 extensions impact that as well?

yewscion commented 2 years ago

Will be amending the package to default to o3, but will also add a separate transformation for o3-singeli compatible machines. Are there other targets that might be useful in specific situations? I can likely add them with the same patch… But I'm pretty unfamiliar with some of the referenced options (like I was with AVX2, my bad, there).

yewscion commented 2 years ago

In particular, perhaps the targets should be the single-* varieties instead? The README seems to suggest it may be more optimized. I'm also unfamiliar with -g.

mlochbaum commented 2 years ago

The other target we're using is BMI2, and we're likely to use PCLMUL and FMA3 in the future. All of these are included in most CPUs with AVX2. I think -march=haswell (maybe with -mtune=icelake-client?) is the setting to use.

-march=native queries the architecture it's currently being built on, which means the fact that you're able to get reproducible builds out of it is confusing. I guess Guix probably overrides this somehow?

The improvement with single-* is going to be pretty minor if it's there. But then the reason not to use it is that it doesn't allow incremental builds, which you're not going to do. I guess I'd say to not use it just to get a more "standard" build.

dzaima commented 2 years ago

o3-shared is a generic build, okay for binary releases; -g is only for debugging purposes; single-* ideally shouldn't give many performance benefits, I should re-check and update the readme (they're largely there for hypothetical situations where the makefile or incremental builds don't want to work).

o3-singeli isn't a valid configuration currently, though make singeli=1 f='-mavx2 -mbmi2 -O3' c is an alternative that does that (i.e. targeting & requiring x86_64+AVX2+BMI2, i.e. all current optimization targets; it appears that AVX2 without BMI2 currently doesn't compile), without being just -march=haswell which presumably doesn't go well on AMD CPUs, but of course would stop being optimal when FMA3 or PCLMUL are targets.

pre-compiled binaries and x86-64 extensions don't go together (and the alternative of runtime architecture detection probably won't come for some time either).

yewscion commented 2 years ago

Yeah, I think the override might have to do with -mtune, though I haven't looked for this in the source.

Copy that, maybe I should submit a patch to include the following packages, then:

All three will have a lib target in addition to the default out target, so the user to install the shared library should they desire. For now, this will use o3-shared, but the hooks will be there for future optimization should the shared library fragment similarly to the binary.

As for the single-* builds, it looks like they are analogous to the non-single anyway, perhaps I could define a single target for each package that uses single-o3 or single-c as appropriate, including the manual flags mentioned above?

dzaima commented 2 years ago

haswell is for modern intel CPUs (i.e. 4th generation or later, which is from 2013), but I don't think it's worth having it when the more generic -mavx2 -mbmi2 is an option; FMA3 and PCLMUL shouldn't be mentioned, they currently aren't used by CBQN, and it isn't even a given that by the time they are they'll be checked at compile-time anyway.

single-* builds are too much hassle for insignificant gain; they're not exactly analogous, and don't support Singeli (as it generates static functions with equivalent names, requiring them to be across multiple compilation units).

yewscion commented 2 years ago

Copy that, then, how about one package with the following outputs, then:

yewscion commented 2 years ago

For Your Awareness, Patch submitted: https://issues.guix.gnu.org/58100