KCU1500+SCAccelの環境構築

Pocket

うっかりyum updateしてしまったCentOSにSDAccel環境を構築しました.スペックはこんな感じ.

  • CentOS Linux release 7.5.1804 (Core)
  • 3.10.0-862.11.6.el7.x86_64
  • SDx 2018.2

ドライバのインストールにこんな driver.patch が必要でした,というメモ.

準備

SDxインストール時にインストールされるxbinstでリソースを準備

% xbinst -f xilinx_kcu1500_dynamic_5_0 -d kcu1500

これで,kcu1500以下にFPGA用のMCSやドライバ一式が用意される.firmware以下のmcsをFPGAに書きこみ.mcsを書き込むROMは,mt25qu512-spi-x1_x2_x4_x1で,primary.mcsとsecondary.mcsを,PRM fileとPRM file 2にそれぞれ書き込めばOKです.

コンパイルエラー…

ドライバをインストールすべく ./install.sh とかすると,コンパイルーエラー.どうも

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)

とかして,(おそらく)UbuntとCentOSのカーネルに対応しようとしている部分がカーネル 3.10.0 が,うまくあわなくて邪魔しているっぽい.

修正

install.shでは,runtime/platforms/xilinx_kcu1500_dynamic_5_0/driver/xocl.zipを展開してコンパイルしている.なので,手間最小で修正するために,runtime/platforms/xilinx_kcu1500_dynamic_5_0/driver/xocl.zipを展開して修正,再度zipファイルにまとめる.

対象は,

  • driver/xclng/drm/xocl/xocl_drv.h
  • driver/xclng/drm/xocl/subdev/icap.c
  • driver/xclng/drm/xocl/userpf/xocl_bo.c
  • driver/xclng/drm/xocl/userpf/xocl_drm.c
  • driver/xclng/drm/xocl/userpf/xocl_ioctl.c

driver/xclng/drm/xocl/xocl_drv.h

4.5.0より前のバージョンでは

static inline bool uuid_equal(const xuid_t *u1, const xuid_t *u2)
static inline void uuid_copy(xuid_t *dst, const xuid_t *src)
static inline bool uuid_is_null(const xuid_t *uuid)

が存在しないので定義している部分.私の環境には存在していて衝突してるので #if 0 で 無効に.

driver/xclng/drm/xocl/subdev/icap.c

同様に,

static xuid_t uuid_null = NULL_UUID_LE;

が衝突しているので#if 0 で 無効に.

driver/xclng/drm/xocl/userpf/xocl_bo.c

4.13.0以降では,drm_free_largeがないらしく

44 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
46 static inline void drm_free_large(void *ptr)
47 {
48 kvfree(ptr);
49 }
50
51 static inline void *drm_malloc_ab(size_t nmemb, size_t size)
52 {
53 return kvmalloc_array(nmemb, sizeof(struct page *), GFP_KERNEL);
54 }
55 #endif

と,定義しているのだけど,私の環境にもないので,#if 1 とかして有効に.

driver/xclng/drm/xocl/userpf/xocl_drm.c

4.13.0以降では,drm_mm_insert_node_genericの引数が一つ少ないらしい

413 int xocl_mm_insert_node(struct xocl_dev *xdev, u32 ddr,
414 struct drm_mm_node *node, u64 size)
415 {
416 return drm_mm_insert_node_generic(&xdev->mm[ddr], node, size, PAGE_SIZE,
417 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
419 0, 0);
420 #else
421 0, 0, 0);
422 #endif
423 }

私の環境でも,一つ少ないので,これも,#if 1 で有効に.

driver/xclng/drm/xocl/userpf/xocl_ioctl.c

同様に,

29 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
31 xuid_t uuid_null = NULL_UUID_LE;
32 #endif

が衝突しているので,#if 0 で無効に.

まとめると,こんな感じ.

インストールがおわった

インストールを終えて再起動すると,

01:00.0 Serial controller: Xilinx Corporation Device 4b88 (prog-if 01 [16450])
Subsystem: Xilinx Corporation Device 4350
Flags: bus master, fast devsel, latency 0, IRQ 16
Memory at da000000 (32-bit, non-prefetchable) [size=32M]
Memory at dc040000 (32-bit, non-prefetchable) [size=64K]
Capabilities: <access denied>
Kernel driver in use: xocl_xdma
Kernel modules: xocl

01:00.1 Serial controller: Xilinx Corporation Device 4b87 (prog-if 01 [16450])
Subsystem: Xilinx Corporation Device 4350
Flags: fast devsel
Memory at d8000000 (32-bit, non-prefetchable) [size=32M]
Memory at dc020000 (32-bit, non-prefetchable) [size=128K]
Memory at dc000000 (32-bit, non-prefetchable) [size=128K]
Capabilities: <access denied>
Kernel driver in use: xclmgmt
Kernel modules: xclmgmt

な感じでデバイスがみえた,よかった.

使ってみる

https://github.com/Xilinx/SDAccel_Examples を cloneしてサンプルをコンパイル,実行してみる.

git clone https://github.com/Xilinx/SDAccel_Examples.git
cd SDAccel_Example
git checkout -b 2018.2 origin/2018.2
source /opt/Xilinx/SDx/2018.2/settings64.sh 
cd getting_started/host/helloworld_ocl
make all TARGETS=hw DEVICES=xilinx_kcu1500_dynamic

とか.しばらく待つと合成・配置配線,ビットストリーム生成の一連のフローが完了.
rootで,

./helloword

として,実行.

Found Platform
Platform Name: Xilinx
Found Device=xilinx_kcu1500_dynamic_5_0
XCLBIN File Name: vector_addition
INFO: Importing xclbin/vector_addition.hw.xilinx_kcu1500_dynamic.xclbin
Loading: 'xclbin/vector_addition.hw.xilinx_kcu1500_dynamic.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

とか.sdaccel_profile_summary.csv に実行結果が出力されている(っぽい).
なお,実行後にdmesgしてみると,

[ 4248.157807] [drm] scheduler client created pid(8433)
[ 4248.158271] xocl_xdma 0000:01:00.0: xocl_mmap: io_remap_pfn_range ret code: 0
[ 4248.158311] xclmgmt 0000:01:00.1: char_open: opened file ffff9e0348ef4b00 by pid: 8433
[ 4248.158328] xclmgmt 0000:01:00.1: bridge_mmap: mmap(): bar 0, phys:0xd8000000, vsize:33554432, psize:33554432
[ 4248.158770] xclmgmt: version_ioctl
[ 4248.158778] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.158832] xclmgmt: version_ioctl
[ 4248.158839] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.178936] icap.m icap.m.257: icap_download_bitstream_axlf: copy-in headers, num sections: 7, size: 776
[ 4248.178948] icap.m icap.m.257: icap_download_bitstream_axlf: incoming xclbin ID: 000000005b933319, on device xclbin ID:000000005b933319
[ 4248.178952] icap.m icap.m.257: icap_freeze_axi_gate: freezing AXI gate
[ 4248.229019] icap.m icap.m.257: icap_free_axi_gate: freeing AXI gate
[ 4248.229038] icap.m icap.m.257: reset_scheduler: calling xocl_reset_scheduler
[ 4248.280036] icap.m icap.m.257: icap_download_bitstream_axlf: bitstream already exists, skip downloading
[ 4248.280057] xocl_xdma 0000:01:00.0: xocl_read_axlf_ioctl_helper: READ_AXLF IOCTL
[ 4248.280063] XOCL: Marker 0 ffff9e069ebabdc8
[ 4248.280068] XOCL: VBNV and TimeStamps matched
[ 4248.280079] icap.u icap.u.256: icap_lock_bitstream: proc 8433 try to lock bitstream 36cf8c5a-7c67-4805-9ae6-523dcccc0b47, ref=0, err=0
[ 4248.280082] Skipping repopulating topology, connectivity,ip_layout data
[ 4248.280086] xocl_read_axlf_ioctl_helper err: 0
[ 4248.280095] xclmgmt: version_ioctl
[ 4248.280104] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.280453] [drm] ert per feature rom = 0
[ 4248.280463] [drm] scheduler config ert(0) slots(16), cudma(1), cuisr(1), cus(1), cu_shift(16), cu_base(0x1800000), cu_masks(1)
[ 4248.283167] xclmgmt: version_ioctl
[ 4248.283180] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.283535] xclmgmt: version_ioctl
[ 4248.283544] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.283583] xclmgmt: version_ioctl
[ 4248.283590] xclmgmt 0000:01:00.1: device_info: MIG Calibration: 1
[ 4248.287743] icap.u icap.u.256: icap_unlock_bitstream: proc 8433 try to unlock bitstream 36cf8c5a-7c67-4805-9ae6-523dcccc0b47, ref=0, err=0
[ 4248.287750] [drm] client exits pid(8433)
[ 4248.287769] xclmgmt 0000:01:00.1: char_close: Closing file ffff9e0348ef4b00 by pid: 8433

とかいってて,FPGAたたいたんだろうな?という感じがみえる.

KCU1500+SCAccelの環境構築」への1件のフィードバック

  1. ピンバック: KCU1500+SDAccelの環境構築(Ubuntu 16.04.03編) | わさらぼ

コメントは停止中です。