SlideShare a Scribd company logo
田中昌宏
  Masahiro Tanaka




RubyKaigi2010   2010-8-29   1
   NArrayの開発者
    ◦ NArray developer
   昨年度からつくば市在住
    ◦ I live in Tsukuba since Apr 2009




                                         RubyKaigi2010   2010-8-29   2
   NArrayを使ったサイエンス
    ◦ Science using NArray
   NArrayの概要
    ◦ NArray overview
    ◦ 詳しい話はしません。No details.
   並列分散ワークフロー実行システム
    ◦ Parallel Distributed Workflow System




                                             RubyKaigi2010   2010-8-29   3
RubyKaigi2010   2010-8-29   4
RubyKaigi2010   2010-8-29   5
   http://www.gfd-dennou.org/

   GPhys
    ◦ 多次元物理量表現ライブラリ
    ◦ multi-dimensional physical quantity
      library
   RubyDCL
    ◦ グラフ描画ライブラリ
    ◦ Plotting Graph
   RubyNetCDF
    ◦ 物理データフォーマットNetCDFのIOラ
      イブラリ
    ◦ Physical data format library


                                            RubyKaigi2010   2010-8-29   6
◦ Gtk ベース格子点可
  視化・解析ツール
◦ Gtk-base visualize &
  analysis tool for lattice
  data




                              RubyKaigi2010   2010-8-29   7
◦ Railsベースの地球流体デー
  タベース・解析・可視化ツー
  ル
◦ Rails-base visualize &
  analysis tool for Geophysical
  database




                                  RubyKaigi2010   2010-8-29   8
RubyKaigi2010   2010-8-29   9
   物質科学における、多次元試料データの管理を効率
    的に行う
   For managing multi-dimensional sample data in
    material science.




                                 RubyKaigi2010   2010-8-29   10
波長
位置
光の強さ




            Shin-ichi Todoroki, Meas. Sci.
            Technol. 16 (2005) 285–291

             RubyKaigi2010   2010-8-29       11
RubyKaigi2010   2010-8-29   12
RubyKaigi2010   2010-8-29   13
   電子顕微鏡写真から、生体微小管などの三次元構造
    を構築するためのプログラム
   Program set for Helical image analysis in combination
    with electron microscopy used to study three-
    dimensional structures of microtubules etc.




                                      RubyKaigi2010   2010-8-29   14
画像から構築した3次元構造
                            3-D structure constructed from the EM image

電子顕微鏡写真
Electron Microscope image




                                           RubyKaigi2010   2010-8-29      15
RubyKaigi2010   2010-8-29   16
   http://www.artcompsci.org/~makino/rikigaku/
   A book in dynamics for general readers




                                        RubyKaigi2010   2010-8-29   17
Program and explanation   飛跡の計算結果
                          Result flight trajectory




                               RubyKaigi2010   2010-8-29   18
RubyKaigi2010   2010-8-29   19
RubyKaigi2010   2010-8-29   20
   処理を簡単に書きたい
    ◦ write processing codes shortly
   結果をすぐ確認したい
    ◦ confirm processing result immediately
   インタラクティブな操作もしたい
    ◦ manipulate interactively



                                       RubyKaigi2010   2010-8-29   21
   プログラムが書ける                            – Ruby
    ◦ Programmable
   インタラクティブな実行                          – irb
    ◦ Interactive execution
   データ配列操作                              – NArray
    ◦ Data Array Manipulation
   数値計算ライブラリ
    ◦ Library for Numerical Algorithms
   グラフ表示機能
    ◦ Plotting Graphs

                                                 RubyKaigi2010   2010-8-29   22
   多次元数値配列
    ◦ Numerical N-dimensional Array
   http://narray.rubyforge.org
   http://github.com/masa16/narray




                                      RubyKaigi2010   2010-8-29   23
   0.3.0 – 1999
   0.5.0 – 2000
   0.5.9p7 – 2009 (current version)
   0.7.0 – 20?? (next version, under development)




                                       RubyKaigi2010   2010-8-29   24
   IDL (Interactive Data Language)
   Yorick
   Python Numeric




                                      RubyKaigi2010   2010-8-29   25
   rank
    ◦ 次元数 the number of dimension
   shape
    ◦ 配列の「形」 array shape
   type
    ◦ 要素の型 element type
   memory block
    ◦ データを格納するメモリーブロック



                                    RubyKaigi2010   2010-8-29   26
   Ruby Array :
    ◦ VALUE *ptr; →     value[0]       value[1]    value[2]          value[3]   …

                                       struct RVALUE {
                                         …
                                       }
   NArray
    ◦ void *ptr; →   double[0] double[1] double[2] double[3] …

    ◦           or   int[0]   int[1]     int[2]   int[3]      …




                                                    RubyKaigi2010   2010-8-29       27
   整数                      複素数
    ◦ BYTE (8bit)            ◦ SCOMPLEX (64bit)
    ◦ SINT (16bit)           ◦ COMPLEX
    ◦ INT (32bit)            ◦ = DCOMPLEX (128bit)
   浮動小数点数                  Rubyオブジェクト
    ◦ SFLOAT (32bit)         ◦ ROBJECT
    ◦ FLOAT
    ◦ = DFLOAT (64bit)


                                  RubyKaigi2010   2010-8-29   28
   現版では、ビルトインのみ
    ◦ Current version has Built-in types only
   次版 Next version
    ◦ 後から付け足すことが可能
      Append-able types




                                       RubyKaigi2010   2010-8-29   29
   shape = [4]                        shape = [4,4,4]
    ◦ 1次元配列                             ◦ 3次元配列
    ◦ one-dimensional array             ◦ three-dimensional array
       a[0]   a[1]   a[2]   a[3]

   shape = [4,4]
    ◦ 2次元配列
                                   a[0,0,0]   a[1,0,0]   a[2,0,0]    a[3,0,0]
    ◦ two-dimensional array
                                   a[0,1,0]   a[1,1,0]   a[2,1,0]    a[3,1,0]
     a[0,0] a[1,0] a[2,0] a[3,0]   a[0,2,0]   a[1,2,0]   a[2,2,0]    a[3,2,0]
     a[0,1] a[1,1] a[2,1] a[3,1]
                                   a[0,3,0]   a[1,3,0]   a[2,3,0]    a[3,3,0]
     a[0,2] a[1,2] a[2,2] a[3,2]
     a[0,3] a[1,3] a[2,3] a[3,3]
                                   行列でいう次元とは異なる
                                   Different from Matrix dimension

                                                     RubyKaigi2010     2010-8-29   30
   a[i,j]                                          データが連続する順番
                                                    contiguous order
   左の次元(i)がはやく回る
    ◦ Left dimension(i) is contiguous
    ◦ Fortran-order                                a[0,0] a[1,0] a[2,0] a[3,0]
    ◦ Row-major order
                                                   a[0,1] a[1,1] a[2,1] a[3,1]

    If a.shape == [m,n] then                       a[0,2] a[1,2] a[2,2] a[3,2]
      a[i,j] == a[i+j*m]
                                                   a[0,3] a[1,3] a[2,3] a[3,3]

   a[j][i] と逆 reverse order
   次版では変更予定
    ◦ This will be changed for the next version.


                                                       RubyKaigi2010   2010-8-29   31
NArray.float(3,2)           NArray[[1,2,3],[4,5,6]]
=> NArray.float(3,2):       => NArray.int(3,2):
[ [ 0.0, 0.0, 0.0 ],        [ [ 1, 2, 3 ],
  [ 0.0, 0.0, 0.0 ] ]         [ 4, 5, 6 ] ]

NArray.float(3,2).indgen!   NArray[1..10]
=> NArray.float(3,2):       => NArray.int(10):
[ [ 0.0, 1.0, 2.0 ],        [ 1, 2, 3, 4, 5, 6, 7, 8,
  [ 3.0, 4.0, 5.0 ] ]         9, 10 ]




                                  RubyKaigi2010   2010-8-29   32
   a[1]                         a[0] a[1] a[2] a[3]
    ◦ 要素参照
    ◦ reference by element
   a[1..2]                      a[0] a[1] a[2] a[3]
    ◦ 範囲参照
    ◦ reference by range
   a[[1,3]]                     a[0] a[1] a[2] a[3]
    ◦ インデックス配列参照
    ◦ reference by index array


                                        RubyKaigi2010   2010-8-29   33
   演算は要素ごと
    ◦ Operation is element-wise

                                a*b=   a[0]*b[0] a[1]*b[1] a[2]*b[2] a[3]*b[3]
   演算
    Operations
    ◦ 四則演算
       arithmetic operations
       +, -, *, /, %, **
    ◦ 数学関数演算
       math operations
       NMath module


                                                 RubyKaigi2010   2010-8-29       34
   Float Array with 106 elements
   Ruby 1.9.2 :
      (0...n).map{|i| a[i]*b[i]}
    ◦ elapsed time : 180 ms
   NArray with Ruby 1.9.2 :
      a*b
    ◦ elapsed time : 6.4 ms
   NArray is ~ 28 times faster 28倍速い
   8 times less characters 8倍短く書ける


                                    RubyKaigi2010   2010-8-29   35
NArrayによる性能向上
速度向上の倍率 Speedup factor




                                    Speedup by NArray                                    コードはNArrayのサイト
                         60                                                              にあります
                         50
                         40
                         30
                         20                                                              Speedup by NArray
                         10
                         0
                          0.E+00    2.E+05   4.E+05   6.E+05   8.E+05   1.E+06
                                         データサイズ data size


                                                                         RubyKaigi2010   2010-8-29           36
   NArrayのメモリアクセス                  実際のPCアーキテクチャ
   Memory access for NArray        Actual PC architechture


          CPU                                CPU
                                             core
          core                                                        fast
                         NArray’s          L1 cache
                        Bottleneck
                        ボトルネック
                                          L2 cache
         Main                             Main                        slow

        Memory                           Memory

                                          RubyKaigi2010   2010-8-29          37
CPU Socket       CPU Socket
   CPU     CPU      CPU     CPU      GPU
   core    core     core    core
   cache   cache    cache   cache


       cache            cache

                                    Storage
    Main Memory      Main Memory
Node                                                       Node        Node   …

                                    Network



                                           RubyKaigi2010   2010-8-29              38
   Ruby and NArray
    ◦ コードを書きやすい Easy to write code
    ◦ 複雑さの隠蔽     Hide complexity
       アーキテクチャの違い different architecture
       データの分散       data distribution




                             RubyKaigi2010   2010-8-29   39
   プログラムが書ける                            – Ruby
    ◦ Programmable
   インタラクティブな実行                          – irb
    ◦ Interactive execution
   データ配列操作                              – NArray
    ◦ Data Array Manipulation
   数値計算ライブラリ                            – Ruby/GSL , etc.
    ◦ Library for Numerical Algorithms
   グラフ表示機能                              –?
    ◦ Plotting Graphs

                                                 RubyKaigi2010   2010-8-29   40
   NArrayの各機能
    ◦ NArray functions
   NArrayの使い方
    ◦ NArray usage
   次版NArray
    ◦ Next version of NArray
   他の類似数値配列との比較
    ◦ Comparison with other numerical arrays, e.g. Numpy
   Python が科学分野で主流になりつつある件
    ◦ Python is becoming major in Science field.


                                                   RubyKaigi2010   2010-8-29   41
田中昌宏
                    Masahiro Tanaka
                            筑波大学
                University of Tsukuba




RubyKaigi2010    2010-8-29              42
ワークフローのグラフ
   科学データ処理                                        Workflow graph
    ◦ Scientific data processing
   複雑なワークフローである
    ◦ is a complicated workflow.
   ワークフロー記述言語が必要
    ◦ It needs definition language
   Makefileによる記述が提案
    ◦ Use of Makefile has been proposed
    ◦ e.g. GXP make


                                          RubyKaigi2010   2010-8-29   43
Pwrake

   Rakeによるワークフロー記述を提案
                                                     Process              Process
   We propose defining workflows Rake
                                                                Process
    ◦ Makeより記述力が高い
    ◦ More descriptive power than Make
   Rakeの並列分散拡張として、Pwrake (プレイク)を開
    発
   We are developing Pwrake, a Parallel workflow
    extension for Rake
    ◦ http://github.com/masa16/pwrake

                                         RubyKaigi2010   2010-8-29                  44
   NArrayを使った科学計算の例について紹介
    ◦ Examples of Scientific computing using NArray
   NArrayとその特徴を紹介
    ◦ NArray and its features
   並列分散ワークフロー実行システムPwrake
    ◦ Parallel Distributed Workflow System Pwrake




                                            RubyKaigi2010   2010-8-29   45
   ご質問
   Questions?




                 RubyKaigi2010   2010-8-29   46

More Related Content

PDF
Rubyによるデータ解析
PDF
HistoPyramid Stream Compaction
PDF
Ruby科学データ処理ツールの開発 NArrayとPwrake
PPTX
x86x64 SSE4.2 POPCNT
PDF
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
PDF
周辺知識から理解するMySQL の GIS機能 ~ClubMySQL #4
PDF
Popcntによるハミング距離計算
PDF
【Unity道場スペシャル 2017札幌】乱数完全マスター
Rubyによるデータ解析
HistoPyramid Stream Compaction
Ruby科学データ処理ツールの開発 NArrayとPwrake
x86x64 SSE4.2 POPCNT
GPUが100倍速いという神話をぶち殺せたらいいな ver.2013
周辺知識から理解するMySQL の GIS機能 ~ClubMySQL #4
Popcntによるハミング距離計算
【Unity道場スペシャル 2017札幌】乱数完全マスター

What's hot (16)

PPTX
Away3D 4.1 パーティクル入門
PDF
Oocon2020 presentation slide @kozukorio
PDF
[Basic 1] ブロックチェーンと計算機科学 / ブール代数 / 情報理論
PDF
[Basic 2] 計算機の構成 / プログラム実行の仕組み
PDF
MySQLに本格GIS機能がやってきた~MySQL8.0最新情報~@OSC2018北海道
PDF
Devsumi2010 Ecmascript5 (ISO/IEC JTC1/SC22)
PDF
OpenStreetMap+MongoDBで地図情報を検索してみたい!
PDF
CRC-32
PDF
色々なダイクストラ高速化
PDF
プログラムを高速化する話
PDF
MySQLのGIS機能とか超入門 ~MyNA会2018年7月
PDF
超連射68K 開発日記 -弾幕世代以前の90年代 STG のこと-
PDF
【Unity道場スペシャル 2017京都】乱数完全マスター 京都編
PDF
Wavelet matrix implementation
PPTX
並列化による高速化
PPTX
実践!Django + GraphQL 実装
Away3D 4.1 パーティクル入門
Oocon2020 presentation slide @kozukorio
[Basic 1] ブロックチェーンと計算機科学 / ブール代数 / 情報理論
[Basic 2] 計算機の構成 / プログラム実行の仕組み
MySQLに本格GIS機能がやってきた~MySQL8.0最新情報~@OSC2018北海道
Devsumi2010 Ecmascript5 (ISO/IEC JTC1/SC22)
OpenStreetMap+MongoDBで地図情報を検索してみたい!
CRC-32
色々なダイクストラ高速化
プログラムを高速化する話
MySQLのGIS機能とか超入門 ~MyNA会2018年7月
超連射68K 開発日記 -弾幕世代以前の90年代 STG のこと-
【Unity道場スペシャル 2017京都】乱数完全マスター 京都編
Wavelet matrix implementation
並列化による高速化
実践!Django + GraphQL 実装
Ad

Viewers also liked (20)

PDF
SharePoint Apps - SharePoint Day 2013
DOCX
Guía1 vfinal comentarios gp
PDF
Copy of Business Card Escape Hunt Gold Coast_FINAL copy
PPTX
Merenje duzine
PPT
Conclusion
PPT
PDF
2011 Kia Sportage For Sale Charlotte, North Carolina at Keffer Kia
PPTX
folding immune system
PPTX
ИП и работники
PPTX
My Family - Dylan C
PPT
Healthcare Professionals and Social Media
PDF
Reining in the 4 Ds of Spiraling Application Support Costs
PDF
Capitolo 4
PDF
Pelota al cesto
PPT
Portfolio Essentials: Expectation 1
PPTX
Language aquisition full pres
PPTX
אקטיביזם תקשורתי וירטואלי2
PPTX
Christmas in Catalonia, Spain
PDF
Merion Workflows
PPTX
September 1 speech and writing
SharePoint Apps - SharePoint Day 2013
Guía1 vfinal comentarios gp
Copy of Business Card Escape Hunt Gold Coast_FINAL copy
Merenje duzine
Conclusion
2011 Kia Sportage For Sale Charlotte, North Carolina at Keffer Kia
folding immune system
ИП и работники
My Family - Dylan C
Healthcare Professionals and Social Media
Reining in the 4 Ds of Spiraling Application Support Costs
Capitolo 4
Pelota al cesto
Portfolio Essentials: Expectation 1
Language aquisition full pres
אקטיביזם תקשורתי וירטואלי2
Christmas in Catalonia, Spain
Merion Workflows
September 1 speech and writing
Ad

Similar to NArray and scientific computing with Ruby - RubyKaigi2010 (20)

PDF
無駄にNeo4jを使っている日々
PDF
Webアプリを並行開発する際のマイグレーション戦略
PDF
Rubysapporo Stringsearch
PDF
ScalableCore system at SWoPP2010 BoF-2
PPTX
Prosym2012
PDF
ツイートID生成とツイッターリアルタイム検索システムの話
PDF
PostgreSQL Unconference #29 Unicode IVS
PDF
文字列曖昧検索によるマルウェアバイナリ解析
PDF
kagami_comput2016_06
PDF
Osc shimane-2016-do-postgres-dream-of-graph-database
PDF
JOSUG 34th Meetup
PDF
Ibisml2011 06-20
PDF
準同型暗号の実装とMontgomery, Karatsuba, FFT の性能
PDF
インメモリーで超高速処理を実現する場合のカギ
PDF
textsearch_jaで全文検索
PPTX
Tokyo r39 beginner
PDF
PDF
Hello Dark-Side C# (Part. 1)
PDF
画像認識で物を見分ける
PDF
とあるFlashの自動生成
無駄にNeo4jを使っている日々
Webアプリを並行開発する際のマイグレーション戦略
Rubysapporo Stringsearch
ScalableCore system at SWoPP2010 BoF-2
Prosym2012
ツイートID生成とツイッターリアルタイム検索システムの話
PostgreSQL Unconference #29 Unicode IVS
文字列曖昧検索によるマルウェアバイナリ解析
kagami_comput2016_06
Osc shimane-2016-do-postgres-dream-of-graph-database
JOSUG 34th Meetup
Ibisml2011 06-20
準同型暗号の実装とMontgomery, Karatsuba, FFT の性能
インメモリーで超高速処理を実現する場合のカギ
textsearch_jaで全文検索
Tokyo r39 beginner
Hello Dark-Side C# (Part. 1)
画像認識で物を見分ける
とあるFlashの自動生成

NArray and scientific computing with Ruby - RubyKaigi2010

  • 1. 田中昌宏 Masahiro Tanaka RubyKaigi2010 2010-8-29 1
  • 2. NArrayの開発者 ◦ NArray developer  昨年度からつくば市在住 ◦ I live in Tsukuba since Apr 2009 RubyKaigi2010 2010-8-29 2
  • 3. NArrayを使ったサイエンス ◦ Science using NArray  NArrayの概要 ◦ NArray overview ◦ 詳しい話はしません。No details.  並列分散ワークフロー実行システム ◦ Parallel Distributed Workflow System RubyKaigi2010 2010-8-29 3
  • 4. RubyKaigi2010 2010-8-29 4
  • 5. RubyKaigi2010 2010-8-29 5
  • 6. http://www.gfd-dennou.org/  GPhys ◦ 多次元物理量表現ライブラリ ◦ multi-dimensional physical quantity library  RubyDCL ◦ グラフ描画ライブラリ ◦ Plotting Graph  RubyNetCDF ◦ 物理データフォーマットNetCDFのIOラ イブラリ ◦ Physical data format library RubyKaigi2010 2010-8-29 6
  • 7. ◦ Gtk ベース格子点可 視化・解析ツール ◦ Gtk-base visualize & analysis tool for lattice data RubyKaigi2010 2010-8-29 7
  • 8. ◦ Railsベースの地球流体デー タベース・解析・可視化ツー ル ◦ Rails-base visualize & analysis tool for Geophysical database RubyKaigi2010 2010-8-29 8
  • 9. RubyKaigi2010 2010-8-29 9
  • 10. 物質科学における、多次元試料データの管理を効率 的に行う  For managing multi-dimensional sample data in material science. RubyKaigi2010 2010-8-29 10
  • 11. 波長 位置 光の強さ Shin-ichi Todoroki, Meas. Sci. Technol. 16 (2005) 285–291 RubyKaigi2010 2010-8-29 11
  • 12. RubyKaigi2010 2010-8-29 12
  • 13. RubyKaigi2010 2010-8-29 13
  • 14. 電子顕微鏡写真から、生体微小管などの三次元構造 を構築するためのプログラム  Program set for Helical image analysis in combination with electron microscopy used to study three- dimensional structures of microtubules etc. RubyKaigi2010 2010-8-29 14
  • 15. 画像から構築した3次元構造 3-D structure constructed from the EM image 電子顕微鏡写真 Electron Microscope image RubyKaigi2010 2010-8-29 15
  • 16. RubyKaigi2010 2010-8-29 16
  • 17. http://www.artcompsci.org/~makino/rikigaku/  A book in dynamics for general readers RubyKaigi2010 2010-8-29 17
  • 18. Program and explanation 飛跡の計算結果 Result flight trajectory RubyKaigi2010 2010-8-29 18
  • 19. RubyKaigi2010 2010-8-29 19
  • 20. RubyKaigi2010 2010-8-29 20
  • 21. 処理を簡単に書きたい ◦ write processing codes shortly  結果をすぐ確認したい ◦ confirm processing result immediately  インタラクティブな操作もしたい ◦ manipulate interactively RubyKaigi2010 2010-8-29 21
  • 22. プログラムが書ける – Ruby ◦ Programmable  インタラクティブな実行 – irb ◦ Interactive execution  データ配列操作 – NArray ◦ Data Array Manipulation  数値計算ライブラリ ◦ Library for Numerical Algorithms  グラフ表示機能 ◦ Plotting Graphs RubyKaigi2010 2010-8-29 22
  • 23. 多次元数値配列 ◦ Numerical N-dimensional Array  http://narray.rubyforge.org  http://github.com/masa16/narray RubyKaigi2010 2010-8-29 23
  • 24. 0.3.0 – 1999  0.5.0 – 2000  0.5.9p7 – 2009 (current version)  0.7.0 – 20?? (next version, under development) RubyKaigi2010 2010-8-29 24
  • 25. IDL (Interactive Data Language)  Yorick  Python Numeric RubyKaigi2010 2010-8-29 25
  • 26. rank ◦ 次元数 the number of dimension  shape ◦ 配列の「形」 array shape  type ◦ 要素の型 element type  memory block ◦ データを格納するメモリーブロック RubyKaigi2010 2010-8-29 26
  • 27. Ruby Array : ◦ VALUE *ptr; → value[0] value[1] value[2] value[3] … struct RVALUE { … }  NArray ◦ void *ptr; → double[0] double[1] double[2] double[3] … ◦ or int[0] int[1] int[2] int[3] … RubyKaigi2010 2010-8-29 27
  • 28. 整数  複素数 ◦ BYTE (8bit) ◦ SCOMPLEX (64bit) ◦ SINT (16bit) ◦ COMPLEX ◦ INT (32bit) ◦ = DCOMPLEX (128bit)  浮動小数点数  Rubyオブジェクト ◦ SFLOAT (32bit) ◦ ROBJECT ◦ FLOAT ◦ = DFLOAT (64bit) RubyKaigi2010 2010-8-29 28
  • 29. 現版では、ビルトインのみ ◦ Current version has Built-in types only  次版 Next version ◦ 後から付け足すことが可能  Append-able types RubyKaigi2010 2010-8-29 29
  • 30. shape = [4]  shape = [4,4,4] ◦ 1次元配列 ◦ 3次元配列 ◦ one-dimensional array ◦ three-dimensional array a[0] a[1] a[2] a[3]  shape = [4,4] ◦ 2次元配列 a[0,0,0] a[1,0,0] a[2,0,0] a[3,0,0] ◦ two-dimensional array a[0,1,0] a[1,1,0] a[2,1,0] a[3,1,0] a[0,0] a[1,0] a[2,0] a[3,0] a[0,2,0] a[1,2,0] a[2,2,0] a[3,2,0] a[0,1] a[1,1] a[2,1] a[3,1] a[0,3,0] a[1,3,0] a[2,3,0] a[3,3,0] a[0,2] a[1,2] a[2,2] a[3,2] a[0,3] a[1,3] a[2,3] a[3,3] 行列でいう次元とは異なる Different from Matrix dimension RubyKaigi2010 2010-8-29 30
  • 31. a[i,j] データが連続する順番 contiguous order  左の次元(i)がはやく回る ◦ Left dimension(i) is contiguous ◦ Fortran-order a[0,0] a[1,0] a[2,0] a[3,0] ◦ Row-major order a[0,1] a[1,1] a[2,1] a[3,1] If a.shape == [m,n] then a[0,2] a[1,2] a[2,2] a[3,2] a[i,j] == a[i+j*m] a[0,3] a[1,3] a[2,3] a[3,3]  a[j][i] と逆 reverse order  次版では変更予定 ◦ This will be changed for the next version. RubyKaigi2010 2010-8-29 31
  • 32. NArray.float(3,2) NArray[[1,2,3],[4,5,6]] => NArray.float(3,2): => NArray.int(3,2): [ [ 0.0, 0.0, 0.0 ], [ [ 1, 2, 3 ], [ 0.0, 0.0, 0.0 ] ] [ 4, 5, 6 ] ] NArray.float(3,2).indgen! NArray[1..10] => NArray.float(3,2): => NArray.int(10): [ [ 0.0, 1.0, 2.0 ], [ 1, 2, 3, 4, 5, 6, 7, 8, [ 3.0, 4.0, 5.0 ] ] 9, 10 ] RubyKaigi2010 2010-8-29 32
  • 33. a[1] a[0] a[1] a[2] a[3] ◦ 要素参照 ◦ reference by element  a[1..2] a[0] a[1] a[2] a[3] ◦ 範囲参照 ◦ reference by range  a[[1,3]] a[0] a[1] a[2] a[3] ◦ インデックス配列参照 ◦ reference by index array RubyKaigi2010 2010-8-29 33
  • 34. 演算は要素ごと ◦ Operation is element-wise a*b= a[0]*b[0] a[1]*b[1] a[2]*b[2] a[3]*b[3]  演算 Operations ◦ 四則演算  arithmetic operations  +, -, *, /, %, ** ◦ 数学関数演算  math operations  NMath module RubyKaigi2010 2010-8-29 34
  • 35. Float Array with 106 elements  Ruby 1.9.2 : (0...n).map{|i| a[i]*b[i]} ◦ elapsed time : 180 ms  NArray with Ruby 1.9.2 : a*b ◦ elapsed time : 6.4 ms  NArray is ~ 28 times faster 28倍速い  8 times less characters 8倍短く書ける RubyKaigi2010 2010-8-29 35
  • 36. NArrayによる性能向上 速度向上の倍率 Speedup factor Speedup by NArray コードはNArrayのサイト 60 にあります 50 40 30 20 Speedup by NArray 10 0 0.E+00 2.E+05 4.E+05 6.E+05 8.E+05 1.E+06 データサイズ data size RubyKaigi2010 2010-8-29 36
  • 37. NArrayのメモリアクセス  実際のPCアーキテクチャ  Memory access for NArray  Actual PC architechture CPU CPU core core fast NArray’s L1 cache Bottleneck ボトルネック L2 cache Main Main slow Memory Memory RubyKaigi2010 2010-8-29 37
  • 38. CPU Socket CPU Socket CPU CPU CPU CPU GPU core core core core cache cache cache cache cache cache Storage Main Memory Main Memory Node Node Node … Network RubyKaigi2010 2010-8-29 38
  • 39. Ruby and NArray ◦ コードを書きやすい Easy to write code ◦ 複雑さの隠蔽 Hide complexity  アーキテクチャの違い different architecture  データの分散 data distribution RubyKaigi2010 2010-8-29 39
  • 40. プログラムが書ける – Ruby ◦ Programmable  インタラクティブな実行 – irb ◦ Interactive execution  データ配列操作 – NArray ◦ Data Array Manipulation  数値計算ライブラリ – Ruby/GSL , etc. ◦ Library for Numerical Algorithms  グラフ表示機能 –? ◦ Plotting Graphs RubyKaigi2010 2010-8-29 40
  • 41. NArrayの各機能 ◦ NArray functions  NArrayの使い方 ◦ NArray usage  次版NArray ◦ Next version of NArray  他の類似数値配列との比較 ◦ Comparison with other numerical arrays, e.g. Numpy  Python が科学分野で主流になりつつある件 ◦ Python is becoming major in Science field. RubyKaigi2010 2010-8-29 41
  • 42. 田中昌宏 Masahiro Tanaka 筑波大学 University of Tsukuba RubyKaigi2010 2010-8-29 42
  • 43. ワークフローのグラフ  科学データ処理 Workflow graph ◦ Scientific data processing  複雑なワークフローである ◦ is a complicated workflow.  ワークフロー記述言語が必要 ◦ It needs definition language  Makefileによる記述が提案 ◦ Use of Makefile has been proposed ◦ e.g. GXP make RubyKaigi2010 2010-8-29 43
  • 44. Pwrake  Rakeによるワークフロー記述を提案 Process Process  We propose defining workflows Rake Process ◦ Makeより記述力が高い ◦ More descriptive power than Make  Rakeの並列分散拡張として、Pwrake (プレイク)を開 発  We are developing Pwrake, a Parallel workflow extension for Rake ◦ http://github.com/masa16/pwrake RubyKaigi2010 2010-8-29 44
  • 45. NArrayを使った科学計算の例について紹介 ◦ Examples of Scientific computing using NArray  NArrayとその特徴を紹介 ◦ NArray and its features  並列分散ワークフロー実行システムPwrake ◦ Parallel Distributed Workflow System Pwrake RubyKaigi2010 2010-8-29 45
  • 46. ご質問  Questions? RubyKaigi2010 2010-8-29 46
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy