Metal for data-parallel computations

Metal for data-parallel computations

グラフィックス以外の分野でのMetalの可能性

iOSDC 2018 LT 発表資料

Ee6254efe6c4bc4c08967c11d4939245?s=128

kotetu (kotetuco)

September 02, 2018
Tweet

Transcript

  1. άϥϑΟοΫεҎ֎ͷ ෼໺ͰͷMetalͷՄೳੑ iOSDC 2018 (2018/9/2) @kotetu

  2. Kuriyama Toru (܀ࢁప) iOS / Android developer ɹɹɹɹɹɹɹɹat Sansan app

    (iOS/Android) Twitter: @kotetuɹɹɹɹɹɹ Github, Qiita: @kotetuco
  3. Metal • GPUΛ࢖͏ͨΊͷFramework • ओʹ3DάϥϑΟοΫεͰ࢖༻ • άϥϑΟοΫεͰ͔͠࢖͑ͳ ͍Θ͚Ͱ͸ͳ͍ 3 /

    14
  4. Metalͷ༻్ “Render advanced 3D graphics and perform data-parallel computations using

    the GPU.” ʮGPUΛ࢖ͬͨߴ౓ͳ3DϨϯμϦϯάͱฒྻॲཧʯ https://developer.apple.com/documentation/metal 4 / 14
  5. Metalͷ༻్ “Render advanced 3D graphics and perform data-parallel computations using

    the GPU.” ʮGPUΛ࢖ͬͨߴ౓ͳ3DϨϯμϦϯάͱฒྻॲཧʯ https://developer.apple.com/documentation/metal 4 / 14 3DάϥϑΟοΫεҎ֎ͷ༻్΋૝ఆ
  6. GPUͷಛੑ • 1ίΞ͋ͨΓͷੑೳ͸CPUͷํ͕ߴ͍͕ίΞ਺ ͸CPUΑΓଟ͍ • ʮCPU͸εϙʔπΧʔɺGPU͸όεʯ • ฒྻॲཧʹ޲͍ͨΞʔΩςΫνϟ Ҿ༻ɿiOSDC 2017ʮඈͼಓ۩Ͱ͸ͳ͍Metalʯ(@shu223͞Μ)

    ൃදࢿྉ 5 / 14
  7. ฒྻॲཧͷԸܙΛड͚ͦ͏ͳɹ ෼໺ • ը૾ॲཧ • ػցֶश(ਪ࿦) • ෺ཧγϛϡϨʔγϣϯ 6 /

    14
  8. ฒྻॲཧͷԸܙΛड͚ͦ͏ͳɹ ෼໺ • ը૾ॲཧ • ػցֶश(ਪ࿦) • ෺ཧγϛϡϨʔγϣϯ 6 /

    14
  9. ը૾ॲཧ • Core Image (Core Imageͷը૾ॲཧͷҰ෦͸ ಺෦ͰMetalΛ࢖༻͍ͯ͠Δ) • Core Image͕αϙʔτ͍ͯ͠ͳ͍ը૾ॲཧ͸

    OpenCVͳͲͷը૾ॲཧϥΠϒϥϦΛ࢖͏ 7 / 14
  10. OpenCV • ը૾ॲཧɾίϯϐϡʔλϏδϣϯϥΠϒϥϦ • PCͷGPUʹ͸ରԠ͍ͯ͠Δ͕Metalʹ͸ରԠ ͍ͯ͠ͳ͍ • iOS্Ͱ͸GPUͷԸܙΛड͚ΒΕͳ͍ 8 /

    14
  11. ࣮ݧɿը૾ॲཧͷॲཧ࣌ؒɹɹ Λൺֱɹɹ • OpenCV (CPU) • Metal (GPU) • Metal

    Performance Shader ɹɹɹɹɹ (MetalΛ࢖ͬͨը૾ɾฒྻॲཧϥΠϒϥϦ) 9 / 14
  12. ࢖༻ͨ͠ը૾ https://pixabay.com/photo-3599450/ ը૾αΠζɿ5984 × 3989 ϑΝΠϧαΠζɿ6.9MB (JPEG) 10 / 14

  13. ൺֱʹ༻͍ͨը૾ॲཧ 11 / 14 1. ೋ஋Խ (നࠇը૾΁ม׵) 2. ը૾ͷॖখ 3.

    ॖখ + ΅͔͠
  14. ݕূ༻ΞϓϦ • githubʹ͋Γ·͢(Լهࢀর) • Xcode 10 (beta 6) • iOS11+

    (࣮ػ͕ඞཁ) • OpenCV 3.4.2 12 / 14 https://github.com/kotetuco/ComparisonOfMetalAndOpenCV
  15. ݕূ݁Ռ 13 / 14 ※ ୯Ґ͸ϛϦඵɺ࢖༻୺຤͸ iPhone 8 Plusɹ(iOS11.3.1)

  16. ݕূ݁Ռ 13 / 14 ※ ୯Ґ͸ϛϦඵɺ࢖༻୺຤͸ iPhone 8 Plusɹ(iOS11.3.1) Metal͕

    ଎͍
  17. ·ͱΊ • MetalΛ࢖͑͹ඞͣ଎͘ͳΔΘ͚Ͱ͸ͳ͍ • ୯७ͳฒྻॲཧͰ͸GPU༻ϝϞϦ΁ͷίϐʔ΍ CPU-GPUؒ௨৴ͷ࣌ؒΛແࢹͰ͖ͳ͍ • ෳ਺ͷॲཧΛ·ͱΊͯߦ͍͍ͨ৔߹ʹ͸Metal͕༗ར • Metal(GPU)ʹ޲͍͍ͯΔ͔Ͳ͏͔ͷݟۃΊ͕େࣄ

    14 / 14