使っているノートPCはSkylake (6th Gen CPU, Gen9 GPU)とギリギリ Intel oneAPI 対応プラットフォームなので、
開発環境をインストールしてサンプルを動かしてみました
本記事の対象
インストールするもの
インストール手順
- GPUドライバーの更新(上記note記事にTIPSのっけてます)
- Visual Studio 2019を使う場合は、先にインストールとのこと(拙環境はインストール済みなので割愛)
- oneAPI Base Toolkitをダウンロード. アカウントがなければ先に作成
- oneAPI Base Toolkitをインストール. 特に操作なし
さぁ始めよう
- やり方は以下の2種類「お好きな方をどうぞ」
- コマンドラインベース
- VisualStudioベース
- 拙環境だとVS2019 ver.16.5.5と>16.4だったが、ソリューションファイル読み込みでエラーが発生したのでver.16.7.3に更新したところ読み込めるようになった
- 実行結果は以下の通り
- GPUで実行しているぽい
他のサンプル
他には↓のようなサンプルがある
oneVPL(Video Processing Library) の "Hello DPC++ interop" を実行してみる
GPUを使っているように見える
※ソースそのままだと実行時エラーが発生したので以下のように、device.is_gpu()を有効にするよう変更しました
// Select device on which to run kernel. class MyDeviceSelector : public cl::sycl::device_selector { public: MyDeviceSelector() {} int operator()(const cl::sycl::device &device) const override { const std::string name = device.get_info<cl::sycl::info::device::name>(); std::cout << "Trying device: " << name << "..." << std::endl; std::cout << " Vendor: " << device.get_info<cl::sycl::info::device::vendor>() << std::endl; if (device.is_cpu()) return 500; // We give higher merit for CPU //if (device.is_accelerator()) return 400; //if (device.is_gpu()) return 300; //if (device.is_host()) return 100; return -1; } };
// Select device on which to run kernel. class MyDeviceSelector : public cl::sycl::device_selector { public: MyDeviceSelector() {} int operator()(const cl::sycl::device &device) const override { const std::string name = device.get_info<cl::sycl::info::device::name>(); std::cout << "Trying device: " << name << "..." << std::endl; std::cout << " Vendor: " << device.get_info<cl::sycl::info::device::vendor>() << std::endl; //if (device.is_cpu()) // return 500; // We give higher merit for CPU //if (device.is_accelerator()) return 400; if (device.is_gpu()) return 300; //if (device.is_host()) return 100; return -1; } };
dpcpp-blur.exe
は
This sample is a command line application that takes a file containing a raw I420 format video elementary stream as an argument, converts it to RGB32 with oneVPL and blurs each frame with DPC++ by using SYCL kernel, and writes the decoded output to
out.rgba
in RGB32 format.
I420フォーマットのビデオエレメンタリーストリームをoneVPLを使ってRGB32に変換しつつ
DPC++(Data Parallel C++)で書かれたSYCLカーネルによるブラーを毎フレームかけてout.rgbaファイルに書き出す処理をしているらしい
ffplayで再生してみるとブラーかかってる(元データしらんけど)
おわりに
8000円で買った中古ノートPCで、スパコンでも使われるソフトウェアフレームワークを試せたのは中々楽しい oneAPIのベース技術であるSYCLはベンダー固有ではないので、どっかで役に立てばいいなぁ