トップ 差分 一覧 Farm ソース 検索 ヘルプ PDF RSS ログイン

FrontPage

みよ@わさもん.ねっと

遊んだこととか、ちょっとしたメモを書いています。

 最近の更新

Diary/2025-2-23 / Diary/2025-2-13 / Diary/2025-2-20 / Diary/2025-2-16 / Diary/2025-2-15


 Miyo's Diaryの最新の1件

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でスレッド数を切り換えて楽しめる.