2014年12月18日 星期四

The era of OpenCL 2.0 is comming

Although OpenCL 2.0 spec was finalized & released in Dec 2013. But it takes almost one year for vendors to implement 2.0 runtime. In the recent months, Intel and AMD have released their SDK (Intel SDK, AMD SDK) for OpenCL 2.0.

AMD provides a series of articles about the new features of OpenCL 2.0 on the AMD Developer Blog:
OpenCL 2.0 - Shared Virtual Memory
OpenCL 2.0 - Pipes
OpenCL 2.0 - Device Enqueue and Workgroup Built-in Functions
OpenCL 2.0 - Generic Address Space and Program Scope Variables
OpenCL 2.0 - Image Enhancement

Besides these, AMD also provides a source code package of OpenCL 2.0 Samples. It is worth to take a look. You can get the key points of OpenCL 2.0 from the topics of sample package and articles. IMHO, SVM, Pipes and Device Enqueue are the most important three features among the new features of OpenCL 2.0.

==
儘管 OpenCL 2.0 規格在2013年十二月就發佈了. 但是各家廠商花了近一年實作 OpenCL 2.0 runtime. 最近幾個月Intel 與 AMD 相繼釋出各自的 SDK (Intel SDK, AMD SDK) for OpenCL 2.0.

AMD 在其 Developer Blog 還發佈了一系列關於 OpenCL 2.0 新特性的文章:
OpenCL 2.0 - Shared Virtual Memory
OpenCL 2.0 - Pipes
OpenCL 2.0 - Device Enqueue and Workgroup Built-in Functions
OpenCL 2.0 - Generic Address Space and Program Scope Variables
OpenCL 2.0 - Image Enhancement

此外, AMD 也提供了 OpenCL 2.0 Samples 的原始碼, 值得一看. OpenCL 2.0 的關鍵點能透過這些原始碼與文章的標題觀察得到. 其中 SVM, Pipe 與 Device Enqueue 是個人認為 OpenCL 2.0 新特性之中最重要的3個.




2014年10月18日 星期六

Gaming 或許是 Android 5.0 Lollipop 其中一項重點

Android 5.0 在近日正式釋出了
而在 10/17 也已釋出了 SDK for Android 5.0
對於 Android 5.0 網路上相關介紹文件不少
由於先前並沒有花心思看 Android L Preview 的介紹
所以這幾日花了點時間消化相關新的系統特性

這裡想指出 Google 對於 Android 平台在 Gaming 的野心
首先是 Android 5.0 除了 OpenGL ES 3.1 的支援外提出的 Android Extension Pack(AEP)
The extension pack supports:
* Guaranteed fragment shader support for shader storage buffers, images, and atomics (Fragment shader support is optional in OpenGL ES 3.1.)
* Tessellation and geometry shaders * ASTC (LDR) texture compression format
* Per-sample interpolation and shading
* Different blend modes for each color attachment in a frame buffer

其中前兩點是最重要的,
請搜尋 Tessellation 稍微了解其目的
另外必須知道 Tessellation 是 OpenGL 4.0/DirectX 11 後的特性
Tessellation & Geometry Shader 是近年 GPU 提升模型動態細緻化的重大演進
對於 AEP 詳細的規範可以參考 Khronos 的 spec

而另外一個點在於此次 Google 裝置除了 Nexus 6/9 外
還有個不太受到注目的 Nexus Player,
多數的 Nexus Player 分析著重於 Android TV 與具有語音控制/搜尋的遙控器上, 這點無可厚非
但 Nexus Player 有許多有趣的特性(像是它是第一個官方 x86 Nexus 裝置)
其一便是 Nexus Player 提供了選購的無線藍牙 GamePad
目前已知 Nexus Player 中的 Intel Atom 所使用的 GPU 是 PowerVR 6000 系列
這系列的 GPU 俱備了支援 AEP 的規格
此兩點顯示 Google 有意透過 Nexus Player 做為 Android Gaming Console 的示範平台的野心
儘管 Android Extension Pack 對於 Android 並非必要項目,
但在智慧裝置利潤逐漸下滑的今日, 平台差異化顯得重要
AEP這樣明確規範的規格, 是很容易成為各家IC生產商軍備競賽的比較條件之一...
況且, 若無市場戰略目標, 維持目前 Android 圖形需求, 跟隨 OpenGL ES 標準也已足夠 (若要與 iOS Metal 競爭那又是另外一個面向的事情了)
並無制定這套延伸 OpenGL ES 擴充標準的必要

2014年8月18日 星期一

OpenCL Kernel Optimization Tips 簡報上線

這段日子工作與 OpenCL 相關
因此碰觸到了一些 Mobile 與 Desktop 的 OpenCL Runtime
面對 OpenCL 程式對不同的硬體平台做優化的過程
有許多的層面必須要考量, 因此將這些想法集結為這份 slides
日後希望有機會能update加入 example 與 case study.

2014年6月24日 星期二

OpenCL Utility/Framework 專案 - CLScript

開了自己的第一個 github project
https://github.com/champyen/clscript

這一兩年由於 GPGPU 應用的興起,
心中一直有個關於 video codec 的想法想要付諸實現
近日開始著手動工, 儘管有些地方的設計還沒頭緒
但是基本的問題還是需要解決
CLScript 這個專案因此這些基本問題而產生, 目前百廢待興, 文件與 code 還需要作進一步改進, 但是初版已可以玩一玩
OpenCL 其中一個讓 programmer 感到麻煩的地方在於
OpenCL Host Code 的撰寫很冗長,
且對於一個 function call 需要相當的前置作業
撰寫 kernel code 對應的 Host Program 是無趣的一件事
CLScript 這是個 utility/framework 層面的專案
其目的就在於簡化 OpenCL 的使用流程, 解決上述問題
讓開發者能更專注於 OpenCL 中核心的 kernel code 的開發
C/C++ framework 使用上, 建構的概念是將 .cl file 視為類似於 C library
在 test/test.cpp 中可以看到參考用法
using namespace clscript;
...
CSRuntime runtime(CS_DEV_GPU);
CSLib lib(&runtime, clFileName);
CSBuffer buf(&runtime, 4096*sizeof(cl_int));
CSWorkSize gWS(4096);
lib.exec("test", gWS, NullWorkSize, 0, &buf);

CSLib 的 exec 界面會將傳進的不定數目參數作設定與傳遞
對 C/C++ 使用者而言, 就像是呼叫一個特定的 function
另外一個 exec 界面是為了 csutil CLI tool 而設的
csutil 為直接測試 CL kernel code 的工具, 可以不用寫 Host Program 而直接測試kernel code 程式
csutil 有四大參數, 目前預設使用 GPU device
1. CL 檔案
2. 在 1. 檔案中, 所要使用的 function 名稱
3. WorkSize
     各 dimension 以 ',' 區隔, global 與 local 以 ':' 區隔, local worksize部份並非必要
4. function 所使用的參數
     * float - f:1.0
     * double - d:1.0
     * int - i:1
     * buffer - b:sz=4096,if=/dev/zero,of=out.bin
    這是最麻煩的, 設定參數又有三個sz, if 與 of(皆非必要), sz 為 buffer 大小, 未設置預設為 global worksizes 相乘, if 為用來初始化 buffer 的資料, 會讀入與 buffer size 相同大小的內容, 若無必要初始化無須指定, of為 buffer 結果的輸出, 若為 temp buffer 無須指定

以 source 中附上的 test.cl 就可以這樣使用
./csutl/csutil ../test.cl test 4096 i:2 b:sz=16384,if=/dev/zero,of=out.bin

Chisel 學習筆記 - Scala 與 Chisel 基礎語法

標題為筆記, 但這篇比較屬於心得 延續 上一篇 的環境建立, 這次計劃藉由 Jserv 最新的 課程安排 來學習 Chisel, 當然個人目標是能夠按照 Jserv 的課程規劃在 期限之內 完成 Lab 3, 由於個人並非 digital designer (現在這年紀也算老貓學...