MacBook AirとCUDA 3.2で画像合成
以前に行った画像合成(アルファブレンディング)をCUDA 3.2で再びやってみた。
テスト環境は前回から大きく変わっている。
- MacOS X 10.6.5 (Snow Leopard)
- MacBook Air/Late 2010 (13inch, Core2 Duo 1.86GHz, 4GB, GeForce 320M)
- CUDA Toolkit 3.2 (driver 3.2.17)
- OpenCV 2.2
- 入力画像:JPEG, 1600x1200(pixel)
OSやハードウェア、CUDAのドライバまで異なるので、前回の値との比較は意味を成さず、あくまで参考値と見なした方が良いだろう。また、今回はCUDA、OpenCVのライブラリとも64bitでビルドしているので、ソフトの方も64bitでビルドして動かしている。(ソースコード自体は、入力画像形式を変えたところ以外に変更無し)
実行結果は下記の通り。
# | 処理方法 | 時間(msec) | 速度比 |
---|---|---|---|
(1) | CPU | 217.03 | 1 |
(2) | GPU(paged) | 73.99 | 2.93 |
(3) | GPU(pinned) | 28.49 | 7.62 |
この結果から、次の事が分かる。
- アルファブレンディングの処理をCPUからGPUに持って行くと、約2.9倍の性能が出た。
- 画像転送元のメモリとして'pinned memory'を指定すると、約7.6倍の性能が出た。
前回の実行結果は下記の通りだった。
# | 処理方法 | 時間(msec) | 速度比 |
---|---|---|---|
(1) | CPU | 162.34 | 1 |
(2) | GPU(paged) | 63.0 | 2.57 |
(3) | GPU(pinned) | 41.2 | 3.94 |
速度向上の率を比較してみると、paged memoryでは15%程度の速度向上だが、pinned memoryでは約2倍弱まで大きく向上していることが分かる。
もちろん速度向上の要因として一番大きいのはGPUチップの違いだろう。GeForce 320Mのデバイス情報は下記のように取得できた。
$ ./bin/darwin/release/deviceQuery ./bin/darwin/release/deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) There is 1 device supporting CUDA Device 0: "GeForce 320M" CUDA Driver Version: 3.20 CUDA Runtime Version: 3.20 CUDA Capability Major/Minor version number: 1.2 Total amount of global memory: 265027584 bytes Multiprocessors x Cores/MP = Cores: 6 (MP) x 8 (Cores/MP) = 48 (Cores) Total amount of constant memory: 65536 bytes Total amount of shared memory per block: 16384 bytes Total number of registers available per block: 16384 Warp size: 32 Maximum number of threads per block: 512 Maximum sizes of each dimension of a block: 512 x 512 x 64 Maximum sizes of each dimension of a grid: 65535 x 65535 x 1 Maximum memory pitch: 2147483647 bytes Texture alignment: 256 bytes Clock rate: 0.95 GHz Concurrent copy and execution: Yes Run time limit on kernels: Yes Integrated: Yes Support host page-locked memory mapping: Yes Compute mode: Default (multiple host threads can use this device simultaneously) Concurrent kernel execution: No Device has ECC support enabled: No Device is using TCC driver mode: No deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 3.20, CUDA Runtime Version = 3.20, NumDevs = 1, Device = GeForce 320M PASSED Press <Enter> to Quit...
前回の結果と比較してみると、コア数が大きく増えているようだ。
デスクトップマシンに載っている巨大なGPUには敵わないけれど、こんな小さなマシンでもGPUの威力を実感できるのはなかなか面白いと思う。
関連