Code Monkey home page Code Monkey logo

crunchy's People

Contributors

dreamflow avatar guzba avatar simonkrauter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

crunchy's Issues

compile error when using [email protected] and [email protected]

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

os-release.txt

SIMD Adler32 does not compile on ARM

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:

  • Pixie is also impacted by this issue, when compiling the following code the same error is triggered.
    import pixie
    echo readImage("test.bmp")
  • Pull request with the missing bindings for the nimsimd package: guzba/nimsimd#4

benchmark

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                    

adler32 crashes on inputs > 31 bytes

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.