Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍...
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
shu223
February 22, 2018
Programming
1.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Metal Acceleratedかどうかを調べる方法〜あなたのアプリのどこでMetalが暗躍しているのか #potatotips
potatotips #48 (iOS/Android開発Tips共有会)での発表資料です。
https://potatotips.connpass.com/event/77702/
shu223
February 22, 2018
More Decks by shu223
See All by shu223
slidify-sample
shu223
1
1.6k
機械学習のブルーオーシャン Core ML by 堤 修一 #iOSDC Japan 2020
shu223
12
5.9k
エンジニアのための発信講座 #4 登壇しよう
shu223
0
160
エンジニアのための発信講座 #3
shu223
0
150
エンジニアのための発信講座 #2
shu223
2
270
エンジニアのための発信講座 #1
shu223
1
1k
今こそwatchOS #iosdc
shu223
5
11k
Depth in Depth #iOSDC
shu223
4
31k
技術書のジレンマとPEAKS + 書評ブログを書くTips #iOS11book
shu223
18
6k
Other Decks in Programming
See All in Programming
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
180
為什麼你並不需要ViewModel / No, you don't need a ViewModel
lovee
1
490
2年かけて Deno に DOMMatrix を実装した話 / How I implemented DOMMatrix in Deno over two years
petamoriken
0
210
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
4
390
「寝てても仕事が進む」Claude Codeで組む第二の脳
tomoyafujita2016
0
320
PHP初心者セッション2026 〜生成AIでは見えない裏側を知る:今だからLAMPを通して仕組みを学ぶ〜
kashioka
0
880
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
520
Apache Hive: Toward a Cloud Native Lakehouse
okumin
0
180
php-fpmのプロセスが枯渇した日-調査・対処・そして本当にやるべきだったこと-
shibuchaaaan
0
260
Laravel Boostに学ぶ、AIにPHPを書かせる技術 〜OSSの実装から蒸留するエージェント制御の王道〜
kentaroutakeda
3
680
運用ダッシュボードの設計を誰も教えてくれないのだけどみなさんどうしてるんですか? - チームに監視するという文化を根付かせるための第一歩を踏みたい -
satoshi256kbyte
1
100
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
1.7k
Featured
See All Featured
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
WCS-LA-2024
lcolladotor
0
790
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
56k
sira's awesome portfolio website redesign presentation
elsirapls
0
320
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Music & Morning Musume
bryan
47
7.3k
KATA
mclloyd
PRO
35
15k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2k
SEO for Brand Visibility & Recognition
aleyda
0
4.7k
What does AI have to do with Human Rights?
axbom
PRO
1
2.3k
Context Engineering - Making Every Token Count
addyosmani
9
1k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
930
Transcript
Metal Accelerated͔Ͳ͏͔ΛௐΔํ๏ ͋ͳͨͷΞϓϦͷͲ͜ͰMetal͕҉༂͍ͯ͠Δͷ͔ Shuichi Tsutsumi @shu223
None
WWDC17ͷ͜ͷਤͰɺUIKitΛؚΉ ଟ͘ͷϑϨʔϜϫʔΫ͕෦Ͱ MetalΛ༻͍͍ͯΔ͜ͱ͕Θ͔ͬͨ
͕ɺ
ࡉ͔͍͜ͱ·Ͱ৭ʑͱΘ͔Βͳ͍ • UIKitͷԼճΓ͍͔ͭΒMetalʹͳͬͨͷ͔ʁ • UIKitͷͲͷॲཧ͕Metal AcceleratedͰɺͲͷॲཧ͕ͦ͏͡Όͳ͍ͷ͔ʁ • OpenGLʢiOSͰʣࠓMetalͷ্ʹ࣮͞Ε͍ͯΔͱAppleͷਓ͕WWDC ͷϥϘͰݴ͚ͬͯͨͲɺެࣜใͳ͍ •
2014ͷWWDCͰCore AnimationͷϨΠϠʹ͍ͭͯղઆ͕͋Δ͚Ͳɺ͜ ΕͬͯͲ͔͜ΒͲ͜·Ͱ͕ࠓ༗ޮͳใͳͷ͔ʁ • etc.
AppleͷެࣜใཔΈ • API Reference • Programming Guide • Forum •
WWDC Session • ʮWWDC LabͰதͷਓ͕ݴͬͯͨʯ ͔͠ɾɾɾ ͕࣌ؒܦͭͱɺެࣜใͰϝϯς͞Ε͍ͯͳ͍ͷূڌͱͯ͠ෆेʹͳΔ
ʮཪऔΓʯେมˍ͍͠
ʮMetal Accelerated͔Ͳ͏͔ʯ ΛࣗͰௐΒΕͳ͍͔ʁ
Metal Accelerated͔Ͳ͏͔ΛͳͥΓ͍ͨͷ͔ʁ • தͷਓʹΑͬͯϝϯς͞Ε͍ͯͯɺ࠷దԽ͞Ε͍ͯΔ͜ͱ͕Θ͔Δ • ࣗͷ࠷దԽख๏͕ద͔Ͳ͏͔ͷஅࡐྉʹͳΔ • ϨΠϠʹ౿ΈࠐΜͰࣗલ࣮͢Δ͔Ͳ͏͔ͷஅࡐྉʹͳΔ
XcodeͷGPU Reportʁ
MetalΛ໌ࣔతʹར༻͍ͯ͠ͳ͍ͱɺ XcodeͷGPU Reportग़ͯ͜ͳ͍
ͦ͜ͰInstruments
Metal System Trace
UIKit͔ͬͯ͠ͳ͍ʢʹMetalͬͯͳ͍ʣ ΞϓϦͰࢼͯ͠ΈΔ
τϨʔεͰ͖ͯΔʂ
UIKitͷԼͰʮ҉తʹʯΘΕ͍ͯΔ MetalͷଉਧΛײ͡Δ͜ͱ͕Ͱ͖Δʂ
࣌ܥྻํʹ֦େͯ͠ΈΔ
ͬ͘͟Γͨ͠ݟํ GPUͰ࣮ߦ͢ΔίϚϯυͷ࡞ʢonCPUʣ GPUίϚϯυΛૹ৴ʢon CPUʣ γΣʔμͷ࣮ߦʢon GPUʣ σΟεϓϨΠͷඳը CPUͰͷॲཧ → GPUͰͷॲཧ
→ ը໘දࣔ ͷҰ࿈ͷྲྀΕͱෛՙ͕ՄࢹԽ͞Ε͍ͯΔ
“Launching” Comand Buffer (SpringBoard) ͦͷޙඳըλεΫͳ͠ ʢUIKitඞཁ͕ͳ͚Εߋ৽ॲཧΛ͠ͳ͍ʣ “Foreground” ͜ͷ͋ͨΓΞϓϦىಈ࣌ͷඳը ॲཧͬΆ͍
ϘλϯΛԡͨ͠ΒUIImageViewͰը૾Λදࣔ͢Δ ʢͪΖΜMetalΘͳ͍ʣ
ΞϓϦىಈ࣌ͷॾʑ ϘλϯԡԼʙ UIImageViewͷը૾දࣔ
࣌ܥྻํʹ֦େ
ʮMetal Accelerated͔Ͳ͏͔ʯ ΛࣗͰௐΒΕͳ͍͔ʁ → InstrumentsͰௐΒΕͦ͏
ϦΞϧλΠϜʹݟΕͳ͍ ʮͲͷάϥϑ͕ͲͷॲཧΛද͍ͯ͠Δͷ͔ʁʯ ͕Θ͔ΓͮΒ͍
MetalͷlabelػೳΛར༻ͯ͠Ͳ͏͔ʁ private func pushLabel(_ label: String) { let commandBuffer =
commandQueue.makeCommandBuffer()! commandBuffer.label = label commandBuffer.commit() } ʮԿ͠ͳ͍MetalͷίϚϯυόοϑΝʯΛGPUʹϓογϡ͢Δ ϝιουΛ͓͍ͭͬͯͯ͘ɺ @IBAction func btnTapped(_ sender: UIButton) { pushLabel(“start”) imageView.image = UIImage(named: "highsierra") pushLabel(“end”) } ͜Μͳײ͡ͰݺͿͱɾɾɾ label͚͍ͩ࣋ͬͯΔ
Instruments্Ͱͦͷlabel͕දࣔ͞Εɾɾɾ ͳ͔ͬͨɾɾɾ
ʮۭͷίϚϯυόοϑΝʯ InstrumentsͰݟ͑ͳ͍ ࣮ߦ࣌ʹGPUʹૹΒΕͳ͍ͷ͔ɺ ͦͦϏϧυஈ֊Ͱ࠷దԽ͞ΕΔͷ͔ɺetc… ʢͲ͔͜ʹ༷ͱͯ͠ॻ͍ͯ͋Δ͔ʣ
தͷ͋ΔίϚϯυʹ͢Δ private func pushLabel(_ label: String) { let textureLoader =
MTKTextureLoader(device: device) let srcTex = try! textureLoader.newTexture(name: “hoge”, scaleFactor: 2.0, bundle: nil) let descriptor = MTLTextureDescriptor.texture2DDescriptor( pixelFormat: srcTex.pixelFormat, width: srcTex.width, height: srcTex.height, mipmapped: false) let destTex = device.makeTexture(descriptor: descriptor)! let commandBuffer = commandQueue.makeCommandBuffer()! commandBuffer.label = label let blitEncoder = commandBuffer.makeBlitCommandEncoder()! blitEncoder.copy( from: srcTex, sourceSlice: 0, sourceLevel: 0, sourceOrigin: MTLOriginMake(0, 0, 0), sourceSize: MTLSizeMake(srcTex.width, srcTex.height, srcTex.depth), to: destTex, destinationSlice: 0, destinationLevel: 0, destinationOrigin: MTLOriginMake(0, 0, 0)) blitEncoder.endEncoding() commandBuffer.commit() } ຊʹཉ͍͠ͷ͚ͩ͜͜
ޭʂ ηοτͨ͠label͕ݟ͍͑ͯΔ
·ͱΊ • ͍··ͰɺMetal Accelerated͔Ͳ͏͔Λ֬ೝ͢ΔʹɺެࣜใཔΈͩͬͨ - Guide, API Reference, Forum, WWDC
Session, WWDC LabͰݴͬͯͨ, etc…ʮཪऔΓʯ ͕͔ͬͨ͠ - MetalΛ໌ࣔతʹ༻͍͍ͯͳ͚ΕɺXcodeͷGPU ReportԠ͠ͳ͍ • InstrumentsͷMetal System TraceΛ༻͍ΔͱɺMetalΛ໌ࣔతʹ༻͍͍ͯͳ ͍߹ʹɺMetalͷಈ͖ΛΔ͜ͱ͕Ͱ͖Δ • ϦΞϧλΠϜʹτϨʔεͰ͖ͳ͍ͷͰɺҹͱͯ͠labelΛషΔํ๏ݕ౼ - ҰԠ͏·͍ͬͨ͘ - ͕ɺखʹMetalΛ͏ख๏ʹͳͬͯ͠·ͬͨͷͰɺ͓͢͢Ί͠ͳ͍