コンパイル的にどんな感じなんだろうと試してみた。
ドキュメントを下記URLを見ながら進めていきます。
インストールはインストーラを使用してインストールするようになっています。
次のインストーラーが用意されているようです。
今回はLocal Installerでインストールを進めます。
次のURLにアクセスします。
https://software.intel.com/content/www/us/en/develop/tools/oneapi.html
"Get the Toolkits"をクリックして下図に進みます。
「Native Toolkits」のうちの「Intel oneAPI Toolkit」をダウンロードします。
選択する項目を次のように設定して、「Download」をします。
サインアップしましょう。
FPGAを選択する場合は「Intel FPGA Add-on oneAPI Base Toolkit」を開いて、使うPlatformをダウンロードします。
今回はFPGAに実装するわけではないので無視しました。
ダウンロードが完了したら次のように実行します。
$ sudo sh ./l_BaseKit_p_2021.1.0.2659_offline.sh
次のスプラッシュウィンドウが開くので「Continue」で進みましょう。
次はチェックを付けて、「Continue」です。
ささ、右矢印をクリックして進みましょう。
Eclipseをインストールするか問われます。
当然、スキップでしょう。
まぁ、ちょっとぐらい協力しましょう。
砂時計が回り始め、時間がかかるのでコーヒーブレイクです。
こんな感じでプログレスバーが表示されるので、インストールが完了するまで待ちましょう。
インストールが完了したらサンプルを実行してみましょう。
つぎのように環境変数の設定します。
$ source /opt/intel/oneapi/setvars.sh
:: initializing oneAPI environment ...
BASH version = 5.0.17(1)-release
:: ccl -- latest
:: advisor -- latest
:: dal -- latest
:: compiler -- latest
:: ipp -- latest
:: dpcpp-ct -- latest
:: dev-utilities -- latest
:: intelpython -- latest
:: mpi -- latest
:: ippcp -- latest
:: tbb -- latest
:: vtune -- latest
:: debugger -- latest
:: mkl -- latest
:: dpl -- latest
:: vpl -- latest
:: dnnl -- latest
:: oneAPI environment initialized ::
次のように実行して進めていくようです。
$ oneapi-cli
次のようにコンソールにメニューが表示されます。
╔ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
║ 1) Create a project
║ 2) View oneAPI docs in browser
║ q) Quit
║
║
║
║
║
║
║
║
║
║
║
║
║
║
║
║
║
║
║
╚ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═ ═
日本語コンソール環境だとあとで文字化けするので「LANG=C」を付けて実行しました。
$ LANG=C oneapi-cli
まぁ、まだマシって感じです。
(1) 「Create a project」を選択します。
????????????????????????????????????????????????????????????????????????????????
?(1) Create a project ?
?(2) View oneAPI docs in browser ?
?(q) Quit ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
????????????????????????????????????????????????????????????????????????????????
次は(1) 「cpp」を選択します。
?????????????????????????????Select sample language?????????????????????????????
?(1) cpp ?
?(2) python ?
?(b) Back ?
?(q) Quit ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
????????????????????????????????????????????????????????????????????????????????
次のようにサンプルの一覧が表示されます。
この辺りで文字が不整列なところにイラついてきます。
????????????????Samples?????????????????┌─────────────Description──────────────┐
?Toolkit ?│ │
?├──Get Started ▒?│ │
?│ ├──Base: Vector Add ▒?│ │
?│ ├──Debugger: Array Transform ▒?│ │
?│ ├──Matrix Mul ▒?│ │
?│ └──Simple Add ▒?│ │
?├──oneAPI Direct Programming ▒?│ │
?│ ├──C++ ▒?│ │
?│ │ ├──Parallel Patterns ▒?│ │
?│ │ │ └──OpenMP* Reduction ▒?│ │
?│ │ └──Structured Grids ▒?│ │
?│ │ └──ISO3DFD OMP Offload ▒?│ │
?│ ├──DPC++ ▒?│ │
?│ │ ├──Combinational Logic ▒?│ │
?│ │ │ ├──Mandelbrot ▒?│ │
?│ │ │ └──Sepia Filter ▒?│ │
?│ │ ├──Dense Linear Algebra ▒?│ │
?│ │ │ ├──Base: Vector Add ▒?│ │
?│ │ │ ├──Complex Mult ▒?│ │
?│ │ │ ├──Matrix Mul ▒?└──────────────────────────────────────┘
?│ │ │ └──Simple Add ▒?┌──────────────────────────────────────┐
?│ │ └──Graph Algorithms ▒?│Press Backspace to return to previous │
????????????????????????????????????????└──────────────────────────────────────┘
カーソルを下に移動して、「DPC++」の「Sepia Filter」を選択しました。
????????????????Samples?????????????????┌─────────────Description──────────────┐
?│ │ │ └──OpenMP* Reduction ▒?│A program that converts an image to │
?│ │ └──Structured Grids ?│Sepia Tone │
?│ │ └──ISO3DFD OMP Offload ▒?│ │
?│ ├──DPC++ ▒?│ │
?│ │ ├──Combinational Logic ▒?│ │
?│ │ │ ├──Mandelbrot ▒?│ │
?│ │ │ └──Sepia Filter ▒?│ │
?│ │ ├──Dense Linear Algebra ▒?│ │
?│ │ │ ├──Base: Vector Add ▒?│ │
?│ │ │ ├──Complex Mult ▒?│ │
?│ │ │ ├──Matrix Mul ▒?│ │
?│ │ │ └──Simple Add ▒?│ │
?│ │ ├──Graph Algorithms ▒?│ │
?│ │ │ └──All Pairs Shortest Paths ▒?│ │
?│ │ ├──Graph Traversal ▒?│ │
?│ │ │ ├──Bitonic Sort ▒?│ │
?│ │ │ └──Hidden Markov Models ▒?│ │
?│ │ ├──Map Reduce ▒?│ │
?│ │ │ └──Monte Carlo Pi ▒?│ │
?│ │ ├──N-Body Methods ▒?└──────────────────────────────────────┘
?│ │ │ └──N-Body ▒?┌──────────────────────────────────────┐
?│ │ └──Parallel Patterns ▒?│Press Backspace to return to previous │
????????????????????????????????????????└──────────────────────────────────────┘
次のように表示されるのでディレクトリに問題がなければ「Create」します。
?Create Project?????????????????????????????????????????????????????????????????
? ?
? Destination /home/hidemi/workspace/oneAPI/sepia-filter ?
? ?
? Create Back ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
? ?
????????????????????????????????????????????????????????????????????????????????
次のように表示されるので「Quit」します。
??????????????????????????????????????
? ?
? Sucessfully created project in ?
? /home/hidemi/workspace/oneAPI/sepi ?
? a-filter ?
? ?
? Quit View Readme and Quit ?
? ?
??????????????????????????????????????
次のようにディレクトリが作成されています。
$ ls
sepia-filter
ディレクトリの中を覗いてみましょう。
$ cd sepia-filter/
$ ls
CMakeLists.txt input sepia-filter.vcxproj src
License.txt sample.json sepia-filter.vcxproj.filters
README.md sepia-filter.sln sepia-filter.vcxproj.user
次のようにcmakeでビルドの準備をします。
$ mkdir build
$ cd build/
$ cmake ..
-- Default CMAKE_BUILD_TYPE not set using Release with Debug Info
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is Clang 12.0.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /disk/opt/intel/oneapi/compiler/2021.1.1/linux/bin/dpcpp - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hidemi/workspace/oneAPI/sepia-filter/build
makeを実行してビルドしましょう。
$ make
Scanning dependencies of target sepia
[ 50%] Building CXX object src/CMakeFiles/sepia.dir/sepia_dpcpp.cpp.o
[100%] Linking CXX executable sepia
[100%] Built target sepia
さくっと出来上がるので生成物を見てみます。
$ ls src/
CMakeFiles Makefile cmake_install.cmake sepia silverfalls1.png
次のように実行してみましょう。
$ ./src/sepia ../input/nahelam512.bmp
Loaded image with a width of 512, a height of 512 and 3 channels
XRT build version: 2.8.0
Build hash: 77d5484b5c4daa691a7f78235053fb036829b1e9
Build date: 2020-11-28 23:41:04
Git branch: 2020.2
PID: 400259
UID: 1000
[Mon Jan 4 14:52:15 2021 GMT]
HOST: saturn
EXE: /home/hidemi/workspace/oneAPI/sepia-filter/build/src/sepia
[XRT] ERROR: XILINX_XRT must be set
Running on Intel(R) FPGA Emulation Device
Submitting lambda kernel...
Submitting functor kernel...
Waiting for execution to complete...
Execution completed
Lambda kernel time: 0.445333 milliseconds
Functor kernel time: 0.588378 milliseconds
Sepia tone successfully applied to image:[../input/nahelam512.bmp]
次のようにPNGファイルができました。
$ ls
CMakeCache.txt Makefile sepia_functor.png sepia_ref.png
CMakeFiles cmake_install.cmake sepia_lambda.png src
↓が元の写真です。
たしかにセピア変換されていました。
FPGAを使わなければ特に難しいことはないんですね。