Page MenuHomeFreeBSD

[BHND] create custom CTZ & popcount functions for cross-compilation
AbandonedPublic

Authored by mizhka on Mar 16 2016, 10:56 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 23 2024, 10:10 AM
Unknown Object (File)
Jan 10 2024, 4:49 AM
Unknown Object (File)
Dec 22 2023, 11:06 PM
Unknown Object (File)
Nov 23 2023, 4:55 PM
Unknown Object (File)
Nov 22 2023, 12:58 PM
Unknown Object (File)
Nov 12 2023, 12:56 AM
Unknown Object (File)
Oct 13 2023, 3:49 PM
Unknown Object (File)
Oct 11 2023, 8:11 PM
Subscribers

Details

Summary

There are platforms without support of CTZ & popcount. To compile BHND for MIPS, new custom functions are implemented.

Performance of functions seems to nice, but additional tests are welcome!

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

mizhka retitled this revision from to [BHND] create custom CTZ & popcount functions for cross-compilation.
mizhka updated this object.
mizhka edited the test plan for this revision. (Show Details)
mizhka added reviewers: landon_landonf.org, adrian.
mizhka set the repository for this revision to rS FreeBSD src repository - subversion.

Minor issues aside, LGTM.

@adrian Should we lift out the portable ctz32 for general use? If so, do you have any suggestions on where? cdefs.h? The __bitcount*() macros that already exist don't really belong in types.h:

/*
 * The following are all things that really shouldn't exist in this header,
 * since its purpose is to provide typedefs, not miscellaneous doodads.
 */
sys/dev/bhnd/bhndb/bhndb_private.h
225

I'd like to see this default to __builtin_ctz when available, similar to LZ4_FORCE_SW_BITCOUNT in sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.c

sys/dev/bhnd/bhndb/bhndb_subr.c
402

There's a set of __bitcount* macros in sys/types.h that use __builtin_popcount when available, and fall back to inline portable definitions.

Hm, is this stuff being called often enough to justify this custom popcount/bitcount stuff?

Hi @adrian

This stuff is called rare, but builtin_ctz, builtin_popcount are undefined in case of cross-compilation under MIPS.

ok. how do I reproduce these being undefined during cross compile? I'd like to fix that bit first. :)

Hm.. just try to compile bhnd under MIPS.

Possible way:
I'm using freebsd-wifi-build scripts (thank you for freebsd-wifi-build!!!) : https://github.com/Cka3o4Huk/freebsd-wifi-build/blob/asusrtn16/build/cfg/asusrtn16
../freebsd-wifi-build/build/bin/build asusrtn16 buildkernel
FreeBSD commit with fix: https://github.com/Cka3o4Huk/freebsd/commit/0bcce4188936eeb2696cd51734ce9eef1b5cd928

You can try to checkout both and revert particular patch. But to be honest, I'm not sure that this commit is compilable :(