guzba / crunchy Goto Github PK
View Code? Open in Web Editor NEWSIMD-optimized hashing, checksums and CRCs.
License: MIT License
SIMD-optimized hashing, checksums and CRCs.
License: MIT License
For the minimum example of using osdialog
and crunchy
together by running
nimble c -r -d:osdialogGtk3 test.nim --verbose
in a directory with:
# test.nim
import crunchy
import osdialog
# test.nimble
version = "0.1.0"
author = "Tilmann Bartsch"
description = "Testing osdialog + crunchy"
license = "MIT"
requires "osdialog == 0.1.2"
requires "crunchy == 0.1.8"
the following error message is printed:
/tmp/test/test.nim(1, 8) Warning: imported and not used: 'crunchy' [UnusedImport]
/tmp/test/test.nim(2, 8) Warning: imported and not used: 'osdialog' [UnusedImport]
CC: ../../.nimble/pkgs/nimsimd-1.2.5/nimsimd/runtimecheck.nim
/home/user/.cache/nim/test_d/@m..@[email protected]@[email protected]@[email protected]: In function ‘cpuid__OOZOOZOnimbleZpkgsZnimsimd4549O50O53ZnimsimdZruntimecheck_19’:
/home/user/.cache/nim/test_d/@m..@[email protected]@[email protected]@[email protected]:130:30: error: expected ‘)’ before ‘:’ token
130 | asm(" cpuid\n"
| ~ ^
| )
131 | :"=a"(eaxr), "=b"(ebxr), "=c"(ecxr), "=d"(edxr)
| ~
Error: execution of an external compiler program 'gcc -c -w -fmax-errors=3 -g -Wall -Wextra -std=c99 -pedantic -g -Wall -Wextra -std=c99 -pedantic -I/usr/include/gtk-3.0 -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-4 -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/libxml2 -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/gio-unix-2.0 -I/usr/include/cloudproviders -I/usr/include/atk-1.0 -I/usr/include/at-spi2-atk/2.0 -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/at-spi-2.0 -pthread -I/home/user/opt/nim-1.6.12/lib -I/tmp/test -o /user/.cache/nim/test_d/@m..@[email protected]@[email protected]@[email protected] /user/.cache/nim/test_d/@m..@[email protected]@[email protected]@[email protected]' failed with exit code: 1
Error: Execution failed with exit code 1
... Command: /home/user/opt/nim-1.6.12/bin/nim c --noNimblePath -d:NimblePkgVersion=0.1.0 --path:/home/user/.nimble/pkgs/osdialog-0.1.2 --path:/home/user/.nimble/pkgs/crunchy-0.1.8 --path:/home/user/.nimble/pkgs/nimsimd-1.2.5 -r -d:osdialogGtk3 test
As stated in the title, on ARM (e.g. Apple M1 in my case) the SIMD implementation of Adler32 does not compile due to missing bindings for some NEON instructions.
Minimal reproducible example:
import std/strutils, crunchy
echo adler32("test").toHex
Expected output:
045D01C1
Actual output:
/Users/edisile/.nimble/pkgs/crunchy-0.1.2/crunchy/adler32_simd.nim(156, 17) Error: undeclared identifier: 'vld1q_lane_u32' candidates (edit distance, scope distance); see '--spellSuggest': (2, 6): 'vst1q_lane_u32' [func declared in /Users/edisile/.nimble/pkgs/nimsimd-1.2.2/nimsimd/neon.nim(115, 6)]
Related:
import pixie
echo readImage("test.bmp")
Hi Guzba,
i've benchmarked the sha256 agains
nimcrypto and the openssl implementation:
import crunchy, benchy, strutils
let data = "The quick brown fox jumps over the lazy dog".repeat(10_000_000)
echo data.len.formatSize()
timeIt "crunchy sha256":
keep crunchy.sha256(data)
import nimcrypto
timeIt "nimcrypto sha256":
keep nimcrypto.sha256.digest(data)
import strutils
const SHA256Len = 32
proc SHA256(d: cstring, n: culong, md: cstring = nil): cstring {.cdecl, importc.}
proc SHA256(s: string): string =
result = ""
let s = SHA256(s.cstring, s.len.culong)
for i in 0 ..< SHA256Len:
result.add s[i].BiggestInt.toHex(2).toLower
timeIt "openssl sha256":
keep SHA256(data)
i compile with:
nim c -d:ssl --passl:-lcrypto --passl:-lssl -d:release -d:allowSimd --gc:arc --opt:speed -d:lto -r "c:\Users\david\projects\nimPlayground\crunchyt.nim"
410.08MiB
name ............................... min time avg time std dv runs
crunchy sha256 .................. 2119.437 ms 2190.603 ms ±110.765 x3
nimcrypto sha256 ................ 1885.133 ms 1886.219 ms ±1.623 x3
openssl sha256 ................... 958.929 ms 973.808 ms ±14.016 x6
My cpu:
# Get-WmiObject -Class Win32_Processor -ComputerName. | Select-Object -Property [a-z]*
Name : Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
NumberOfCores : 4
NumberOfEnabledCore : 4
NumberOfLogicalProcessors : 8
import crunchy/adler32
let data_bytes : seq[byte] = newSeq[byte](32)
echo adler32(data_bytes)
error : SIGILL: Illegal operation
my environment :
cpu : AMD Phenom II X4 970
instructions sets : MMX (+), 3DNow! (+), SSE, SSE2, SSE3, SSE4A, x86-64, AMD-V
nimble list -i :
crunchy [(version: 0.1.9, ... ]
nimsimd [(version: 1.2.6, ... ]
nim -v :
Nim Compiler Version 2.1.1 [Windows: amd64]
Compiled at 2023-12-24
gcc --version :
gcc (MinGW-W64 x86_64-ucrt-posix-seh, built by Brecht Sanders) 13.2.0
os : Win10pro-64bit 22H2
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.