Add AArch64 SIMD for Blake, SHA, CRC, XXH3, Argon2, and Adler32#88
Merged
Conversation
- unify TCRCFoldRuntimeCtx32/64 into one TCRCFoldRuntimeCtx (untyped TableRow, same +96 asm layout); collapse the two init builders into one overload - rename fold fns/globals to ISA-neutral names (Lsb->Reflected, Msb->Forward, CRC_Fold_UsesPclmul->CRC_Fold_UsesCarrylessMul) and the 10 CRCFold*.inc files - factor scalar reflected slice into CRC_FoldReflected_OneSlice - rename HlpGF2 -> HlpCRCFoldConstants; merge HlpCRC16/32/64 into HlpCRCStandard (HlpCRC32Fast kept separate) - fix stale .inc header refs (e.g. TConverters.le2me_32) public API (THashFactory.TChecksum.TCRC, TCRCStandard, ICRC) unchanged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds runtime-dispatched AArch64 SIMD implementations across HashLib4Pascal, bringing ARM64 to parity with the existing x86 SIMD tier ladder. Kernels use inline assembly with
.long-encoded vector/crypto instructions for broad FPC assembler compatibility, and are selected at startup via the existing*Dispatch.pas+HlpArmSimdFeaturesinfrastructure.This PR also refactors the CRC fold core (unified runtime context, clearer include naming).
What's new on AArch64
Crypto Extensions (FEAT_SHA*)
HasSHA1()SHA1CompressCryptoExt_aarch64.incHasSHA256()SHA256CompressCryptoExt_aarch64.incHasSHA512()SHA512CompressCryptoExt_aarch64.incHasSHA3()KeccakF1600CryptoExt_aarch64.inc+ absorb variantHasPMULL()CRCFoldForwardPmull_aarch64.inc,CRCFoldReflectedPmull_aarch64.incNEON (Advanced SIMD)
SelectSlot([NEON])Blake2BCompressNeon_aarch64.inc,Blake2SCompressNeon_aarch64.incSelectSlot([NEON])Blake3CompressNeon_aarch64.inc,Blake3Hash4Neon_aarch64.incSelectSlot([NEON])Adler32BlocksNeon_aarch64.incSelectSlot([NEON])XXH3Acc512Neon_aarch64.inc,XXH3InitSecretNeon_aarch64.inc,XXH3ScrambleNeon_aarch64.incSelectSlot([NEON])Argon2FillBlockNeon_aarch64.incScrypt (intentional scalar default)
A verified
ScryptSalsaXor_Neonkernel is included, but dispatch keeps the scalar path on AArch64. Benchmarks on Apple Silicon show scalar wins at every tested N because Scrypt's serial Salsa20/8 chain does not benefit from lane parallelism, while AArch64's 31 GPRs let the scalar kernel avoid spills. This matches upstream practice (OpenSSL/libsodium ship x86 SSE2 Scrypt but no NEON variant).Infrastructure changes
HlpArmSimdFeatures: probes SHA-512, SHA-3, and PMULL; addsDisableAllExtraFeatures()for uniformHASHLIB_FORCE_*override baselinesSimdProc1Begin_aarch64.inc…SimdProc6Begin_aarch64.incunderInclude/Simd/Common/*Dispatch.pasunits; kernel header conventions documented inHashLib.Tests/docs/SimdDispatch.mdandSimdAarch64Headers.mdCRC core refactor (#86, #87)
TCRCFoldRuntimeCtx(fold constants + slicing table rows in one packed record)CRCFoldForwardPclmul_x86_64.inc, etc.)HlpGF2.pas→HlpCRCFoldConstants.pasHlpCRCStandard.pas(replaces separateHlpCRC16/32/64.pasunits)HasPMULL()is true (analogous to x86 PCLMUL/VPCLMUL chain)Other changes
HashLib.Benchmark*convention (no functional change)Architecture
flowchart TD Init["InitDispatch at unit load"] --> Scalar["Assign scalar fallback"] Scalar --> ArmProbe{"AArch64?"} ArmProbe -->|CryptoExt| SHA["HasSHA* / HasSHA3 probes"] ArmProbe -->|NEON tier| NEON["SelectSlot NEON"] ArmProbe -->|PMULL| CRC["HasPMULL for CRC fold"] ArmProbe -->|Scrypt skip| ScryptScalar["Keep Scrypt_SalsaXor_Scalar"] SHA --> Active["Active proc pointer"] NEON --> Active CRC --> Active ScryptScalar --> Active