Aleksei_Rostov
Свой-
Постов
313 -
Зарегистрирован
-
Посещение
Репутация
0 ОбычныйИнформация о Aleksei_Rostov
-
Звание
Местный
- День рождения 03.04.1985
Старые поля
-
skype
Array
-
LinkedIn
Array
Контакты
-
Сайт
Array
-
ICQ
Array
-
Skype
Array
Информация
-
Город
Array
-
Оптимизация for loop на Си
Aleksei_Rostov ответил Aleksei_Rostov тема в Программирование
Тему можно закрыть. Разница в скорости вычислений связана с размером кэш памяти (L1, L2) для машины с Ubuntu и linux на Cortex a53. Для распараллеливания использовал Pthread, что не намного, но быстрее оказалось, чем OpenMP. -
Оптимизация for loop на Си
Aleksei_Rostov опубликовал тема в Программирование
Добрый день! Пытаюсь ускорить выполнение функции сортировки массива по индексам, которая запускается на Cortex a53. Оптимизируемая функция rd_rotation_old. Новая функция rd_rotation. #include <errno.h> #include <getopt.h> #include <poll.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <unistd.h> #include <math.h> #include <omp.h> #include <fcntl.h> #define TxChnl 3 #define RxChnl 16 #define Nchirp 128 #define NrFFT 2048 #define FFTR_REAL 1 #define CHIRP_MUX 4 /* chirp multiplexing in raw data */ #define N_TX_PER_CHIP 3 //NUM_TX_PER_DM #define FFT_WIDTH 2048 typedef struct { int16_t re; int16_t im; } cplx_int16_t; typedef struct { cplx_int16_t val[4]; } cplx_int16x4_t; void rd_rotation_old(void *in[], size_t in_buf_num, size_t n_tx_ch, size_t n_rx_ch, size_t n_bins, size_t n_chirps_per_slot, void *out[], size_t out_buf_num) { const cplx_int16x4_t *p; cplx_int16x4_t * out_p; unsigned int d_bin_idx; /* bin index in doppler fft input */ unsigned int tdm_bin_off; unsigned int tdm_bin_idx; unsigned int chip_off; /* chip offset in the output buffer */ unsigned int n_bins_proc = (FFTR_REAL ? n_bins / 2 : n_bins); size_t n_chirps = n_chirps_per_slot * n_tx_ch; /*how many x4 samples per single chip*/ chip_off = (n_chirps * n_bins_proc); for (int idx_buf = 0; idx_buf < in_buf_num; idx_buf++) { out_p = (cplx_int16x4_t *)out[idx_buf]; for (int idx_chirp = 0; idx_chirp < n_chirps * CHIRP_MUX; idx_chirp++) { /* stride over separate chirp */ p = (cplx_int16x4_t *)in[idx_buf] + (idx_chirp * n_bins); d_bin_idx = idx_chirp / CHIRP_MUX; tdm_bin_idx = (d_bin_idx / n_tx_ch); tdm_bin_off = ((d_bin_idx % n_tx_ch) * n_chirps_per_slot); for (int idx_smpl = 0; idx_smpl < n_bins_proc; idx_smpl++, p++) { *(out_p + idx_smpl * n_chirps + chip_off * (idx_chirp % CHIRP_MUX) + tdm_bin_off + tdm_bin_idx) = *p; } } } } void rd_rotation(cplx_int16x4_t *array_in, size_t n_tx_ch, size_t n_rx_ch, size_t n_bins, size_t n_chirps_per_slot, cplx_int16x4_t *array_out ) { unsigned int blockTxRx = n_tx_ch*n_rx_ch/4*n_bins; unsigned int blockTx = n_rx_ch/4*n_bins; unsigned int blockRx = n_bins/4*4; unsigned int ptr_out = 0; unsigned int rx = 0, rbin = 0, tx = 0, nChirp = 0; unsigned int tmp_tx = 0; // #pragma omp parallel { // #pragma omp for for ( rx = 0; rx < n_rx_ch/4; ++rx ){ for( rbin = 0; rbin < n_bins/2; ++rbin ){ for( tx = 0; tx < n_tx_ch; ++tx ){ tmp_tx = tx*blockTx + rbin; for( nChirp = 0; nChirp < n_chirps_per_slot; ++nChirp) { ptr_out = nChirp + rx*TxChnl*NrFFT/2*Nchirp + rbin*TxChnl*Nchirp + tx*Nchirp; *(array_out + ptr_out) = *(array_in + nChirp*blockTxRx + tmp_tx + rx*blockRx); } // nChirp } // tx } // rbin } // rx } // omp } // m2nF9zXyiBRD int main() { printf("<- Start Application \n"); #ifdef _OPENMP printf("<- OpenMP is supported \n"); #endif cplx_int16x4_t *cube_in, *cube_out, *cube_gld; cube_in = (cplx_int16x4_t *)malloc(Nchirp*TxChnl*RxChnl/4*NrFFT*sizeof(cplx_int16x4_t)); cube_out = (cplx_int16x4_t *)malloc(Nchirp*TxChnl*RxChnl/4*NrFFT/2*sizeof(cplx_int16x4_t)); cube_gld = (cplx_int16x4_t *)malloc(Nchirp*TxChnl*RxChnl/4*NrFFT/2*sizeof(cplx_int16x4_t)); void *cube_in_arr[1] = {cube_in}; void *cube_out_arr[1] = {cube_gld}; if(cube_in == NULL || cube_out == NULL || cube_gld == NULL) { printf("Error malloc \n"); exit(-1); } printf("<- Output buffers initialization \n"); for(int i = 0; i < Nchirp*TxChnl*RxChnl/4*NrFFT/2; i ++) for(int k = 0; k < 4; k ++) { cube_out[i].val[k].re = (int16_t)rand() % 16382; cube_out[i].val[k].im = (int16_t)rand() % 16382; cube_gld[i].val[k].re = (int16_t)rand() % 16382; cube_gld[i].val[k].im = (int16_t)rand() % 16382; } for(int i = 0; i < Nchirp*TxChnl*RxChnl/4*NrFFT; i ++) for(int k = 0; k < 4; k ++) { cube_in[i].val[k].re = (int16_t)rand() % 16382; cube_in[i].val[k].im = (int16_t)rand() % 16382; } size_t in_buf_num = 1; size_t n_tx_ch = (size_t)TxChnl; size_t n_rx_ch = (size_t)RxChnl; size_t n_bins = (size_t)NrFFT; size_t n_chirps_per_slot = (size_t)Nchirp; size_t out_buf_num = 1; double start, end, runTime; start = omp_get_wtime(); rd_rotation_old( (void *)&cube_in_arr, in_buf_num, n_tx_ch, n_rx_ch, n_bins, n_chirps_per_slot, (void *)&cube_out_arr, out_buf_num); end = omp_get_wtime(); runTime = end - start; printf("<- rd_rotation_old run time is %g ms \n", runTime*1000); start = omp_get_wtime(); rd_rotation(&cube_in[0], n_tx_ch, n_rx_ch, n_bins, n_chirps_per_slot, &cube_out[0]); end = omp_get_wtime(); runTime = end - start; printf("<- rd_rotation run time is %g ms \n", runTime*1000); int32_t diff = 0; for(int i = 0; i < Nchirp*TxChnl*RxChnl/4*NrFFT/2; i ++) for(int k = 0; k < 4; k ++) diff += (int32_t)abs(cube_out[i].val[k].re-cube_gld[i].val[k].re+cube_out[i].val[k].im-cube_gld[i].val[k].im); printf("<- Check difference: error is %d \n", diff); free(cube_in); free(cube_out); free(cube_gld); printf("<- End Application \n"); return 0; } Запускаю на на виртуальной машине с Ubuntu x86-64 gcc -Wall -O3 -fopenmp -o main main.c ./main <- Start Application <- OpenMP is supported <- Output buffers initialization <- rd_rotation_old run time is 21.8302 ms <- rd_rotation run time is 9.4134 ms <- Check difference: error is 0 <- End Application Запускаю на Cortex A53 aarch64-linux-gnu-gcc -Wall -O3 -fopenmp -o main main.c ./main <- Start Application <- OpenMP is supported <- Output buffers initialization <- rd_rotation_old run time is 86.7562 ms <- rd_rotation run time is 282.807 ms <- Check difference: error is 0 <- End Application И там и там работают 4 ядра, но результаты противоположные. Вопрос: как можно ускорить rd_rotation в том числе и с использованием OpenMP? И в чем причина различий во времени выполнения кода ? -
Скорее всего, убрал bootdelay и автозапуск заработал. Спасибо
-
Почему то уже не отрабатывает. В версии u-boot до того как автозагрузку начал реализовывать, задержка отрабатывалась
-
Добрый день! Подскажите пожалуйста, что необходимо прописать в envoriment u-boot а для автозагрузки Линукса из QSPI? Создал BOOT.BIN (fsbl.elf, pmufw.elf, system.bit, bl31.elf, u-boot.elf, image.itb) для Zynq MP, залил в QSPI. После подачи питания и загрузки u-boot в терминале читаю image.itb в RAM и запускаю Линукс: sf probe 0 sf read 0x60000000 0x00000000 0xF00000 bootm 0x60000000 Теперь хочу автоматизировать загрузку. Прописал в CONFIG_EXTRA_ENV_SETTINGS u-boot'а #define CONFIG_EXTRA_ENV_SETTINGS \ "distro_bootcmd=sf probe 0 && sf read 0x60000000 0x800000 0x700000 && bootm 0x60000000\0" \ "" Загрузка получается только после команды boot в терминале Xilinx Zynq MP First Stage Boot Loader Release 2019.1 Mar 3 2021 - 13:12:50 NOTICE: ATF running on XCZU3EG/silicon v4/RTL5.1 at 0xfffea000 NOTICE: BL31: Secure code at 0x0 NOTICE: BL31: Non secure code at 0x8000000 NOTICE: BL31: v2.0(release):xilinx-v2018.3-720-g80d1c790 NOTICE: BL31: Built : 13:12:14, Mar 3 2021 U-Boot 2020.01-00031-ga604ef9-dirty (Mar 05 2021 - 00:47:52 -0800) Board: Xilinx ZynqMP DRAM: 2 GiB usb dr_mode not found PMUFW: v1.1 EL Level: EL2 Chip ID: zu3eg NAND: 0 MiB MMC: mmc@ff160000: 0, mmc@ff170000: 1 In: serial@ff000000 Out: serial@ff000000 Err: serial@ff000000 Bootmode: QSPI_MODE Reset reason: EXTERNAL Net: ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr -1, interface rgmii-id Could not get PHY for eth0: addr -1 No ethernet found. U-BOOT for sl_zynqmp Hit any key to stop autoboot: 0 ZynqMP> printenv arch=arm baudrate=115200 board=zynqmp board_name=zynqmp boot_targets=qspi0 bootcmd=run distro_bootcmd bootdelay=2 bootm_low=0 bootm_size=7ff00000 cpu=armv8 distro_bootcmd=sf probe 0 && sf read 0x60000000 0x800000 0x700000 && bootm 0x60000000 ethaddr=00:0a:35:00:22:01 fdtcontroladdr=7dda32a8 fdtfile=xilinx/zynqmp.dtb ipaddr=192.168.0.123 modeboot=qspiboot reset_reason=EXTERNAL script_offset_f=3e80000 serverip=192.168.0.21 soc=zynqmp stderr=serial@ff000000 stdin=serial@ff000000 stdout=serial@ff000000 vendor=xilinx Environment size: 583/32764 bytes ZynqMP> ZynqMP> boot SF: Detected n25q512a with page size 512 Bytes, erase size 128 KiB, total 128 MiB device 0 offset 0x800000, size 0x700000 SF: 7340032 bytes @ 0x800000 Read: OK ## Loading kernel from FIT Image at 60000000 ... Using 'conf-1' configuration Trying 'kernel-1' kernel subimage Description: Linux Kernel Type: Kernel Image Compression: gzip compressed Data Start: 0x600000c0 Data Size: 3680269 Bytes = 3.5 MiB Architecture: AArch64 OS: Linux Load Address: 0x00080000 Entry Point: 0x00080000 Hash algo: sha1 Hash value: 14723a2c892b059fef5585ee0b1b03e3c9e090fb Verifying Hash Integrity ... sha1+ OK ## Loading ramdisk from FIT Image at 60000000 ... Using 'conf-1' configuration Trying 'ramdisk-1' ramdisk subimage Description: RAMDisk Image Type: RAMDisk Image Compression: lzma compressed Data Start: 0x60389b58 Data Size: 3271927 Bytes = 3.1 MiB Architecture: AArch64 OS: Linux Load Address: 0x10000000 Entry Point: 0x10000000 Hash algo: sha1 Hash value: ce3929849a5e71b2dabe2d05d8dff2bb8a380c4e Verifying Hash Integrity ... sha1+ OK Loading ramdisk from 0x60389b58 to 0x10000000 WARNING: 'compression' nodes for ramdisks are deprecated, please fix your .its file! ## Loading fdt from FIT Image at 60000000 ... Using 'conf-1' configuration Trying 'fdt-1' fdt subimage Description: Flattened Device Tree blob Type: Flat Device Tree Compression: uncompressed Data Start: 0x603829c8 Data Size: 28864 Bytes = 28.2 KiB Architecture: AArch64 Hash algo: sha1 Hash value: 44dcf97d89cd102df5c89916b8238a4f9d57cf75 Verifying Hash Integrity ... sha1+ OK Booting using the fdt blob at 0x603829c8 Uncompressing Kernel Image Loading Ramdisk to 7da82000, end 7dda0cf7 ... OK Loading Device Tree to 000000007da77000, end 000000007da810bf ... OK Starting kernel ... [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
-
NAND for Zynq Ultrascale+
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
у меня еще запасной вариант был: сборка MTD модуля для Arasan вручную с пошаговой отладкой исходников, но до этого дело не дошло... -
NAND for Zynq Ultrascale+
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
Посмотрите эти ветки, там zip есть https://forums.xilinx.com/t5/ACAP-and-SoC-Boot-and/ZynqMP-Ultrascale-Boot-from-NAND-error-from-SD-good/td-p/1072801 https://forums.xilinx.com/t5/Embedded-Linux/NAND-Flash-U-Boot-is-using-on-die-ECC-instead-of-HW-ECC/td-p/1020626 https://forums.xilinx.com/t5/Embedded-Linux/PetaLinux-2019-1-with-micron-NAND-unable-to-write-bad-block/td-p/1070934 -
NAND for Zynq Ultrascale+
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
В проекте решили проблему переходником на eMMC. Как я понял, проблема с MTD_NAND_ARASAN драйвером в ядре: с версией ядра 4.19 все работает (она у вас по дефолту в petalinux 2019.1), а с версией 5.4 (в petalinux 2020.1) нужно патчить драйвер, патч нашел, но уже необходимость отпала -
NAND for Zynq Ultrascale+
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
Перебрал DT, NAND при запуске Линукса видна. Не понятно почему Линукс виснет при проверке BBT. Что необходимо сделать? [ 4.852848] nand: device found, Manufacturer ID: 0x2c, Chip ID: 0xd3 [ 4.859206] nand: Micron MT29F8G08ABACAH4 [ 4.863212] nand: 1024 MiB, SLC, erase size: 256 KiB, page size: 4096, OOB size: 224 [ 38.018693] Bad block table not found for chip 0 [ 83.074693] Bad block table not found for chip 0 [ 83.079309] Scanning device for bad blocks [ 84.098694] nand_bbt: error while erasing BBT block -5 [ 85.122693] nand_bbt: error while erasing BBT block -5 [ 86.146693] nand_bbt: error while erasing BBT block -5 [ 87.170693] nand_bbt: error while erasing BBT block -5 [ 87.175825] No space left to write bad block table [ 87.180606] nand_bbt: error while writing bad block table -28 [ 87.186396] arasan-nand-controller ff100000.nand: nand_scan_tail for NAND failed [ 96.386692] nand: No NAND device found [ 96.390431] arasan-nand-controller ff100000.nand: nand_scan_tail for NAND failed [ 105.602691] nand: No NAND device found [ 105.606429] arasan-nand-controller ff100000.nand: nand_scan_tail for NAND failed -
Buildroot with custom DTS file
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
Спасибо! Получилось! -
Buildroot with custom DTS file
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
Тоже так делал - все равно ошибка. Может нужно все эти файлы (dts и все dtsi) в BR2_LINUX_KERNEL_CUSTOM_DTS_PATH прописать? Сейчас у меня так BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/kernel.dts" А сделать вот так BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/kernel.dts" BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/first.dtsi" BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/second.dtsi" ... BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/n.dtsi" -
Buildroot with custom DTS file
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
За ссылку спасибо, у меня dtsi файлы, на них команды cp нет. Я переименовал dtsi в dts, но все равно не видит инклюды DTC arch/arm64/boot/dts/kernel.dtb arch/arm64/boot/dts/kernel.dts:9:22: fatal error: zynqmp.dts: No such file or directory compilation terminated. scripts/Makefile.lib:299: recipe for target 'arch/arm64/boot/dts/kernel.dtb' failed make[3]: *** [arch/arm64/boot/dts/kernel.dtb] Error 1 Makefile:1243: recipe for target 'kernel.dtb' failed make[2]: *** [kernel.dtb] Error 2 package/pkg-generic.mk:247: recipe for target '/home/zynq/trenz-us/build/linux-xilinx-v2020.1/.stamp_built' failed make[1]: *** [/home/zynq/trenz-us/build/linux-xilinx-v2020.1/.stamp_built] Error 2 Makefile:23: recipe for target '_all' failed make: *** [_all] Error 2 файл kernel.dts /* * CAUTION: This file is automatically generated by Xilinx. * Version: * Today is: Sat Dec 19 18:33:06 2020 */ /dts-v1/; #include "/home/zynq/trenz_buildroot/board/trenz_mp/zynqmp.dts" #include "/home/zynq/trenz_buildroot/board/trenz_mp/zynqmp-clk-ccf.dts" #include "/home/zynq/trenz_buildroot/board/trenz_mp/pl.dts" #include "/home/zynq/trenz_buildroot/board/trenz_mp/pcw.dts" #include "/home/zynq/trenz_buildroot/board/trenz_mp/system-user.dts" / { chosen { bootargs = "earlycon clk_ignore_unused"; stdout-path = "serial0:115200n8"; }; aliases { ethernet0 = &gem3; i2c0 = &axi_iic_sens1; i2c1 = &i2c0; i2c2 = &i2c1; serial0 = &uart0; spi0 = &qspi; }; memory { device_type = "memory"; reg = <0x0 0x0 0x0 0x7ff00000>; }; cpus { /delete-node/ cpu@2 ; /delete-node/ cpu@3 ; }; }; -
Buildroot with custom DTS file
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
u-boot я тоже не собираю buildroot'ом. По kernel вопросов нет, путь к конфигу ядра прописан, кроме того в конфиге buildroot'а задаю версию ядра. Решение пока нашел что называется "в лоб": убрал все инклюды и добавил все в один файл kernel.dts. Это не очень хорошо, т.к. в каждом инклюде был определенный DT (например для PL части Zynq Ultrascale+ или отдельно все что касается памяти) -
Buildroot with custom DTS file
Aleksei_Rostov опубликовал тема в Linux
Добрый день! Может есть специалисты по Buildroot, подскажите пожалуйста как в конфиг Buildroot'a правильно прописать внешний dts файл с dtsi инклюдами. Сейчас использую: BR2_LINUX_KERNEL_DTS_SUPPORT=y BR2_LINUX_KERNEL_USE_CUSTOM_DTS=y BR2_LINUX_KERNEL_CUSTOM_DTS_PATH="$(BR2_EXTERNAL_TRENZ_PATH)/board/trenz_mp/kernel.dts" В kernel.dts есть include'ы для файлов .dtsi и чтобы скомпилировать kernel.dts пути для dtsi приходится задавать абсолютные, но необходимо относительные. Как правильно указать Buildroot'у где находятся dtsi файлы, которые читает kernel.dts? -
NAND for Zynq Ultrascale+
Aleksei_Rostov ответил Aleksei_Rostov тема в Linux
Компиляция DT с инклюдами не исправила проблему. Собрал образ из сборки Buildroot'ом с настройками kernel от petalinux # dmesg | grep nand -i [ 6.621228] jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc. # dmesg |grep mtd -i [ 6.711807] mtdoops: mtd device (mtddev=name/number) must be supplied # не видит Linux Nand