7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Intel Mac と M2 Mac を比較する

Last updated at Posted at 2023-08-07

はじめに

先日 M2 Mac が手元に届いたので、今まで使っていた Intel Mac とパフォーマンスを比較してみます

2019 モデルと 2022 モデルであり、メモリも違うので単純比較はできませんが、、、

あくまでも私のメモ用ということで

どの程度の差が出るのか Livebook で検証してみます

実行する処理

Nx の様々なバックエンドによる行列の加算処理を計測の対象とします

Benchee.run によって、IPS(Instructions Per Second 1秒間に何回処理を実行できたか)を計測します

bench = fn backend ->
  tensor =
    {200, 200}
    |> Nx.iota(type: :f64, backend: backend)

  Nx.add(tensor, tensor)
end
Benchee.run(%{
  "binary" => fn -> bench.(Nx.BinaryBackend) end,
  "exla" => fn -> bench.(EXLA.Backend) end,
  "torchx" => fn -> bench.(Torchx.Backend) end,
  "evision" => fn -> bench.(Evision.Backend) end
})

詳細な内容は以下の記事を参照してください

Nx.BinaryBackend を使っている場合は単純に Elixir で 40,000 回足し算を行っています

Evision.Backend なら OpenCV 、 EXLA.Backend なら XLA を使った行列演算を実行しています

Intel Mac

実行環境は以下の通りです

  • MacBook Pro 13 inch, 2019
    • macOS Ventura 13.5
    • CPU 2.4 GHz クアッドコアIntel Core i5
      (物理的には 4 コア、 Hyperthreading による擬似 8 コア)
    • メモリ 16 GB
  • Elixir 1.15.4
  • Erlang 26.0.2
  • Livebook 0.10.0

Elixir と Erlang は asdf でインストールし、 Livebook は GitHub からタグ指定でクローンしてきたコードをローカルビルドしています

実行結果は以下のようになりました

バックエンド IPS
binary 79
evision 2,560
exla 8,090
torchx 5,880

M2 Mac

実行環境は以下の通りです

  • MacBook Pro 13 inch, 2022
    • macOS Ventura 13.5
    • CPU Apple M2
      8 コア(パフォーマンス: 4、効率性: 4)
    • メモリ 24 GB
  • Elixir 1.15.4
  • Erlang 26.0.2
  • Livebook 0.10.0

Elixir と Erlang は asdf でインストールし、 Livebook は GitHub からタグ指定でクローンしてきたコードをローカルビルドしています

実行結果は以下のようになりました

バックエンド IPS
binary 152
evision 5,910
exla 12,490
torchx 8,800

比較

Intel Mac と M2 Mac の比較表は以下のようになります

バックエンド Intel Mac IPS M2 Mac IPS M2 / Intel
binary   79 152 1.92
evision   2,560 5,910 2.31
exla   8,090 12,490 1.54
torchx   5,880 8,800 1.50

BinaryBackend 、つまり単純な足し算のループでは 2 倍近い差がありました

そして、 evision = OpenCV は 2 倍を超える結果に

まとめ

単純な計算によるものではありますが、明らかに M2 Mac で高速化していますね

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?