SlideShare ist ein Scribd-Unternehmen logo
1 von 42
自己的異質多核心平台自己幹
AJ (張仁傑)
<ajblane0612@gmail.com>
2015.3.7
http://www.slideshare.net/aj0612/sitcon2015
感謝SITCON
參加分享的活動
• MOSUT
• 若渴計畫
Motivation
• 研究在寫CUDA程式
• 開放原始碼專案協作 (2014 年暑期)
• 意外獲得板子,要感謝Jserv大大
CUDA
不滿足
偷用一下圖片XD
跟LLVM有什麼關係?
Outline
• 神人寫的GPGPU: Nyuzi processor, 在DE2-115 board執行
• github搜尋
• 概說Nyuzi processor特性
• 如何在DE2-115讓Nyuzi processor開始執行
• 在SoCKit board使用Golden System Reference Design (GSRD)
• RocketBoards.org組織提供
• 怎麼去做porting
Nyuzi Processor特色-SIMD
• A custom RISC instruction set (load-store architecture)
• 30 general purpose scalar registers
• 32 vector registers, each with 16 lanes
• Instructions are 32-bit fixed length and must be 32-bit aligned
des op2 op1 mask
add_i_mask v1, s2, v2, v3
total number of registers available per block: 65536
我比較大
需透過LLVM-
GPGPU來產
生machine
code
Nyuzi Processor特色
• 同時抓4個指令,切換執行
如何讓Nyuzi processor開始
執行?
需要手動boot 與載入code
$ jload boot.hex
$ bin/serial_boot program.elf
GPGPU
Niso II
The DE2-115 Board
Ubutun14.04
USB Blaster-JTAG Clock rate: ~60 Mhz
SuperFish
如何實現?
Niso II
The DE2-115 Board
GPGPU
Memory
UART
0
0xffffffff
5. boot.c等待
serial_boot.c的command
stack
0x2000
code
JTAG Loader
PC
start.s
boot.c stack
0x200000
2. GPGPU reset後從address 0
開始執行
3. start.s 設定sp = 0x2000
4. 跳至boot.c
boot.hex
Ubutun14.04
step1 step6 step4
start.s boot.c
$ jload
NyuziProcessor/tools/serial_boot/serial_boot.c
1.
Niso II
The DE2-115 Board
GPGPU
Memory
UART
0
0xffffffff
NyuziProcessor/tools/serial_boot/serial_boot.c
解譯program.ELF
8. serial_boot.c告知
boot.c,code已經搬移
結束.跳至start.s
stack
0x2000
code
JTAG Loader
PC
start.s
boot.c stack
0x200000
9. 設置PC開始執行,並把
sp設置0x200000 (?)
Ubutun14.04
step1 step6 step4
6.告知GPGPU把HEX code 寫至board memory
boot.c
$ bin/serial_boot program.elf
7.收到HEX code寫至board memory
start.s
$ jload boot.hex
$ bin/serial_boot program.elf
怎那麼麻煩? (搬code進板子memory)
因為Niso II在納涼(閒置)
在解決這問題之前,先來介紹GSRD
GSRD
• 提供開發者有一個Linux
環境可以操作FPGA
• Software IP
• Linux Driver
• File I/O來操作Software IP
• 開發流程概念:
• 先有個Image,先run.再針
對各部分update
• 細節可參考
• Booting Linux Using
Prebuilt SD Card Image
• Creating and Updating SD
Card
Linux如何與FPGA溝通?
先來看Altera Hard Process System (HPS)
• H2F(Host to FPGA)
• High bandwidth
• Light weight
• F2H (FPGA to HPS system)
• F2S (FPGA-to-HPS SDRAM Interface)
Cyclone V HPS Memory Map
• 在SoCKit版中,Cortex-A9可主動透過
H2F傳資料給software IP
• LWAXI
• 0xFF200000 ~0xFF3FFFFF(2MB)
• HPS2FPGA (high bandwidth)
• 0xC000000開始
Golden Hardware
Reference Design
(GHRD)
• On-Chip RAM需高頻寬傳輸,
控制周邊就不須使用高頻寬
F2H
F2S
在SoCKit版中,software IP可透過F2H、F2S主動傳資料到memory與Cortex-A9溝通
如何設計software IP與memory溝通
參考SoCKit Video Server and Video IP (VIP) Reference Design設
LWAXI
F2H
使用Qsys連接AXI master/slave
Software IP使用Qsys,有這麼簡單@@?
• 必須了解AXI master slave
• AMBA AXI and ACE Protocol Specification AXI3, AXI4, and AXI4-Lite, ACE and ACE-Lite
• 我不了解,但我會改 Demo AXI Memory Design Example
• Qsys System Design Tutorial
• 注意細節:
• 所有AXI master或者slave的pin都要宣告
• AXI slave's ID bit width
• If an AXI slave's ID bit width is smaller than required for your system, the AXI slave response
might not reach all AXI
• maximum_master_id_width_in_the_interconnect +
log2(number_of_masters_in_the_same_interconnect)
• 所以我把Nyuzi Processor製作成Qsys元件
Software IP開發者角度
+0xff20 0000
軟體開發者角度
有了GSRD我們可以怎修改
Qsys會自動產生
LWAXI
F2H自動忽略XD
經過下列步驟,就可以撰寫程式來測試FPGA是
否有加成功? Yes, it works.
• Converting .sof to .rbf
• Device tree generation
• 給寫driver用的。概念上就是知道I/O的name,就可以透過查詢
Device Tree得到address來操作[跨板子設計]
• Preloader image generation
• 會產生出preloader的source code ,所以有些FPGA初始化設定
可以在這裡撰寫編譯
• Configure Pinmux
• Preloader and U-Boot Customization - v13.1
• Updating SD card
過程與細節可參考我的研究紀錄
這流程是對於GDRD,
如果是VIP RD就不行
還記得
Niso II
The DE2-115 Board
GPGPU
Memory
UART
0
0xffffffff
5. boot.c等待
serial_boot.c的command
stack
0x2000
code
JTAG Loader
PC
start.s
boot.c stack
0x200000
2. GPGPU reset後從address 0
開始執行
3. start.s 設定sp = 0x2000
4. 跳至boot.c
boot.hex
Ubutun14.04
step1 step6 step4
start.s boot.c
$ jload
NyuziProcessor/tools/serial_boot/serial_boot.c
1.
Niso II
The DE2-115 Board
GPGPU
Memory
UART
0
0xffffffff
NyuziProcessor/tools/serial_boot/serial_boot.c
解譯program.ELF
8. serial_boot.c告知
boot.c,code已經搬移
結束.跳至start.s
stack
0x2000
code
JTAG Loader
PC
start.s
boot.c stack
0x200000
9. 設置PC開始執行,並把
sp設置0x200000 (?)
Ubutun14.04
step1 step6 step4
6.告知GPGPU把HEX code 寫至board memory
boot.c
$ bin/serial_boot program.elf
7.收到HEX code寫至board memory
start.s
那現在
Cortex-A9
The SoCKit Board
GPGPU
Memory
0 0xffffffff
stackcode
PC
Ubutun14.04
LINUX
HPS
SD card
Program.hex produced by elf2hex
LWAXI
step 1
step 2
F2H
LWAXI
F2H
1. 透過Linux宣告code空間,並設置code base
address、stack address(?)
2. cortex-A9從SD card搬code至指定memory
3. 透過cortex-A9來控制GPGPU RESET signal(?)
Address data
0xFF200000 RESET
0xFF200004 Code base address
0xFF200008 Stack address
(*highest* stack)
0xFF20000C Heap address
0xFF200010 Frame address
差在哪?
搬code透過Cortex-a9來搬,
且從SD card到memory
Cortex-A9
The SoCKit Board
GPGPU
Memory
0 0xffffffff
stackcode
PC
Ubutun14.04
LINUX
HPS
SD card
Program.hex produced by elf2hex
LWAXI
1. 透過Linux宣告code空間,並設置code base
address、stack address(?)
2. cortex-A9從SD card搬code至指定memory
3. 透過cortex-A9來控制GPGPU RESET signal(?)
step 1
step 2
LWAXI
F2H 主動
Address data
0xFF200000 RESET
0xFF200004 Code base address
0xFF200008 Stack address
(*highest* stack)
0xFF20000C Heap address
0xFF200010 Frame address
PC
step 3
• 設計了memory I/O
• 你想要存取0xff200000你需要使用mmap
• fd = open(“/dev/mem”,..)
• used_ptr = mmap(..,fd,0xff200000)
• 透過LWAXI設定GPGPU的初始狀態, 且GPGPU透過F2H主動抓code
來執行
• 透過LWAXI設定Reset signal
上圖work之後的幾個概念整理
boot.hex
• How to build
• Elf2hex is as a loader
• Tutorial: Creating an LLVM Backend for the Cpu0 Architecture
LLVM-nyuzi is built to the target
Cortex-A9
The SoCKit Board
LINUX
HPS
SD card
ld.mcld
llvm-ar
elf2hex
clang
.s, .c, .cpp .o
.a.o
.elf
.hex
.hex
整個流程打通之後, 越來越像…..
實現CPU/GPU無縫切換運算,HSA催生下世代處理器 CUDA LLVM Compiler
有興趣email給我, 因為還很多還沒做XD
AJ (張仁傑)
<ajblane0612@gmail.com>
最近跑去研究Xvisor在ARMv8-A
Q&A
我不是神人, 所以如果有問題我當下沒辦法回答,
我會記錄下來並更新在此投影片上

Weitere ähnliche Inhalte

Ähnlich wie [SITCON2015] 自己的異質多核心平台自己幹

Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qcon
Yiwei Ma
 
Lvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukongLvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukong
Michael Zhang
 
使用Dsl改善软件设计
使用Dsl改善软件设计使用Dsl改善软件设计
使用Dsl改善软件设计
mingjin
 
张勇 搜搜前端架构
张勇 搜搜前端架构张勇 搜搜前端架构
张勇 搜搜前端架构
isnull
 
Exadata那点事
Exadata那点事Exadata那点事
Exadata那点事
freezr
 

Ähnlich wie [SITCON2015] 自己的異質多核心平台自己幹 (20)

Taobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qconTaobao casestudy-yufeng-qcon
Taobao casestudy-yufeng-qcon
 
icecream / icecc:分散式編譯系統簡介
icecream / icecc:分散式編譯系統簡介icecream / icecc:分散式編譯系統簡介
icecream / icecc:分散式編譯系統簡介
 
Python小团队不妨知道的技术
Python小团队不妨知道的技术Python小团队不妨知道的技术
Python小团队不妨知道的技术
 
Lvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukongLvs在大规模网络环境下的应用pukong
Lvs在大规模网络环境下的应用pukong
 
08 gaming framework design based on cocos2d-x
08   gaming framework design based on cocos2d-x08   gaming framework design based on cocos2d-x
08 gaming framework design based on cocos2d-x
 
.NET Conf Taiwan 2022 - Tauri - 前端人員也能打造小巧快速的 Windows 應用程式
.NET Conf Taiwan 2022 - Tauri -前端人員也能打造小巧快速的 Windows 應用程式.NET Conf Taiwan 2022 - Tauri -前端人員也能打造小巧快速的 Windows 應用程式
.NET Conf Taiwan 2022 - Tauri - 前端人員也能打造小巧快速的 Windows 應用程式
 
使用Dsl改善软件设计
使用Dsl改善软件设计使用Dsl改善软件设计
使用Dsl改善软件设计
 
Full stack-development with node js
Full stack-development with node jsFull stack-development with node js
Full stack-development with node js
 
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open Camp微服務架構 導入經驗分享 吳剛志 - Community Open Camp
微服務架構 導入經驗分享 吳剛志 - Community Open Camp
 
高效益、設計專利保護 如何達成雙贏?
高效益、設計專利保護 如何達成雙贏?高效益、設計專利保護 如何達成雙贏?
高效益、設計專利保護 如何達成雙贏?
 
專題-2017Linux Driver 實現
專題-2017Linux Driver 實現專題-2017Linux Driver 實現
專題-2017Linux Driver 實現
 
Sdn 之旅 open suse_asia_summit_20151206
Sdn 之旅 open suse_asia_summit_20151206Sdn 之旅 open suse_asia_summit_20151206
Sdn 之旅 open suse_asia_summit_20151206
 
NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析NoSQL误用和常见陷阱分析
NoSQL误用和常见陷阱分析
 
LinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorialLinkIt 7697 IoT tutorial
LinkIt 7697 IoT tutorial
 
[students AI workshop] Pytorch
[students AI workshop]  Pytorch[students AI workshop]  Pytorch
[students AI workshop] Pytorch
 
张勇 搜搜前端架构
张勇 搜搜前端架构张勇 搜搜前端架构
张勇 搜搜前端架构
 
OpenSCAD Workshop
OpenSCAD WorkshopOpenSCAD Workshop
OpenSCAD Workshop
 
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
探索 ISTIO 新型 DATA PLANE 架構 AMBIENT MESH - GOLANG TAIWAN GATHERING #77 X CNTUG
 
Exadata那点事
Exadata那点事Exadata那点事
Exadata那点事
 
美丽说的架构发展与变迁 New
美丽说的架构发展与变迁 New美丽说的架构发展与变迁 New
美丽说的架构发展与变迁 New
 

Mehr von Aj MaChInE

Mehr von Aj MaChInE (17)

An Intro on Data-oriented Attacks
An Intro on Data-oriented AttacksAn Intro on Data-oriented Attacks
An Intro on Data-oriented Attacks
 
A Study on .NET Framework for Red Team - Part I
A Study on .NET Framework for Red Team - Part IA Study on .NET Framework for Red Team - Part I
A Study on .NET Framework for Red Team - Part I
 
A study on NetSpectre
A study on NetSpectreA study on NetSpectre
A study on NetSpectre
 
Introduction to Adversary Evaluation Tools
Introduction to Adversary Evaluation ToolsIntroduction to Adversary Evaluation Tools
Introduction to Adversary Evaluation Tools
 
[若渴] A preliminary study on attacks against consensus in bitcoin
[若渴] A preliminary study on attacks against consensus in bitcoin[若渴] A preliminary study on attacks against consensus in bitcoin
[若渴] A preliminary study on attacks against consensus in bitcoin
 
[RAT資安小聚] Study on Automatically Evading Malware Detection
[RAT資安小聚] Study on Automatically Evading Malware Detection[RAT資安小聚] Study on Automatically Evading Malware Detection
[RAT資安小聚] Study on Automatically Evading Malware Detection
 
[若渴] Preliminary Study on Design and Exploitation of Trustzone
[若渴] Preliminary Study on Design and Exploitation of Trustzone[若渴] Preliminary Study on Design and Exploitation of Trustzone
[若渴] Preliminary Study on Design and Exploitation of Trustzone
 
[若渴]Study on Side Channel Attacks and Countermeasures
[若渴]Study on Side Channel Attacks and Countermeasures [若渴]Study on Side Channel Attacks and Countermeasures
[若渴]Study on Side Channel Attacks and Countermeasures
 
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode[若渴計畫] Challenges and Solutions of Window Remote Shellcode
[若渴計畫] Challenges and Solutions of Window Remote Shellcode
 
[若渴計畫] Introduction: Formal Verification for Code
[若渴計畫] Introduction: Formal Verification for Code[若渴計畫] Introduction: Formal Verification for Code
[若渴計畫] Introduction: Formal Verification for Code
 
[若渴計畫] Studying ASLR^cache
[若渴計畫] Studying ASLR^cache[若渴計畫] Studying ASLR^cache
[若渴計畫] Studying ASLR^cache
 
[若渴計畫] Black Hat 2017之過去閱讀相關整理
[若渴計畫] Black Hat 2017之過去閱讀相關整理[若渴計畫] Black Hat 2017之過去閱讀相關整理
[若渴計畫] Black Hat 2017之過去閱讀相關整理
 
[若渴計畫] Studying Concurrency
[若渴計畫] Studying Concurrency[若渴計畫] Studying Concurrency
[若渴計畫] Studying Concurrency
 
[若渴計畫2015.8.18] SMACK
[若渴計畫2015.8.18] SMACK[若渴計畫2015.8.18] SMACK
[若渴計畫2015.8.18] SMACK
 
[若渴計畫]由GPU硬體概念到coding CUDA
[若渴計畫]由GPU硬體概念到coding CUDA[若渴計畫]由GPU硬體概念到coding CUDA
[若渴計畫]由GPU硬體概念到coding CUDA
 
[若渴計畫]64-bit Linux Return-Oriented Programming
[若渴計畫]64-bit Linux Return-Oriented Programming[若渴計畫]64-bit Linux Return-Oriented Programming
[若渴計畫]64-bit Linux Return-Oriented Programming
 
[MOSUT] Format String Attacks
[MOSUT] Format String Attacks[MOSUT] Format String Attacks
[MOSUT] Format String Attacks
 

[SITCON2015] 自己的異質多核心平台自己幹