31
Page 1 System Software Lab., NCTU Introduction to OpenVX An open, royalty-free standard for cross platform acceleration of computer vision applications. Presenter: Jia-Rung Chang Instructor: Yi-Ping You The last modification date : 2016/08/10

Introduction to OpenVX

Embed Size (px)

Citation preview

Page 1: Introduction to OpenVX

Page 1System Software Lab., NCTU

Introduction to OpenVX

An open, royalty-free standard for cross platform acceleration of computer vision applications.

Presenter: Jia-Rung ChangInstructor: Yi-Ping You

The last modification date : 2016/08/10

Page 2: Introduction to OpenVX

Page 2System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from SynopsysOpenVX relevant paperConclusion

簡報者
簡報註解
大綱: 1.OpenVX是Khronos眾多標準的其中一項,所以會先介紹在Khronos生態系當中,OpenVX的角色 2.OpenVX正式推出標準到現在約2年,來看看現在的發展如何 3.OpenVX是以vendor(製造商)為中心的標準,所以就以Synopsys的經驗來了解 4.參考OpenVX相關的論文,如果之後作為研究題目,可能的研究方向
Page 3: Introduction to OpenVX

Page 3System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from SynopsysOpenVX relevant paperConclusion

簡報者
簡報註解
那我們來看看,Khronos生態系當中,OpenVX的角色
Page 4: Introduction to OpenVX

Page 4System Software Lab., NCTU

What is OpenVX?

An open standard , not open source.Do not specify the details of implementation.

For cross platform acceleration of computer vision applications.

Every vendor can do their optimization for their own Soc.

Ex: NVIDIA, AMD and Synopsys,etc.

Currently,only few of vendors release their own implementation.

簡報者
簡報註解
什麼是OpenVX? OpenVX是一個公開的標準,但並非開放原始碼,而且沒有規定實作的條件,也就是供應商可能僅提供library,而非原始碼。 OpenVX是為了加速跨平台的影像處理,特別是具有多種影像處理單元的SoC 那麼目前只有AMD有將他們的OpenVX實作開放出來,稱為AMDOVX 另外就是Khronos的實作範例。
Page 5: Introduction to OpenVX

Page 5System Software Lab., NCTU

Vision Acceleration

Targeted at low-power, real-time applicationsMobile and embedded platforms

Portability across diverse heterogeneous processors

ISPs, Dedicated hardware, DSPs and DSP arrays, GPUs, Multi-core CPUs …

Doesn’t require high-power CPU/GPU ComplexLow-power host can setup and manage frame-rate vision processing pipeline

簡報者
簡報註解
OpenVX的目標:加速影像處理 目標平台是:智慧型手機以及嵌入式平台, 因為這些平台都擁有異質多核心, 包括DSP,GPU,CPU,以及一些特定目標的硬體加速裝置。 因為是設計給移動平台,所以host CPU可以不需要太高效能,只要能分派特定任務給特定的硬體即可。
Page 6: Introduction to OpenVX

Page 6System Software Lab., NCTU

Khronos APIs for Vision Processing

ref: http://www.slideshare.net/embeddedvision/1-c01-khronostrevett

簡報者
簡報註解
這裡是Khronos的API比較,每個API標準都有自己當初設立的目標: OpenGL系列,已經於大多數的裝置上可用,僅能在單顆GPU上使用,且語言是GLSL(OpenGL Shading Language)。 OpenCL是針對異質多核心的framework,需要compiler的支援,常作為各種OS或framework的後端。 OpenVX不要求compiler的支援,僅規定API介面,特色是可以針對各個裝置客製化API實作內容,主要是針對低耗電且常駐的裝置。
Page 7: Introduction to OpenVX

Page 7System Software Lab., NCTU

Layered Vision Processing Ecosystem

ref: http://www.slideshare.net/embeddedvision/1-c01-khronostrevett

簡報者
簡報註解
介紹OpenVX的架構之前,先了解OpenVX以及相關標準的相對角色: 未來應用程式開發者只要熟悉OpenVX的標準,就能在任何硬體上開發, 因為OpenVX只是一個API介面,實作並沒有規定,所以能夠在實作上套用現有的OpenCL以及OpenGL, 遇到特定的硬體,各個硬體製造商,能自己實作最有利自己的產品的driver, 並且各家都以相同的OpenVX API提供給應用程式開發者使用。
Page 8: Introduction to OpenVX

Page 8System Software Lab., NCTU

OpenVX and OpenCV are Complementary

OpenCV OpenVX

Implementation Community driven open source library

Open standard API designed to be implemented by hardware vendors

Conformance Extensive OpenCV Test Suite butno formal Adopters program

Implementations must pass defined conformance test suite to use trademark

ConsistencyAvailable functions can vary depending on implementation / platform

All core functions must be available in all conformant implementations

簡報者
簡報註解
OpenCV以及OpenVX事實上是互補的角色, OpenCV作為高階的library,而OpenVX是屬於低階的library(但比OpenGL更高階), 兩者相比之下,OpenVX改善了不少OpenCV的缺點: 1.OpenCV沒有規定哪些API是一定要實作,而OpenVX有 2.因為OpenCV沒有規定一定要有的API,所以並沒有通用的benchmark,而OpenVX可以有
Page 9: Introduction to OpenVX

Page 9System Software Lab., NCTU

OpenVX Framework Objects Definition

ContextThe object domain for all OpenVX objects.

KernelThe abstract representation of a computer vision function

NodeAn instance of a kernel that will be paired with a

specific set of the parameters.

GraphA set of nodes connected in a directed (only goes one-way) acyclic (does not loop back) fashion.

簡報者
簡報註解
更深入介紹之前,先介紹幾個OpenVX定義的名詞,因為接下來的投影片都會用到。
Page 10: Introduction to OpenVX

Page 10System Software Lab., NCTU

OpenVX Framework

ref: https://www.khronos.org/openvx/

簡報者
簡報註解
在OpenVX的規格書內,將各個操作均視為nodes,也就是一個kernel加上參數。 如同前面定義的,一個Graph就是一組nodes, 第一步:先將一個大graph(一大組nodes)根據他們的特性,拆成不同的subgraph(一小組nodes) 第二步:根據每個node的特性,分配記憶體 第三步:將相似的node合併,增加memory的locality 第四步:一連串的sub graph最終成為一連串的pipeline,(稱為tile-base pipeline),詳細的說明後面還有。
Page 11: Introduction to OpenVX

Page 11System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from SynopsysOpenVX relevant paperConclusion

簡報者
簡報註解
再來是介紹,OpenVX的現況
Page 12: Introduction to OpenVX

Page 12System Software Lab., NCTU

OpenVX Status

OpenVX 1.1 Specification released in 2016 at Embedded Vision Summit

OpenVX 1.0 in 2014Expands node functionality AND enhances graph frameworkThe sample implementation v1.1 from Khronos is failed to build.

The sample implementation v1.0.1 from Khronos can build,but can not fully support their own tutorial.Official tutorial uses AMDOVX(v1.0.1) as the default OpenVX libraries.

簡報者
簡報註解
最新的1.1版,在今年5月的時候釋出 那新版跟舊版的差異我沒有特別去比較, 因為目前也沒有新版的範例可以參考, 他們的實作範例連編譯都無法通過, 所以就先不考慮。
Page 13: Introduction to OpenVX

Page 13System Software Lab., NCTU

NVIDIA VisionWorks

The implementation for OpenVX in VisionWorks is not open source.Available on Ubuntu 14.04(64-bits)

Because it is not an open source project, we skip trying it.

簡報者
簡報註解
NVIDIA的OpenVX是包裝在他們的SDK,稱為VisionWorks, 但是VisionWorks並非open source,所以接下來投影片,會以AMD的為主
Page 14: Introduction to OpenVX

Page 14System Software Lab., NCTU

AMD OpenVX (AMDOVX)

The official OpenVX tutorial use AMDOVX as the default libraries.In the tutorial

AMDOVX has better performance than the “Khronos sample implementation”.

The “Khronos sample implementation” version 1.1 is failed to build on my Ubuntu16.04 platform.

With AMD GPU will get better performance, but not necessarily.

AMD official Linux driver stop updating since 2016.

簡報者
簡報註解
Khronous現在定期都有在矽谷辦OpenVX的推廣教學,那他們的教材有開放讓人下載, 不過他們的教材,使用的OpenVX的實作,是採用AMD的AMDOVX, 如果套用他們官方釋出的範例實作,經測試,不是每個範例都能正常運作的。 那AMDOVX,如果硬體上有AMD的GPU,可以有更好的效能, 不過AMD的GPU driver,現在只提供比較較新且較高階GPU的drive給Linux,低階的不再支援更新,僅到Ubuntu15.10, 這是Ubuntu發出的聲明。 那AMDOVX在我實驗室的電腦上,還是可以跑,有去看他為什麼限定只給AMD使用, 發現主要是透過OpenCL加速,所以有嘗試修改build system,讓他成功地在編譯時, 把OpenCL編進去,但執行時會發生錯誤,又發現AMDOVX會使用getenv()來判斷是否為AMD的GPU, 因為與這相關的code太多了,就沒有繼續試下去了。
Page 15: Introduction to OpenVX

Page 15System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from Synopsys

Focusing on the idea, not the details.ref:Embeded VISION ALLIANCE

OpenVX relevant paperConclusion

簡報者
簡報註解
接下來是Synopsys,Synopsys是EDA tools and SoC 解決方案的供應商, 要分享他們的經驗是因為,OpenVX實在太新了,這是唯一與實做有關的內容, 接下來借用幾張他們的投影片,重點在於對OpenVX有更清楚的架構,而非細節, 而他們這份投影片,有公開的演講可以觀看。
Page 16: Introduction to OpenVX

Page 16System Software Lab., NCTU

簡報者
簡報註解
這是他們實作OpenVX的硬體架構 最底下的藍色框是Synopsys的EV Processor系列大致上的架構, 擁有4個RISC架構的32bit CPU,搭配DMA以及一個專為他們的圖形演算法(CNN)開發的CNN accelerator, 是一款專門用來計算convolution的硬體。 由圖中可以看到,OpenVX的每個Node都有一個對應的硬體處理, 而node的來源有可能是OpenVX規範的kernel lib(在1.0.1中,約有50個kernel), 其他的可以透過OpenVX extension,定義User kernels和Vendor kernels。 可以看到Ui和Uj都是被指定到同一個CPU單元上,這是為了要避免memory hierarchy,提升locality, 因為如果像Ui和Kn,就會需要shared memory來處理,對於嵌入式系統來說,這是相對耗電和耗時的。 當然如果本來就是global variable,就不會有這問題。 Vm則是分配到CNN accelerator上,這就是他們的例子。 這裡有一些相關應用, 像是智慧錶,這類需要always-on的裝置,CPU host只需要負責scheduling,always on的顯示就交給專用硬體。 或是相機模組,裡面有很多專用的影像處理單元,就可以善用OpenVX這類的機制, 提早效率。
Page 17: Introduction to OpenVX

Page 17System Software Lab., NCTU

簡報者
簡報註解
這是Synopsys去年的演講發表的人臉辨識演算法,其中他們的OpenVX流程圖, 這張圖只是用來表示,他們pipeline的分配 和 node-to-core assignment,在OpenVX的示意圖。 它們說是根據profiling的結果所決定的。
Page 18: Introduction to OpenVX

Page 18System Software Lab., NCTU

簡報者
簡報註解
OpenVX的最大問題是,共享資源的存取, 會有很多重複的物件導致記憶體的浪費以及同步的問題, 所以Synopsys就在OpenVX的體制之外,自己處理這個問題, 但這個機制必須與OpenVX的同步機制同步,不然就會導致race condition。
Page 19: Introduction to OpenVX

Page 19System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from SynopsysOpenVX relevant paper

Does not focus on the details,but the possible direction of research for us.

Conclusion

簡報者
簡報註解
接下來是與OpenVX有關的論文,那去google學術搜尋,大概只會找到幾篇, 有幾篇是與IC設計有關,扣掉那幾篇,僅剩2篇,這裡會以幾分鐘的方式大致描述該篇論文的重點, 但是細節不在這份投影片的討論範圍內。
Page 20: Introduction to OpenVX

Page 20System Software Lab., NCTU

Graph execution model in OpenVX

Synchronous blocking mode In that vxProcessGraph() will block until the graph has completed

Causing the synchronous processing of a graph.

Asynchronous single-issue-per-reference mode via vxScheduleGraph() and vxWaitGraph().

Schedules a graph for future executionWaits for a specific graph to complete.

簡報者
簡報註解
看論文之前,先幫大家建立OpenVX scheduling的背景知識, 有分成同步和非同步兩種, 但不論同步,還是非同步,都要經過Verify這個過程,這個API裡面, 可以進行最佳化,例如要做topological sort,就是要在這個階段做,這是從khronous的OpenVX實作範例裡面發現的。 那在這個階段之後,graph就不能修改了,之後就是選擇同步或非同步的API。
Page 21: Introduction to OpenVX

Page 21System Software Lab., NCTU

Graph execution model in OpenVX

Synchronous blocking mode In that vxProcessGraph() will block until the graph has completed

Causing the synchronous processing of a graph.

Asynchronous single-issue-per-reference mode via vxScheduleGraph() and vxWaitGraph().

Schedules a graph for future executionWaits for a specific graph to complete.

簡報者
簡報註解
同步的話,就是會等這個graph內,所有的node都運算結束,才算完成,主要是透過vxProcessGraph()這個API,將你的graph當作參數,餵給他,依我目前看到的OpenVX實作,就是看你要怎麼處理各個node,可以指定給OpenCL或是直接用CPU執行。 非同步,就是會依序執行,目前看到是會直接給一個專門處理node的thread處理,但只了解到這邊,因為還是看各家的實作。
Page 22: Introduction to OpenVX

Page 22System Software Lab., NCTU

Scheduling Methods for OpenVX Programson Heterogeneous Multi-core Systems

Authors: Tzu-Hsiang Lin, Cheng-Yen Lin, and Jenq-KuenLee

Department of Computer Science, National Tsing-Hua University, Taiwan

Source: PDPTA'15 The 21st International Conference on Parallel and Distributed Processing Techniques and Applications

簡報者
簡報註解
這是關於上一頁所述,關於修改Khronos範例排程(Verify和schedule)實作的論文。 是隔壁清大的去年的論文 來源是PDPTA 2015
Page 23: Introduction to OpenVX

Page 23System Software Lab., NCTU

Keynotes

AssumptionA linear relationship for data size and computation time, data size and data transfer time

The graph execution modelA directed acyclic graph (DAG) that determines the computation process of an OpenVX application

Optimization opportunitiesDispatching graphs to a different target, such as multicore CPUs with C, OpenMP runtime, OpenCLon GPUs, or a dedicated hardware. Memory locality and system throughput.

簡報者
簡報註解
其中比較重要的假設:data size和計算及傳輸時間成正比,雖然先前meeting好像有提到這不一定對, 然後他們認為OpenVX的node是DAG, 這篇認為,可以透過OpenMP於CPU,OpenCL於GPU,還有善用memory localit於scheduler,得到最佳化的機會。
Page 24: Introduction to OpenVX

Page 24System Software Lab., NCTU

Scheduling Algorithm(Node coarsen algorithm)Two phases

Node coarsen algorithm– Calculating the nodes that whether belonging to specific cluster via

thier ranking algorithm,including computation time and data transfer time between host and targets.

– vxVerifyGraph(graph)» Nodes in the same cluster will be forced to dispatch to the same target in the

scheduling phase» We only select the nodes which can reduce data transfer time or largely shorten the

computation time into the same cluster

Node scheduling algorithm– Dispatching the clustered nodes.

» Otherwise, finding the most free/available target compared to the preferred targets for the nodes, and rank both of them.

» According to the rank,dispatch it.– vxProcessGraph(graph)

» The remaining nodes not clustered will be scheduled for the target in the scheduling(this) phase.

Keynotes

簡報者
簡報註解
那他們的演算法分為兩層,第一層是位於verify階段,第二層位於schedule階段 Verify階段,他們會決定要把哪些node,併在同一組,同一組代表於下個階段,會被送到同一個運算單元去做計算。 但不是所有node都會被決定組別。 Schedule階段,如果已經有被指定為一組,同一個組內的node都會被指派到同一個運算單元, 沒有組別的node,會依據該node本身的rank來決定,看是要選擇本來就偏好的運算單元,還是最空閒的運算單元, 這些都是那些node本身實作的時候,就該考慮的點。
Page 25: Introduction to OpenVX

Page 25System Software Lab., NCTU

Keynotes

Experiment results

簡報者
簡報註解
這是實驗結果,他們排除了無法用OpenCL加速的kernel, 應該說,khronos範例實做,裡面沒有透過OpenCL加速的API, 所以約50個kernel,扣到只剩這幾個,然後量測時間。
Page 26: Introduction to OpenVX

Page 26System Software Lab., NCTU

Supporting Real-Time Computer Vision Workloads using OpenVX on

Multicore+GPU Platforms

Authors: Glenn A. Elliott, Kecheng Yang, and James H. Anderson

Department of Computer Science, University of North Carolina at Chapel Hill

Source: 2015 IEEE Real-Time Systems Symposium

簡報者
簡報註解
這是一篇關於OpenVX於即時系統的分析論文, 為”北卡羅來納大學教堂山分校”所做, 資料來源是2015的IEEE的即時系統研討會
Page 27: Introduction to OpenVX

Page 27System Software Lab., NCTU

Keynotes

The OpenVX model imposes three significant implications on real-time scheduling

Having no notion of a repeating (i.e., periodic or sporadic) task, and lacks any framework for real-time analysis.

The key issue is the allowance of “back edges” that can create cycles in a graph.

Does not defining a threading model for graph execution.Requiring a graph to execute end-to-end before it may be executed again.

Significantly hindering the ability to exploit parallelism by “pipelining” portions of a graph’s structure

簡報者
簡報註解
這篇論文我僅列出這張投影片,他們點出了OpenVX於即時系統的重大缺點: 1.OpenVX沒有規定太多,所以沒有週期性task的概念,可能導致反向的edge,使graph成為非DAG的圖形。 2.同一個graph,必須要執行完,才能重複執行,這阻礙了使graph透過類似pipeline的方式計算。
Page 28: Introduction to OpenVX

Page 28System Software Lab., NCTU

Keynotes

Implementation model

簡報者
簡報註解
那這篇論文,很大部分是基於他們以前的成果,先是與NVIDIA有合作,拿到當時為測試版的VisionWorks原始碼(現在正式版,依然沒有釋出),加上PGM,是一套他們為了符合美國海軍對於圖形處理的一套流程的軟體, 加上他們自己維護的real-time Linux,稱為LITMUS, 以及他們另外一個成果GPUSync,是一個user space的GPU管理的framework,可以透過API,指定GPU的動作, 說了這麼多他們自己的成果,他們就是讓VisionWorks跑於他們以前的成果,然後給予不同參數,得到delay多少單位的相關成果, 然後探討參數的關係。 這篇我認為不值得深入了解,因為太多他們自己設計的東西,也沒有開放原始碼,很多參數都沒有說明,也不知道是真是假。 但至少這一篇,可以知道,OpenVX與即時系統領域的關係為何。
Page 29: Introduction to OpenVX

Page 29System Software Lab., NCTU

Outline

OpenVX’s role in the Khronos ecosystemOpenVX in realityExperience from SynopsysOpenVX relevant paperConclusion

簡報者
簡報註解
接下來是與OpenVX有關的論文,那去google學術搜尋,大概只會找到幾篇, 有幾篇是與IC設計有關,扣掉那幾篇,僅剩2篇,這裡會以幾分鐘的方式大致描述該篇論文的重點, 但是細節不在這份投影片的討論範圍內。
Page 30: Introduction to OpenVX

Page 30System Software Lab., NCTU

Conclusion

The Possible direction of research in OpenVXThe world-first OpenVX benchmarkScheduling AlgorithmOpenVX in embedded/real-time system

簡報者
簡報註解
那今天的結論是,對於我們實驗室來說,OpenVX可能的研究方向: 1.OpenVX雖然有共同的API介面,可是缺乏一個具有公信力的benchmark,我認為這是不錯的切入點,做的還可以的話,其他前期的OpenVX研究,都引用你的成果。 2.如同前面清大的論文,就是做排程,這我就不多說了。 3.OpenVX設立的用意是為了嵌入式系統,而非一般的Intel架構電腦,可能在特定的ARM架構的硬體上,利用OpenVX看能提升多少效能。 其實上述兩篇論文最大的問題,我覺得是,他們都在x86相關的平台上測試,而非OpenVX原先針對的嵌入式系統,有點失去意義。
Page 31: Introduction to OpenVX

Page 31System Software Lab., NCTU

Main References

Khronos websiteMay 2014 Embedded Vision Summit Technical Presentation: KhronosMay 2016 Embedded Vision Summit Technical Presentation: SynopsysOpenVX tutorial(official)AMDOVXkhronos OpenVX sampleOpenVX specification