Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance of gemm_strided vs numpy #23

Open
timotheecour opened this issue Jan 30, 2019 · 1 comment
Open

performance of gemm_strided vs numpy #23

timotheecour opened this issue Jan 30, 2019 · 1 comment

Comments

@timotheecour
Copy link

python

time python $timn_D/tests/nim/all/t0147.py
1000.0
python $timn_D/tests/nim/all/t0147.py  5.26s user 0.13s system 293% cpu 1.840 total
import numpy as np
p=1000
a=np.ones((p,p))
b=np.ones((p,p))

for i in np.arange(100):
  c=np.matmul(a,b)

print(c[0,0])

laser

nim c -d:release -d:case2 $timn_D/src/timn/apps/laser.nim
time $timn_D/src/timn/apps/laser
1000.0
$timn_D/src/timn/apps/laser  5.35s user 0.03s system 99% cpu 5.405 total
import pkg/laser/primitives/matrix_multiplication/gemm

when defined(case2):
  proc test =
    # todo: different numbers
    let p1 = 1000
    let p2 = p1
    let p3 = p1

    type T = float

    var a = newSeq[T](p1 * p2)
    for i in 0..<a.len: a[i] = 1.0
    var b = newSeq[T](p2 * p3)
    for i in 0..<b.len: b[i] = 1.0
    var c = newSeq[T](p1 * p3)

    for i in 0..<100:
      gemm_strided(
        p1, p2, p3, # CHECKME ; not sure if order correct, would be nice to document M,N,K in `gemm_strided`
        1.0,
        a[0].addr, p1, 1,
        b[0].addr, p2, 1,

        0.0,
        c[0].addr, p1, 1,
      )
    # echo a
    # echo b
    echo c[0]

test()
@timotheecour
Copy link
Author

need
-d:openmp -d:release

... and then need to fix on my system the paths to avoid this: /bin/sh: /usr/local/bin/gcc-7: No such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant