トップ 一覧 Farm 検索 ヘルプ RSS ログイン

Diary/2025-2-25の変更点

  • 追加された行はこのように表示されます。
  • 削除された行はこのように表示されます。
!Petalinuxでstreamを追加
Petalinuxな環境で定番のstreamでメモリ転送速度の測定をする.
...というのをネタに,Petalinuxでのアプリ追加の例.
streamは,https://github.com/jeffhammond/STREAM から.

OpenMPを使いたいので project-spec/meta-user/conf/user-rootfsconfig に
 CONFIG_libgomp
 CONFIG_libgomp-dev
 CONFIG_libgomp-staticdev
を追加する.
で,まずは,アプリのテンプレートを追加.
 petalinux-create -t apps --template c --name stream --enable
これで,project-spec/meta-user/recipes-apps/stream/にアプリ用のディレクトリができる.
テンプレートで作成される project-spec/meta-user/recipes-apps/stream/files/stream.c は,
https://github.com/jeffhammond/STREAM/blob/master/stream.c
でバサっとおきかえる.
 #define STREAM_ARRAY_SIZE 100000000
とかすると,メモリが2.2GBくらい使われる.
project-spec/meta-user/recipes-apps/stream/files/Makefile は,
次のように.
 APP = stream
 
 # Add any other object files to this list below
 APP_OBJS = stream.o
 
 all: build
 
 build: $(APP)
 
 CFLAGS += -O2 -fopenmp
 
 $(APP): $(APP_OBJS)
         $(CC) -o $@ $(APP_OBJS) $(LDFLAGS) $(LDLIBS) -O2 -fopenmp
 clean:
         rm -f $(APP) *.o
CFLAGS += -O2 -fopenmpがキモ.
あとは,
 petalinux-build
 petalinux-package --boot --plm --psmfw --u-boot --dtb --force
して,images/linux{BOOT.BIN,boot.scr,Image,rootfs.cpio.gz.u-boot}をSDカードにコピー.
OMP_NUM_THREADSでスレッド数を切り換えて楽しめる.