大模型-高通平台性能测试示例-2
一、qnn-profile-viewer 获取性能数据
在QNN中,可以使用qnn-net-run
(genis-t2t-run)和qnn-profile-viewer
这两个工具来进行推理的性能分析。支持在QNX操作系统或Android操作系统上进行性能分析。QNN目前支持四种性能分析类型,分别是:
-
Basic Profiling(基本性能分析):提供基本的性能数据,如运行时间、资源消耗等。
-
Detailed Profiling(详细性能分析):提供更详细的性能数据,可能包括各个操作的执行时间、资源使用情况等。
-
Lint Profiling(代码检查性能分析):是指在性能分析的同时进行代码质量检查,以发现潜在的问题。
-
opTrace Profiling(操作跟踪性能分析):是指跟踪和分析神经网络中各个操作的性能,以优化网络结构或参数。
1. 获取调试的profiling 的基础数据。
qnn-net-run \
--backend libQnnHttp.so \
--retrieve_context xx.serialized.bin \
--input_list ./***
--output_dir ./profiling \
--profiling_level basic --perf_profile burst
2. 使用qnn-profile-viewer 解析基础数据
qnn-profile-viewer \
--reader libQnnHttpProfilingReader.so \
--input_log ./profiling/**** \
--output ./profiling/diaglog.csv > ./profiling/diaglog_out.txt
二、op算子级别的性能数据分析
1. 在离线模型生成时添加optrace选项
# generate <graph_name>_schematic.bin
qnn-context-binary-generator --model ./xx.so --backend libQnnHttp.so \
--binary_file xxx --profiling_option=optrace --profiling_level=detailed
2. qnn-net-run 工具运行QNN推理,并进行性能分析,获取数据。
qnn-net-run \
--backend libQnnHttp.so \
--retrieve_context xx.serialized.bin \
--input_list ./****
--output_dir ./optrace_profiling --perf_profile burst \
--profiling_option=optrace --profiling_level=detailed
3. 进行数据的分析解析
qnn-profile-viewer \
--reader libQnnHttpOptraceProfilingReader.so \
--schematic <graph_name>_schematic.bin \
--input_log ./*****
--output ./optrace_profiling/optrace.json
三、 Genis 性能测试
./genie-t2t-run -c ./internvlm.json -e input_concat_embs_dongzuoshibie.bin -t embedding_weights_92553x2048.raw --profile intervl_profile_data.json
四、高通sysprofiler app使用
高通在SA8295P HQX基线上提供的sysprofiler_app
工具,该工具用于分析和查询系统的关键性能信息,包括CPU、GPU、DDR、ADSP、CDSP、NET、MEM、Thermal等类型的性能数据。sysprofiler_app
是一个命令行工具,用于收集和分析系统的性能数据,通过这个工具,可以对系统的性能和负载有一个准确的度量,了解各个工况下各元器件的负载情况,以针对各个场景进行针对性的优化和处理。除了sysprofiler_app
这个命令行程序,高通还提供了sysprofiler.h
头文件和libsysprofiler.so
共享库。这些支持库可以帮助开发者编写代码开发系统性能监控软件,实现实时监控系统性能指标。高通提供了Overview文档,详细介绍了SYSProfiler的使用方法和原理。可以通过阅读这些文档来了解如何使用这些工具和库进行性能分析和监控。
4.1 安装步骤
Qnx 系统的使用说明文档路径:D:\Android_platform\qcom_app\sysprofiler_app_v2.4.0\sysprofiler_app_v2.4.0\howto\QNX-LoadBinaries.txt
测试步骤:
1: 连接台架的qnx系统2: mount -uw /mnt3: push so库和测试bin
push sysprofiler_app_v2.4.0/bin/QNXSDP710GEN4/libsysprofiler.so /mnt/lib64
push sysprofiler_app_v2.4.0/bin/QNXSDP710GEN4/libsysprofiler.so.1
push sysprofiler_app_v2.4.0/bin/QNXSDP710GEN4/libQProfilerInterface.so /mnt/lib64
push sysprofiler_app_v2.4.0/bin/QNXSDP710GEN4/sysprofiler_app /mnt/data4. 添加执行权限
cd /data/sysprofiler_app 5. 想要测试 ADSP profiling on Makena Gen4.
mount -uw /mnt
cp /ifs/etc/images/dsp/libsysmon* /mnt/etc/images/dsp/5. ./sysprofiler_app --cpu --gpu -> this starts cpu and gpu profiling.
6. ./sysprofiler_app --help -> this provides the available options.
4.2 查看指令
增加--json 可以生成json 文件,在perfetto 解析使用
# ./sysprofiler_app --help
Options provided in sysprofiler :
--cpu -> for CPU Load Profiling.
--cpu-ddr-bw -> for enabling CPU <-> DDR BW profiling //不支持
--gpu -> for GPU Utilization and GPU frequency
--adsp -> for ADSP load and frequency.
--cdsp -> for CDSP load and frequency.
--cdsp1 -> for CDSP1 load and frequency.
--gpdsp0 -> for GPDSP0 load and frequency.
--gpdsp1 -> for GPDSP1 load and frequency.
--io -> for IO subsystem profiling.
--ddr -> for DDR subsystem profiling.
--noc-bw -> for NOC level bandwidth profiling.
--mem -> for MEM profiling
--proc -> for PROC profiling
--thermal -> for THERMAL profiling
--procmem -> for PerProcess Memory Profiling //不支持
--gpu-proc -> for PerProcess GPU Profiling
--net -> For NET Profiling
--trace -> For enabling tracelogger
--thread -> For THREAD Profiling
--cpu-pmu -> For CPU PMU Profiling
--pmu-events -> Comma separated list of events for CPU PMU Profiling.
--gpu-freq -> in Mhz. This option adjusts the GPU Utilization accordingly.
--live -> for printing the live outputs
--json -> for converting the output to JSON
--csv -> for converting the output to CSV
--file <filename> -> for generating the logs with the particular name
--dir <dirname> -> Absolute path to the custom directory where results to be stored
--qtimer -> for enabling qtimer if supported on the device
--sample-time <time in ms> -> in milliseconds to set the sampling interval.
--total-time <time in s> -> in seconds to set the total profiling time
--pid-list -> list of comma separated pids for per process metrics
--cpu-sample-time <time in ms> -> adjusts the CPU sampling time
--gpu-sample-time <time in ms> -> adjusts the GPU sampling time
--adsp-sample-time <time in ms> -> adjusts the ADSP sampling time
--cdsp-sample-time <time in ms> -> adjusts the CDSP sampling time
--cdsp1-sample-time <time in ms> -> adjusts the CDSP1 sampling time
--ddr-sample-time <time in ms> -> adjusts the DDR sampling time
--mem-sample-time <time in ms> -> adjusts the MEM sampling time
--thermal-sample-time <time in ms> -> adjusts the THERMAL sampling time
--proc-sample-time <time in ms> -> adjusts the PROC sampling time
--io-sample-time <time in ms> -> adjusts the DISKIO sampling time
--procmem-sample-time <time in ms> -> adjust the PROCMEM sampling time
--net-sample-time -> adjusts the NET sampling time
--trace-sample-time -> adjusts the TRACE sampling time in ms
--thread-sample-time -> adjusts the THREAD sampling time
--cpu-pmu-sample-time -> adjusts the CPU PMU sampling time in ms
--cpu-ddr-bw-sample-time -> adjusts the CPU<->DDR BW sampling time in ms
--log <level> -> Prints logs (0:No logs, 1:Err, 2:Warn, 3:Info)
--version -> prints the version of the sysprofiler
--help -> Prints this help menu