Oil3 / runmetal

fork ofPython + Apple Metal Framework = ?

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

runmetal: Apple Metal(GPU) Framework caller

  • numpy array -> GPU buffer -> compute -> copy result into numpy array

requirements

  • macOS
  • Xcode (or CommandLineTools)
    • Metal Framework
  • Python 3.x

install

(python)

  • brew install pyenv
  • pyenv install 3.7.1

(venv)

(released version)

  • pip install runmetal

usage(runmetal command)

Usage: runmetal [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  compile
  lsdev
  mtlinfo
  run
  • compile
    • precompile source in YAML to .metallib
    • ... may not work (depends on your environment)
  • lsdev
    • list GPU device
  • mtlinfo
  • run
    • run recipe

examples(YAML)

  • pi
    • calculate π by monte carlo
      • numpy.random.random()
      • -> copy numpy to GPU buffer
      • -> compute sqrt(x*x+y*y) < 1.0
      • -> copy GPU buffer to numpy bool8 array
      • numpy.sum(result == True)/len(result)*4
    • runmetal run example/pi.yaml
  • rand
    • random number generator (LCG)
    • runmetal run example/rand.yaml

examples(python)

About

fork ofPython + Apple Metal Framework = ?


Languages

Language:Python 78.2%Language:Jupyter Notebook 12.2%Language:C 8.0%Language:Go 1.6%