Submit Search
Upload
Intel®HLS CompilerでSHA256アクセラレータを作ったら微妙に失敗した
•
Download as PPTX, PDF
•
1 like
•
2,937 views
Yukitaka Takemura
Follow
SHA-256をIntel HLS Compilerでお手軽に作ってみた経験談を紹介します。
Read less
Read more
Devices & Hardware
Slideshow view
Report
Share
Slideshow view
Report
Share
1 of 31
Download now
Recommended
Ansible x softlayer Provisioning
Ansible x softlayer Provisioning
softlayerjp
Scalaのコンパイル速度の話が聞きたいだろうし、するつもりだ
Scalaのコンパイル速度の話が聞きたいだろうし、するつもりだ
yoshiaki iwanaga
Watsonをささえる ハイパフォーマンスクラウドで はじめるDeep Learning
Watsonをささえる ハイパフォーマンスクラウドで はじめるDeep Learning
Atsumori Sasaki
第4回 SoftLayer勉強会 資料
第4回 SoftLayer勉強会 資料
Naoki Shibata
Devsumi 2016 b_4 KafkaとSparkを組み合わせたリアルタイム分析基盤の構築
Devsumi 2016 b_4 KafkaとSparkを組み合わせたリアルタイム分析基盤の構築
Tanaka Yuichi
some SHA1 implementation
some SHA1 implementation
Makoto Kishimoto
鹿駆動勉強会 青江発表資料
鹿駆動勉強会 青江発表資料
Takashi Aoe
20160127三木会 RDB経験者のためのspark
20160127三木会 RDB経験者のためのspark
Ryuji Tamagawa
Recommended
Ansible x softlayer Provisioning
Ansible x softlayer Provisioning
softlayerjp
Scalaのコンパイル速度の話が聞きたいだろうし、するつもりだ
Scalaのコンパイル速度の話が聞きたいだろうし、するつもりだ
yoshiaki iwanaga
Watsonをささえる ハイパフォーマンスクラウドで はじめるDeep Learning
Watsonをささえる ハイパフォーマンスクラウドで はじめるDeep Learning
Atsumori Sasaki
第4回 SoftLayer勉強会 資料
第4回 SoftLayer勉強会 資料
Naoki Shibata
Devsumi 2016 b_4 KafkaとSparkを組み合わせたリアルタイム分析基盤の構築
Devsumi 2016 b_4 KafkaとSparkを組み合わせたリアルタイム分析基盤の構築
Tanaka Yuichi
some SHA1 implementation
some SHA1 implementation
Makoto Kishimoto
鹿駆動勉強会 青江発表資料
鹿駆動勉強会 青江発表資料
Takashi Aoe
20160127三木会 RDB経験者のためのspark
20160127三木会 RDB経験者のためのspark
Ryuji Tamagawa
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
More Related Content
Featured
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Featured
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Intel®HLS CompilerでSHA256アクセラレータを作ったら微妙に失敗した
1.
Intel®HLS Compilerで SHA256アクセラレータを 作ったら微妙に失敗した 竹村 幸尚
2.
Intel®HLS Compilerで SHA256アクセラレータを 作ったら微妙に失敗した 竹村 幸尚
3.
がっかりポイント • VivadoHLS使ったこと無いです • なので両ツールの比較、的な視点では喋れません •
まあ仮に使ったことあったとしても喋れないわけですが…
4.
背景 • 今PACが熱い!(局所的に) • PAC(Programmable
Acceleration Card)とは • Intel®ブランドで提供されるアクセラレーション向け量産カード • 例えばデルでサーバ買うとオプションでFPGAカードをつけられる未来がすぐ そこに • チップビジネスから ボードビジネスへ?
5.
NVIDIA に!! と言ったとか言わなかったとか(言ってない)
6.
背景 • PACで動くデザインサンプル作ったろ • 前にSHA-1とかやったし、次はSHA-256あたりが良いんじゃ ね?(適当) •
まあOpenSSLあたりからコード引っ張ってくればいいし、簡単 だろ(適当) • 回路がんがんパラ化すれば超速いんじゃね?(適当)
7.
本題 • Intel® HLS
Compilerとは • Quartus®Prime Pro/Standard/Lite 17.1から標準添付 • 追加ライセンス不要 • Lite EditionももちろんOK • クォータスと呼んでくださいね • untimedのC/C++コードをRTLに高位合成 • 最適化・高速化は以下で行う • コード自体の修正 • #pragma • attribute • 入出力最適化 • コマンドラインオプション • Quartus®のGUIとは連携なし • Platform Designer(旧Qsys)は使います
8.
思想 • コンパイル時のコマンドをg++からi++に変えるだけでHWが出 来る! • なのでコマンド名はi++ •
なのでコマンドラインオプションも割と共通 • 開発ツールもg++用のを使えば良いじゃん! • gdbとか • Valgrindとか
9.
余談 • SHA256について • メッセージダイジェスト・暗号学的ハッシュ関数の一種 •
MD5とかSHA-1とかの仲間 • ロイヤルティフリー • Federal Information Processing Standards Publication 180-2なるドキュメントを見 るべし • 計算方法が割とそのまんま書いてある • OpenSSLとかの実装をそのまま使うのはかえって面倒くさいかも • 権利関係とかさ • 512bitのチャンクに分割して計算していく • Paddingが重要 • 単にzero paddingとかしちゃうとハッシュじゃなくなるもんね
10.
続き • 関数(FIPS180-2より)
11.
続き • Hash計算(FIPS180-2より) For i
= 1 to N(ブロック数) { <処理1> For t = 0 to 63 { <処理2> <処理3> } <処理4> }
12.
続き • 処理1 • ワーク変数初期化 •
Hは最初に決められた初期値で初期化 For i = 1 to N(ブロック数) { <処理1> For t = 0 to 63 { <処理2> <処理3> } <処理4> }
13.
続き • 処理4 • ワーク変数書き戻し For
i = 1 to N(ブロック数) { <処理1> For t = 0 to 63 { <処理2> <処理3> } <処理4> }
14.
続き • 処理2 • W設定 For
i = 1 to N(ブロック数) { <処理1> For t = 0 to 63 { <処理2> <処理3> } <処理4> }
15.
続き • 処理3 • メインの計算処理 For
i = 1 to N(ブロック数) { <処理1> For t = 0 to 63 { <処理2> <処理3> } <処理4> }
16.
方針 • 入出力データはストリーミング式にする • いつだってストリーミングが性能上有利(自分調べ) •
入力幅はチャンクサイズと同じ512bitとする • CCI-Pバスと同じ幅 • 超高速になる予感… • Paddingがちょっとややこしそうなので、別モジュールに切り出し • ややこしい処理はパイプライン化を阻害しがち • 初段のモジュールでPaddingし、(512bitブロック×N個)化する • 次段のモジュールでHash計算 • とりあえずはこの程度の工夫で、後はスペックのまま実装してみる
17.
デモ
18.
結果 • レポートを見てみる • Initiation
Interval (II)は全て1! • んん??
19.
結果 • レポート曰く Iteration executed
serially across calc_hash.B3. Only a single loop iteration will execute inside this region due to data dependency on variable(s) • これはSerial region…
20.
解説 • Serial regionとは •
ネストされたループで発生 • 内側のループの実行が完了しないと、次の外側のループのイタレーションが回せ ない状態 • 内側ループのパイプラインのフラッシュを待たなければいけない • フラッシュ待ち時間が無視出来れば性能上問題ない • フラッシュ待ちが無視できる状態 • パイプラインのレイテンシが短い • 内側ループの回数が多い kernel void test() { int a[1024]; while (i<M) { for ( j=0; j<N; j++) { a[X] = b[X]; process(a); } } } a[]へのアクセスは、 一つ前の外側ループ の実行が終わってか らでないと出来ない (例)
21.
解説 • Serial regionとは •
ネストされたループで発生 • 内側のループの実行が完了しないと、次の外側のループのイタレーションが回せ ない状態 • 内側ループのパイプラインのフラッシュを待たなければいけない • フラッシュ待ち時間が無視出来れば性能上問題ない • フラッシュ待ちが無視できる状態 • パイプラインのレイテンシが短い (今回は10クロック) • 内側ループの回数が多い (今回は64回) 今回の実装ではイマイチ (512bit処理に64+10サイクルかかる & パラ化は無理)
22.
考察 • そりゃそうだよね。暗号だもんね。 • 簡単に高速化されたらあっという間にクラックされちゃうよね •
工夫の余地があるのか??世間はもっとうまいことやっている のか? • 世間のSHA-256実装の工夫は、もっぱらCPUの命令にうまく当たるよ うに分解しているだけの話のような… • HW化の際はあまりそこ関係ない • CPUの命令に綺麗に当たるように書いてもFPGAは知らんがなという話
23.
世間 • 見つけた • IP屋さんと言えばCAST
24.
世間
25.
世間
26.
世間 =7bit/clk
27.
世間 =7bit/clk 73.14clock/512bit…
28.
理想 • 理想 $ time
sha256sum hogehoge real 0m10.000ms $ time sha256sum_fpga hogehoge real 0m1.000ms • FPGA早い! • 現実 • CPUよりかなり遅い • 最後まで実装する気失せた
29.
反省 • じゃあFPGAでSHA-256は意味がないのか??
30.
反省 • じゃあFPGAでSHA-256は意味がないのか?? • そんなことはない! •
1ファイルのハッシュ値取得レイテンシをCPUと競っても負ける • 複数のファイルを同時に扱えばよい • 回路のパラレル化が有効になる • 今回の回路はとても小さい • Arria10の1%以下 • PCIEボトルネックまで持っていけるはず • パイプラインも詰められる
31.
締め • ちゃんと考えてから設計しよう • CPUアクセラレーションは簡単ではないです! •
Intel® HLS Compilerをどうぞよろしく • 既にRTLに性能ポータビリティなんぞ無いですよ!! • untimedだからこその性能ポータビリティ
Editor's Notes
好きなIDEを使おう
Download now