LoginSignup
1
1

More than 5 years have passed since last update.

SDAccelを用いた回路設計について その3

Last updated at Posted at 2017-11-22

前回の記事,SDAccelを用いた回路設計について その2では,SDAccelの環境構築について紹介しました.

本記事では,引き続き,サンプルプログラムの実行方法について紹介します.

実行環境

OS : Centos7.4
Kernel : 3.10.0-693.5.2.el7.x86_64
SDAccel : 2017.2

サンプルプログラムのダウンロード

SDAccelのサンプルプログラムは,githubにあります.

SDAccelサンプルプログラム

GitHubにあるリポジトリをローカルにcloneし,

$git clone https://github.com/Xilinx/SDAccel_Examples examples

以下のディレクトリに移動します.

SDAccel_Examples/getting_started/host/helloworld_ocl/

ファイルの階層は以下の通りとなっています.

.gitignore
Makefile
README.md
description.json
src/host.cpp
src/vector_addition.cl

このサンプルプログラムは,FPGA上でベクトルどうしの加算を行います.各要素ごとに独立して行うことができるため,高速化できることが期待できます.

コンパイルと実行

SDAccelには,アプリケーション開発者が利用できる機能の一部として,ソフトウェアエミュレートレベルとハードウェアエミュレートレベルの両方でアプリケーションの正確性をテストする環境が含まれています.

sw_emuおよびhw_emuという名前のこれらのモードでは,実機実装する前にプログラムのパフォーマンスを評価することができます.

少なくともsw_emuモードで実行してから,FPGAボード上でコンパイルして実行することをお勧めします.

以下のコマンドを実行することで,バイナリファイルが生成されます.

$make all TARGETS= sw_emu|hw_emu|hw 

以下の3つのファイルが生成されます.

helloworld
kernels. sw_emu|hw_emu|hw .xclbin
system_estimate.xtxt

ソフトウェアエミュレート,ハードウェアエミュレートするには下記のコマンドを実行します.

$emconfigutil --platform xilinx_kcu1500_4ddr-xpr_4_0
$export XCL_EMULATION_MODE= sw_emu|hw_emu

emconfigutilコマンドはemconfig.jsonファイルを作り,ターゲットデバイスに関する情報が含まれています.

実行するには以下のコマンドを実行します.

./helloworld

実行結果は以下の通りとなります.

[root@misaka helloworld_ocl]$ ./helloworld 
Linux:3.10.0-693.5.2.el7.x86_64:$1 SMP Fri Oct 20 20:32:50 UTC 2017:x86_64

XILINX_OPENCL="/home/xil-accel-rd-kcu1500/xbinst"
LD_LIBRARY_PATH="/home/xil-accel-rd-kcu1500/xbinst/runtime/lib/x86_64:/home/opt/Xilinx/SDx/2017.2/runtime/lib/x86_64:/home/opt/Xilinx/SDx/2017.2/lib/lnx64.o"

platform Name: Xilinx
Vendor Name : Xilinx
Found Platform
Found Device=xilinx_kcu1500_4ddr-xpr_4_0
XCLBIN File Name: vector_addition
INFO: Importing xclbin/vector_addition.sw_emu.xilinx_kcu1500_4ddr-xpr_4_0.xclbin
Loading: 'xclbin/vector_addition.sw_emu.xilinx_kcu1500_4ddr-xpr_4_0.xclbin'
Result = 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 
TEST PASSED

実機実装する場合

以下のコマンドを実行し,コンパイルする.1時間程度かかります.

$make all TARGETS=hw

コンパイルが終わったら,以下のコマンドを実行し,ボードインストールファイルを生成する.

xbinst --platform xilinx_kcu1500_4ddr-xpr_4_0 -z -d .

生成されたフォルダ内に,install.shが作られているので,実行する.

./install.sh

実行が完了すると,setup.shが生成される.

source ./setup.sh

以下のコマンドを実行することで,プログラムを実行する

./helloworld

プログラムの実行が終わると

sdaccel_profile_summary.html
が生成され,各APIの呼び出しにかかる時間,動作周波数が記載されている.
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1