(2) 我的结果- spec2006中精确的simulation points执行点

本文介绍SPEC2006基准测试环境下SimPoints的生成过程及关键参数设置,包括使用的SPEC版本、输入配置、周期设定及具体脚本。文中还列举了权重较高的模拟点及其对应的基准测试程序。

spec06中获取simpoints的环境说明:

  • spec的版本为spec2006v1.0;
  • 使用ref input with runspec;
  • 100millions为周期生成的simpoints;
  • 使用脚本为$GEM5_DIR/build/ALPHA/gem5.fast --outdir=$OUTPUT_DIR $GEM5_DIR/configs/example/spec06_se.py --benchmark=$BENCHMARK --benchmark_st
    dout=$OUTPUT_DIR/$BENCHMARK.out --benchmark_stderr=$OUTPUT_DIR/$BENCHMARK.err --simpoint-profile --simpoint-interval=100000000 --
    fastmem | tee -a $SCRIPT_OUT
  • 生成的simpoint.bb.gz(文件过大已失效)和spec06simpoints;

权重最大的模拟点统计如下:

idCINT06(12个)Simpoint
1400.perlbenchpanic: fault (unalign)
2401.bzip23792
3403.gccpanic
4429.mcf3060
5445.gobmk530
6456.hmmer3313
7458.sjeng14714
8462.libquantum15117
9464.h264ref5271
10471.omnetpp3772
11473.astar3287
12483.xalancbmkpanic: fault (arith)

idCFP06(17个)Simpoint
13410.bwaves45020
14416.gamess8582
15433.milc8221
16434.zeusmp3629
17435.gromacs20013
18436.cactusADMpanic: fault (unalign)
19437.leslie3d2236
20444.namd7471
21447.dealII35
22450.soplex2274
23453.povray2467
24454.calculix18931
25459.GemsFDTD4385
26465.tonto9316
27470.lbm615
28481.wrfrunning more than 1mouth
29482.sphinx324340

说明:481.wrf还在运行中。

帮我整理下面的help,配置参数的意义,可以设置的值,请详细介绍列出来:ubuntu@studyubuntu:~/gem5$ build/X86/gem5.opt configs/deprecated/example/se.py --help gem5 Simulator System. https://www.gem5.org gem5 is copyrighted software; use the --copyright option for details. gem5 version 25.0.0.1 gem5 compiled Oct 15 2025 14:07:26 gem5 started Oct 22 2025 14:01:40 gem5 executing on studyubuntu, pid 3588 command line: build/X86/gem5.opt configs/deprecated/example/se.py --help warn: The se.py script is deprecated. It will be removed in future releases of gem5. usage: se.py [-h] [-n NUM_CPUS] [--sys-voltage SYS_VOLTAGE] [--sys-clock SYS_CLOCK] [--list-mem-types] [--mem-type {CfiMemory,DDR3_1600_8x8,DDR3_2133_8x8,DDR4_2400_16x4,DDR4_2400_4x16,DDR4_2400_8x8,DDR5_4400_4x8,DDR5_6400_4x8,DDR5_8400_4x8,DRAMInterface,GDDR5_4000_2x32,HBM_1000_4H_1x128,HBM_1000_4H_1x64,HBM_2000_4H_1x64,HMC_2500_1x32,LPDDR2_S4_1066_1x32,LPDDR3_1600_1x32,LPDDR5_5500_1x16_8B_BL32,LPDDR5_5500_1x16_BG_BL16,LPDDR5_5500_1x16_BG_BL32,LPDDR5_6400_1x16_8B_BL32,LPDDR5_6400_1x16_BG_BL16,LPDDR5_6400_1x16_BG_BL32,NVMInterface,NVM_2400_1x64,QoSMemSinkInterface,SimpleMemory,WideIO_200_1x128}] [--mem-channels MEM_CHANNELS] [--mem-ranks MEM_RANKS] [--mem-size MEM_SIZE] [--enable-dram-powerdown] [--mem-channels-intlv MEM_CHANNELS_INTLV] [--memchecker] [--external-memory-system EXTERNAL_MEMORY_SYSTEM] [--tlm-memory TLM_MEMORY] [--caches] [--l2cache] [--num-dirs NUM_DIRS] [--num-l2caches NUM_L2CACHES] [--num-l3caches NUM_L3CACHES] [--l1d_size L1D_SIZE] [--l1i_size L1I_SIZE] [--l2_size L2_SIZE] [--l3_size L3_SIZE] [--l1d_assoc L1D_ASSOC] [--l1i_assoc L1I_ASSOC] [--l2_assoc L2_ASSOC] [--l3_assoc L3_ASSOC] [--cacheline_size CACHELINE_SIZE] [--ruby] [-m TICKS] [--rel-max-tick TICKS] [--maxtime MAXTIME] [-P PARAM] [--list-cpu-types] [--cpu-type {AtomicSimpleCPU,BaseAtomicSimpleCPU,BaseMinorCPU,BaseNonCachingSimpleCPU,BaseO3CPU,BaseTimingSimpleCPU,DerivO3CPU,NonCachingSimpleCPU,O3CPU,TimingSimpleCPU,X86AtomicSimpleCPU,X86KvmCPU,X86MinorCPU,X86NonCachingSimpleCPU,X86O3CPU,X86TimingSimpleCPU}] [--list-bp-types] [--list-indirect-bp-types] [--bp-type {BiModeBP,LTAGE,LocalBP,MultiperspectivePerceptron64KB,MultiperspectivePerceptron8KB,MultiperspectivePerceptronTAGE64KB,MultiperspectivePerceptronTAGE8KB,TAGE,TAGE_SC_L_64KB,TAGE_SC_L_8KB,TournamentBP}] [--indirect-bp-type {SimpleIndirectPredictor}] [--list-rp-types] [--list-hwp-types] [--l1i-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher}] [--l1d-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher}] [--l2-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher}] [--checker] [--cpu-clock CPU_CLOCK] [--smt] [--elastic-trace-en] [--inst-trace-file INST_TRACE_FILE] [--data-trace-file DATA_TRACE_FILE] [--dist] [--dist-sync-on-pseudo-op] [--is-switch] [--dist-rank DIST_RANK] [--dist-size DIST_SIZE] [--dist-server-name DIST_SERVER_NAME] [--dist-server-port DIST_SERVER_PORT] [--dist-sync-repeat DIST_SYNC_REPEAT] [--dist-sync-start DIST_SYNC_START] [--ethernet-linkspeed ETHERNET_LINKSPEED] [--ethernet-linkdelay ETHERNET_LINKDELAY] [-I MAXINSTS] [--work-item-id WORK_ITEM_ID] [--num-work-ids NUM_WORK_IDS] [--work-begin-cpu-id-exit WORK_BEGIN_CPU_ID_EXIT] [--work-end-exit-count WORK_END_EXIT_COUNT] [--work-begin-exit-count WORK_BEGIN_EXIT_COUNT] [--init-param INIT_PARAM] [--initialize-only] [--simpoint-profile] [--simpoint-interval SIMPOINT_INTERVAL] [--take-simpoint-checkpoints TAKE_SIMPOINT_CHECKPOINTS] [--restore-simpoint-checkpoint] [--take-checkpoints TAKE_CHECKPOINTS] [--max-checkpoints MAX_CHECKPOINTS] [--checkpoint-dir CHECKPOINT_DIR] [-r CHECKPOINT_RESTORE] [--checkpoint-at-end] [--work-begin-checkpoint-count WORK_BEGIN_CHECKPOINT_COUNT] [--work-end-checkpoint-count WORK_END_CHECKPOINT_COUNT] [--work-cpus-checkpoint-count WORK_CPUS_CHECKPOINT_COUNT] [--restore-with-cpu {AtomicSimpleCPU,BaseAtomicSimpleCPU,BaseMinorCPU,BaseNonCachingSimpleCPU,BaseO3CPU,BaseTimingSimpleCPU,DerivO3CPU,NonCachingSimpleCPU,O3CPU,TimingSimpleCPU,X86AtomicSimpleCPU,X86KvmCPU,X86MinorCPU,X86NonCachingSimpleCPU,X86O3CPU,X86TimingSimpleCPU}] [--repeat-switch REPEAT_SWITCH] [-s STANDARD_SWITCH] [-p PROG_INTERVAL] [-W WARMUP_INSTS] [--bench BENCH] [-F FAST_FORWARD] [-S] [--at-instruction] [--spec-input {ref,test,train,smred,mdred,lgred}] [--arm-iset {arm,thumb,aarch64}] [--stats-root STATS_ROOT] [--override-vendor-string OVERRIDE_VENDOR_STRING] [-c CMD] [-o OPTIONS] [-e ENV] [-i INPUT] [--output OUTPUT] [--errout ERROUT] [--chroot CHROOT] [--interp-dir INTERP_DIR] [--redirects REDIRECTS] [--wait-gdb] options: -h, --help show this help message and exit -n NUM_CPUS, --num-cpus NUM_CPUS --sys-voltage SYS_VOLTAGE Top-level voltage for blocks running at system power supply --sys-clock SYS_CLOCK Top-level clock for blocks running at system speed --list-mem-types List available memory types --mem-type {CfiMemory,DDR3_1600_8x8,DDR3_2133_8x8,DDR4_2400_16x4,DDR4_2400_4x16,DDR4_2400_8x8,DDR5_4400_4x8,DDR5_6400_4x8,DDR5_8400_4x8,DRAMInterface,GDDR5_4000_2x32,HBM_1000_4H_1x128,HBM_1000_4H_1x64,HBM_2000_4H_1x64,HMC_2500_1x32,LPDDR2_S4_1066_1x32,LPDDR3_1600_1x32,LPDDR5_5500_1x16_8B_BL32,LPDDR5_5500_1x16_BG_BL16,LPDDR5_5500_1x16_BG_BL32,LPDDR5_6400_1x16_8B_BL32,LPDDR5_6400_1x16_BG_BL16,LPDDR5_6400_1x16_BG_BL32,NVMInterface,NVM_2400_1x64,QoSMemSinkInterface,SimpleMemory,WideIO_200_1x128} type of memory to use --mem-channels MEM_CHANNELS number of memory channels --mem-ranks MEM_RANKS number of memory ranks per channel --mem-size MEM_SIZE Specify the physical memory size (single memory) --enable-dram-powerdown Enable low-power states in DRAMInterface --mem-channels-intlv MEM_CHANNELS_INTLV Memory channels interleave --memchecker --external-memory-system EXTERNAL_MEMORY_SYSTEM use external ports of this port_type for caches --tlm-memory TLM_MEMORY use external port for SystemC TLM cosimulation --caches --l2cache --num-dirs NUM_DIRS --num-l2caches NUM_L2CACHES --num-l3caches NUM_L3CACHES --l1d_size L1D_SIZE --l1i_size L1I_SIZE --l2_size L2_SIZE --l3_size L3_SIZE --l1d_assoc L1D_ASSOC --l1i_assoc L1I_ASSOC --l2_assoc L2_ASSOC --l3_assoc L3_ASSOC --cacheline_size CACHELINE_SIZE --ruby -m TICKS, --abs-max-tick TICKS Run to absolute simulated tick specified including ticks from a restored checkpoint --rel-max-tick TICKS Simulate for specified number of ticks relative to the simulation start tick (e.g. if restoring a checkpoint) --maxtime MAXTIME Run to the specified absolute simulated time in seconds -P PARAM, --param PARAM Set a SimObject parameter relative to the root node. An extended Python multi range slicing syntax can be used for arrays. For example: 'system.cpu[0,1,3:8:2].max_insts_all_threads = 42' sets max_insts_all_threads for cpus 0, 1, 3, 5 and 7 Direct parameters of the root object are not accessible, only parameters of its children. --list-cpu-types List available CPU types --cpu-type {AtomicSimpleCPU,BaseAtomicSimpleCPU,BaseMinorCPU,BaseNonCachingSimpleCPU,BaseO3CPU,BaseTimingSimpleCPU,DerivO3CPU,NonCachingSimpleCPU,O3CPU,TimingSimpleCPU,X86AtomicSimpleCPU,X86KvmCPU,X86MinorCPU,X86NonCachingSimpleCPU,X86O3CPU,X86TimingSimpleCPU} type of cpu to run with --list-bp-types List available branch predictor types --list-indirect-bp-types List available indirect branch predictor types --bp-type {BiModeBP,LTAGE,LocalBP,MultiperspectivePerceptron64KB,MultiperspectivePerceptron8KB,MultiperspectivePerceptronTAGE64KB,MultiperspectivePerceptronTAGE8KB,TAGE,TAGE_SC_L_64KB,TAGE_SC_L_8KB,TournamentBP} type of branch predictor to run with (if not set, use the default branch predictor of the selected CPU) --indirect-bp-type {SimpleIndirectPredictor} type of indirect branch predictor to run with --list-rp-types List available replacement policy types --list-hwp-types List available hardware prefetcher types --l1i-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher} type of hardware prefetcher to use with the L1 instruction cache. (if not set, use the default prefetcher of the selected cache) --l1d-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher} type of hardware prefetcher to use with the L1 data cache. (if not set, use the default prefetcher of the selected cache) --l2-hwp-type {AMPMPrefetcher,BOPPrefetcher,DCPTPrefetcher,IndirectMemoryPrefetcher,IrregularStreamBufferPrefetcher,MultiPrefetcher,PIFPrefetcher,SBOOEPrefetcher,STeMSPrefetcher,SignaturePathPrefetcher,SignaturePathPrefetcherV2,SlimAMPMPrefetcher,SmsPrefetcher,StridePrefetcher,TaggedPrefetcher} type of hardware prefetcher to use with the L2 cache. (if not set, use the default prefetcher of the selected cache) --checker --cpu-clock CPU_CLOCK Clock for blocks running at CPU speed --smt Only used if multiple programs are specified. If true, then the number of threads per cpu is same as the number of programs. --elastic-trace-en Enable capture of data dependency and instruction fetch traces using elastic trace probe. --inst-trace-file INST_TRACE_FILE Instruction fetch trace file input to Elastic Trace probe in a capture simulation and Trace CPU in a replay simulation --data-trace-file DATA_TRACE_FILE Data dependency trace file input to Elastic Trace probe in a capture simulation and Trace CPU in a replay simulation --dist Parallel distributed gem5 simulation. --dist-sync-on-pseudo-op Use a pseudo-op to start dist-gem5 synchronization. --is-switch Select the network switch simulator process for adistributed gem5 run --dist-rank DIST_RANK Rank of this system within the dist gem5 run. --dist-size DIST_SIZE Number of gem5 processes within the dist gem5 run. --dist-server-name DIST_SERVER_NAME Name of the message server host DEFAULT: localhost --dist-server-port DIST_SERVER_PORT Message server listen port DEFAULT: 2200 --dist-sync-repeat DIST_SYNC_REPEAT Repeat interval for synchronisation barriers among dist-gem5 processes DEFAULT: --ethernet-linkdelay --dist-sync-start DIST_SYNC_START Time to schedule the first dist synchronisation barrier DEFAULT:5200000000000t --ethernet-linkspeed ETHERNET_LINKSPEED Link speed in bps DEFAULT: 10Gbps --ethernet-linkdelay ETHERNET_LINKDELAY Link delay in seconds DEFAULT: 10us -I MAXINSTS, --maxinsts MAXINSTS Total number of instructions to simulate (default: run forever) --work-item-id WORK_ITEM_ID the specific work id for exit & checkpointing --num-work-ids NUM_WORK_IDS Number of distinct work item types --work-begin-cpu-id-exit WORK_BEGIN_CPU_ID_EXIT exit when work starts on the specified cpu --work-end-exit-count WORK_END_EXIT_COUNT exit at specified work end count --work-begin-exit-count WORK_BEGIN_EXIT_COUNT exit at specified work begin count --init-param INIT_PARAM Parameter available in simulation with m5 initparam --initialize-only Exit after initialization. Do not simulate time. Useful when gem5 is run as a library. --simpoint-profile Enable basic block profiling for SimPoints --simpoint-interval SIMPOINT_INTERVAL SimPoint interval in num of instructions --take-simpoint-checkpoints TAKE_SIMPOINT_CHECKPOINTS <simpoint file,weight file,interval-length,warmup- length> --restore-simpoint-checkpoint restore from a simpoint checkpoint taken with --take- simpoint-checkpoints --take-checkpoints TAKE_CHECKPOINTS <M,N> take checkpoints at tick M and every N ticks thereafter --max-checkpoints MAX_CHECKPOINTS the maximum number of checkpoints to drop --checkpoint-dir CHECKPOINT_DIR Place all checkpoints in this absolute directory -r CHECKPOINT_RESTORE, --checkpoint-restore CHECKPOINT_RESTORE restore from checkpoint <N> --checkpoint-at-end take a checkpoint at end of run --work-begin-checkpoint-count WORK_BEGIN_CHECKPOINT_COUNT checkpoint at specified work begin count --work-end-checkpoint-count WORK_END_CHECKPOINT_COUNT checkpoint at specified work end count --work-cpus-checkpoint-count WORK_CPUS_CHECKPOINT_COUNT checkpoint and exit when active cpu count is reached --restore-with-cpu {AtomicSimpleCPU,BaseAtomicSimpleCPU,BaseMinorCPU,BaseNonCachingSimpleCPU,BaseO3CPU,BaseTimingSimpleCPU,DerivO3CPU,NonCachingSimpleCPU,O3CPU,TimingSimpleCPU,X86AtomicSimpleCPU,X86KvmCPU,X86MinorCPU,X86NonCachingSimpleCPU,X86O3CPU,X86TimingSimpleCPU} cpu type for restoring from a checkpoint --repeat-switch REPEAT_SWITCH switch back and forth between CPUs with period <N> -s STANDARD_SWITCH, --standard-switch STANDARD_SWITCH switch from timing to Detailed CPU after warmup period of <N> -p PROG_INTERVAL, --prog-interval PROG_INTERVAL CPU Progress Interval -W WARMUP_INSTS, --warmup-insts WARMUP_INSTS Warmup period in total instructions (requires --standard-switch) --bench BENCH base names for --take-checkpoint and --checkpoint- restore -F FAST_FORWARD, --fast-forward FAST_FORWARD Number of instructions to fast forward before switching -S, --simpoint Use workload simpoints as an instruction offset for --checkpoint-restore or --take-checkpoint. --at-instruction Treat value of --checkpoint-restore or --take- checkpoint as a number of instructions. --spec-input {ref,test,train,smred,mdred,lgred} Input set size for SPEC CPU2000 benchmarks. --arm-iset {arm,thumb,aarch64} ARM instruction set. --stats-root STATS_ROOT If given, dump only stats of objects under the given SimObject. SimObjects are identified with Python notation as in: system.cpu[0].mmu. All elements of an array can be selected at once with: system.cpu[:].mmu. If given multiple times, dump stats that are present under any of the roots. If not given, dump all stats. --override-vendor-string OVERRIDE_VENDOR_STRING Override vendor string returned by CPUID instruction in X86. -c CMD, --cmd CMD The binary to run in syscall emulation mode. -o OPTIONS, --options OPTIONS The options to pass to the binary, use around the entire string -e ENV, --env ENV Initialize workload environment from text file. -i INPUT, --input INPUT Read stdin from a file. --output OUTPUT Redirect stdout to a file. --errout ERROUT Redirect stderr to a file. --chroot CHROOT The chroot option allows a user to alter the search path for processes running in SE mode. Normally, the search path would begin at the root of the filesystem (i.e. /). With chroot, a user can force the process to begin looking atsome other location (i.e. /home/user/rand_dir).The intended use is to trick sophisticated software which queries the __HOST__ filesystem for information or functionality. Instead of finding files on the __HOST__ filesystem, the process will find the user's replacment files. --interp-dir INTERP_DIR The interp-dir option is used for setting the interpreter's path. This will allow to load the guest dynamic linker/loader itself from the elf binary. The option points to the parent folder of the guest /lib in the host fs --redirects REDIRECTS A collection of one or more redirect paths to be used in syscall emulation.Usage: gem5.opt [...] --redirects /dir1=/path/to/host/dir1 --redirects /dir2=/path/to/host/dir2 --wait-gdb Wait for remote GDB to connect.
最新发布
10-24
上述代码是对指定路径向下的指定文件进行了相关数据处理,尤其是对其中的WDP数据/文件; 而下述代码则是生成WDP数据的过程,目前需要将二者的代码进行拼接,请你修改 上述代码,完成对下述代码的拼接,下述代码执行后拿到了B-scan的对数反射强度,并进一步转换为熔深曲线; %% 探测器记录的是干涉光谱,通过物理关系:不同深度z的反射面会产生不同的相位延迟 %% 这个相位差会调制出不同频率的余弦振荡项在光谱上 %% 对光谱做傅里叶变换,就是把振荡频率转换成位置 %% 原始光谱-去直流项(去除S(k)背景)-k空间重采样-均匀间隔-加窗抑制旁瓣 %% ifft对齐0频-fft将k域信号转换为z域-abs取模得到包络-峰值对应反射层 %% 图2中有空间密度趋势,这个密度趋势是统计了B-scan 的趋势,由此进行统计,得到常见峰的位置; %% 内置函数findpeaks用于提取显著反射层 %% ==================== 系统参数 ==================== lambda_center = 840e-9; % 中心波长 (m) bandwidth_FWHM = 40e-9; % FWHM 带宽 (m) sigma_lambda = bandwidth_FWHM / (2 * sqrt(2 * log(2))); % 高斯标准差计算 N_pixels = 2048; % 光谱仪像素数 lateral_range = 40e-3; % 扫描总长度 (m) lateral_resolution = 20.5e-6; % 单步分辨率 lateral_step = 2 * lateral_resolution; % 采样间隔 ~41 μm N_AScans = max(1, round(lateral_range / lateral_step)); % 构造波长向量(就把波长范围构造出来了) lambda_min = lambda_center - 3 * sigma_lambda; lambda_max = lambda_center + 3 * sigma_lambda; lambda = linspace(lambda_min, lambda_max, N_pixels)'; % k空间基础(2pi/波长,进行重采样得基础) k_vec = 2 * pi ./ lambda; % 添加轻微非线性畸变(模拟 spectrometer 色散不均) distortion = 1e4 * (k_vec - mean(k_vec)).^2 / max(k_vec)^2; k_vec = k_vec + distortion; % 深度轴(对称,ZPD 在中心) c = 3e8; n_eff = 1.0; dz = pi / (n_eff * (max(k_vec) - min(k_vec))); z_axis_full = (-N_pixels/2 : N_pixels/2 - 1)' * dz; z_mm = z_axis_full * 1e3; % mm x_mm = (0:N_AScans-1)' * lateral_step * 1e3; % 噪声参数 read_noise_std = 0.01; shot_noise_factor = 1.0; % 控制散粒噪声强度 source_instability = 0.03; min_peak_height_ratio = 0.05; min_peak_distance_base = round(N_pixels / 50); fprintf('🔍 波长范围: %.2f ~ %.2f nm\n', min(lambda)*1e9, max(lambda)*1e9); fprintf('📏 轴向分辨率: %.2f μm\n', (2*log(2)/pi) * lambda_center^2 / bandwidth_FWHM * 1e6); fprintf('🔄 正在模拟 %d 条 A-scan...\n', N_AScans); %% ==================== 初始化变量 ==================== bscan_intensity = zeros(N_pixels, N_AScans); all_detected_points = cell(1, N_AScans); example_spectrum_raw = []; example_spectrum_proc = []; example_ascan = []; %% ==================== 主循环:模拟采集 ==================== for idx = 1:N_AScans try %% Step 1: 构建物理结构 surface_depth = -25e-6 + 50e-6 * rand(); % ±25μm 浮动 % 熔池散射:密度随深度递减(指数分布) num_scatterers = randi([5, 12]); depths_norm = exprnd(1.8e-3, [num_scatterers, 1]); depths_pool = surface_depth + 1.0e-3 + depths_norm; reflections_pool = 0.08 + 0.07 * rand(num_scatterers, 1); bottom_depth = surface_depth + 2.8e-3 + 0.4e-3*rand(); depths_all = [surface_depth; depths_pool; bottom_depth]; reflections_all = [0.35; reflections_pool; 0.4]; % 表面强反射 % 5%概率添加虚假深层 if rand() < 0.05 fake_deep = bottom_depth + 0.1e-3 + 0.3e-3*rand(); depths_all = [depths_all; fake_deep]; reflections_all = [reflections_all; 0.05]; end %% Step 2: 生成光谱 raw_spectrum = generate_spectrum(lambda, k_vec, lambda_center, sigma_lambda, ... depths_all, reflections_all, read_noise_std, shot_noise_factor, source_instability); if isempty(example_spectrum_raw) example_spectrum_raw = raw_spectrum; end %% Step 3: 处理链 dc_removed = remove_dc(raw_spectrum); [k_uniform, spec_resampled] = resample_to_uniform_k(k_vec, dc_removed); if any(isnan(spec_resampled)) error('NaN detected in resampling'); end spec_shaped = apply_window(spec_resampled, 'hanning'); ascan_envelope = compute_ascan(k_uniform, spec_shaped); if isempty(example_spectrum_proc) example_spectrum_proc = spec_resampled; example_ascan = ascan_envelope; end bscan_intensity(:, idx) = ascan_envelope; %% Step 4: 提取反射(仅 z ≥ 0) %这里是对z进行大于0的逻辑判断,因此返回的是一个真假的向量 valid_positive = (z_mm >= 0); %zmm还是原来的,但这就提取了只有大于0的了 z_pos = z_mm(valid_positive); %提取位于正深度区域的包络强度值 a_pos = ascan_envelope(valid_positive); %设置2个相邻的峰之间的最小距离(就是峰不能太密) min_dist = max(5, round(length(z_pos)/50)); %峰的阈值、间隔、距离、阈值 [peaks, locs] = findpeaks(a_pos, 'MinPeakHeight', max(a_pos)*0.05, 'MinPeakDistance', min_dist); %从数组索引转换为物理深度值 detected_z = z_pos(locs); %去除靠近图像检测边缘的检测结果 detected_z = detected_z(detected_z <= max(z_mm)*0.95); % 截断边缘 %将本次扫描提取到的所有反射深度保存到单元数组中 all_detected_points{idx} = detected_z; catch ME fprintf('❌ A-scan %d 失败: %s\n', idx, ME.message); bscan_intensity(:, idx) = eps; all_detected_points{idx} = []; end end fprintf('✅ 采集完成!\n'); %% ==================== 数据后处理:构建 pts_clean ==================== valid_mask = ~cellfun(@isempty, all_detected_points); if any(valid_mask) pts_cat = vertcat(all_detected_points{valid_mask}); pts_clean = pts_cat(pts_cat >= 0 & pts_cat <= max(z_mm)); else pts_clean = []; end %% ==================== 图1:五阶段处理链 ==================== figure('Name', '图1:五阶段处理链', 'Position', [100, 100, 1100, 700]); subplot(3,2,1); plot(lambda*1e9, example_spectrum_raw); title('① 原始光谱'); xlabel('\lambda (nm)'); subplot(3,2,2); plot(k_vec, example_spectrum_raw); title('② k空间(有畸变,因为不均匀)'); xlabel('k (rad/m)'); dc_removed = remove_dc(example_spectrum_raw); subplot(3,2,3); plot(k_vec, dc_removed); title('③ 去DC'); [k_uni, spec_r] = resample_to_uniform_k(k_vec, dc_removed); subplot(3,2,4); plot(k_uni, spec_r); title('④ 均匀k(线性插值)'); w_spec = apply_window(spec_r, 'hanning'); subplot(3,2,5); plot(k_uni, w_spec); title('⑤ 加窗去旁瓣'); env = compute_ascan(k_uni, w_spec); subplot(3,2,6); plot(z_mm, env, 'c'); ax = gca; ax.XAxisLocation='origin'; grid on; title('⑥ A-scan包络'); try exportgraphics(gcf, 'figure1_chain.png', 'Resolution', 300); end %% ==================== 图2:A-scan 分析 ==================== figure('Name', '图2:反射密度分析', 'Position', [200, 200, 900, 500]); valid_region = (z_mm >= 0); z_pos = z_mm(valid_region); a_pos = example_ascan(valid_region); min_peak_height = max(a_pos) * 0.1; [~, pk_idx] = findpeaks(a_pos, 'MinPeakHeight', min_peak_height, 'MinPeakDistance', 5); yyaxis left plot(z_mm, example_ascan, 'b', 'LineWidth', 1.2); hold on; if ~isempty(pk_idx) plot(z_pos(pk_idx), a_pos(pk_idx), 'ro', 'MarkerFaceColor', 'r', 'MarkerSize', 6); end ylabel('反射强度'); ylim auto; bin_width = 0.05; bins = 0:bin_width:max(z_mm); [den, ~] = histcounts(pts_clean, bins); den_smooth = smoothdata(den, 'gaussian', 5); bin_centers = bins(1:end-1) + bin_width/2; yyaxis right plot(bin_centers, den_smooth, 'k--', 'LineWidth', 2); ylabel('反射密度(平滑)'); title('A-scan 包络 + 检测峰值 + 空间密度分布'); xlabel('深度 z (mm)'); legend('A-scan包络', '检测到的峰', '空间密度趋势', 'Location', 'best'); grid on; hold off; %% ==================== 图3:B-scan 与 熔深 ==================== figure('Name', '图3:B-scan 与 熔深提取', 'Position', [100, 100, 1200, 800]); img_log = log10(bscan_intensity + 1e-10); subplot(2,1,1); imagesc(x_mm, z_mm, img_log); axis image; colorbar; colormap(flipud(gray)); title('B-scan: 对数反射强度'); ylabel('深度 z (mm)'); hold on; for idx = 1:N_AScans x = x_mm(idx); pts = all_detected_points{idx}; if ~isempty(pts) plot(repmat(x, length(pts), 1), pts, 'y.', 'MarkerSize', 3); end end % 提取熔深:取每个 A-scan 最深的有效峰 melt_depth_curve = NaN(size(x_mm)); for idx = 1:N_AScans pts = all_detected_points{idx}; if isempty(pts), continue; end [vals, ~] = sort(pts, 'descend'); for v = vals' if v > 1.0 && v < max(z_mm)*0.95 melt_depth_curve(idx) = v; break; end end end % 插值修复 NaN valid_md = ~isnan(melt_depth_curve); if sum(valid_md) >= 2 melt_depth_curve = interp1(x_mm(valid_md), melt_depth_curve(valid_md), x_mm, 'linear'); else melt_depth_curve = fillmissing(melt_depth_curve, 'nearest'); end plot(x_mm, melt_depth_curve, 'r-', 'LineWidth', 2.5); legend('反射', '估计熔深', 'Location', 'best'); hold off; subplot(2,1,2); plot(x_mm, melt_depth_curve, 'b-', 'LineWidth', 2); xlabel('x (mm)'); ylabel('熔深 (mm)'); title('熔深曲线'); grid on; % 安全设置 ylim valid_vals = melt_depth_curve(~isnan(melt_depth_curve)); if isempty(valid_vals) ylim([0, 1]); % 默认范围 else ylim([0, max(valid_vals)*1.1]); end sgtitle('📌 B-scan 与 熔深提取:ZPD对齐表面,熔深为正'); %% ==================== 输出统计与保存 ==================== fprintf('\n📊 统计信息:\n'); fprintf(' 总A-scan数量: %d\n', N_AScans); avg_pts = mean(cellfun(@numel, all_detected_points)); fprintf(' 平均每A-scan检测到 %.1f 个反射\n', avg_pts); if all(isnan(melt_depth_curve)) fprintf('⚠️ 未能提取任何有效熔深!\n'); else range_md = [min(melt_depth_curve, [], 'omitnan'), max(melt_depth_curve, [], 'omitnan')]; fprintf(' 提取熔深范围: %.2f ~ %.2f mm\n', range_md(1), range_md(2)); fprintf(' 平均熔深: %.2f mm\n', mean(melt_depth_curve, 'omitnan')); end save('sd_oct_simulation_result.mat', 'bscan_intensity', 'melt_depth_curve', 'x_mm', 'z_mm', 'all_detected_points'); fprintf('💾 结果已保存至 sd_oct_simulation_result.mat\n'); disp('🎉 SD-OCT 高保真仿真完成!'); %% ========== 子函数1:生成光谱 ========== function spectrum = generate_spectrum(lambda, k_vec, lambda_center, sigma_lambda, depths, reflections, noise_std, shot_factor, instability) N = length(lambda); I0 = exp(-(lambda - lambda_center).^2 / (2*sigma_lambda^2)); interference = zeros(N,1); for i = 1:length(depths) phase = 2 * k_vec * depths(i); interference = interference + reflections(i) * cos(phase); end I_total = I0 + interference; I_total = max(I_total, 0); noise_readout = noise_std * randn(N,1); noise_shot = shot_factor * sqrt(I_total) .* randn(N,1); noise_drift = instability * I0 * randn(); spectrum = I_total + noise_readout + noise_shot + noise_drift; end %% ========== 子函数2:去直流 ========== function y = remove_dc(x) background = mean(x(1:2048)); y = x - background; end %% ========== 子函数3:k空间重采样 ========== function [k_new, y_new] = resample_to_uniform_k(k, y) k_new = linspace(min(k), max(k), length(k))'; y_new = interp1(k, y, k_new, 'pchip', 'extrap'); end %% ========== 子函数4:加窗抑制旁瓣 ========== function y = apply_window(x, type_str) w = window(@hann, length(x)); y = x .* w(:); end %% ========== 子函数5:计算A-scan包络 ========== function envelope = compute_ascan(k_uniform, spectrum) %spectrum先确保为列向量 %ifft将数据“绕一圈”,使得0频成分移到首位,满足FFT的周期性假设 spec_shifted = ifftshift(spectrum(:)); %fft执行快速傅里叶变换,输出一个复数向量,模表示反射强度,相位可用于Doppler分析; ascan_complex = fft(spec_shifted); %取模得到包络信号,即看到的山峰,每一个山峰代表一个反射界面 envelope = abs(ascan_complex); end
10-23
Traceback (most recent call last): File "/home/robot/UR5-Pick-and-Place-Simulation-main/catkin_ws/src/vision/scripts/lego-vision.py", line 475, in <module> load_models() File "/home/robot/UR5-Pick-and-Place-Simulation-main/catkin_ws/src/vision/scripts/lego-vision.py", line 465, in load_models model = torch.hub.load(path_yolo,'custom',path=weight, source='local') File "/home/robot/.local/lib/python3.8/site-packages/torch/hub.py", line 570, in load model = _load_local(repo_or_dir, model, *args, **kwargs) File "/home/robot/.local/lib/python3.8/site-packages/torch/hub.py", line 599, in _load_local model = entry(*args, **kwargs) File "/home/robot/yolov5/hubconf.py", line 135, in custom return _create(path, autoshape=autoshape, verbose=_verbose, device=device) File "/home/robot/yolov5/hubconf.py", line 54, in _create from models.common import AutoShape, DetectMultiBackend File "/home/robot/yolov5/models/common.py", line 39, in <module> from utils.dataloaders import exif_transpose, letterbox File "/home/robot/yolov5/utils/dataloaders.py", line 23, in <module> import torchvision File "/home/robot/.local/lib/python3.8/site-packages/torchvision/__init__.py", line 10, in <module> from torchvision import _meta_registrations, datasets, io, models, ops, transforms, utils # usort:skip File "/home/robot/.local/lib/python3.8/site-packages/torchvision/models/__init__.py", line 2, in <module> from .convnext import * File "/home/robot/.local/lib/python3.8/site-packages/torchvision/models/convnext.py", line 8, in <module> from ..ops.misc import Conv2dNormActivation, Permute File "/home/robot/.local/lib/python3.8/site-packages/torchvision/ops/__init__.py", line 23, in <module> from .poolers import MultiScaleRoIAlign File "/home/robot/.local/lib/python3.8/site-packages/torchvision/ops/poolers.py", line 10, in <module> from .roi_align import roi_align File "/home/robot/.local/lib/python3.8/site-packages/torchvision/ops/roi_align.py", line 7, in <module> from torch._dynamo.utils import is_compile_supported File "/home/robot/.local/lib/python3.8/site-packages/torch/_dynamo/__init__.py", line 2, in <module> from . import convert_frame, eval_frame, resume_execution File "/home/robot/.local/lib/python3.8/site-packages/torch/_dynamo/convert_frame.py", line 48, in <module> from . import config, exc, trace_rules File "/home/robot/.local/lib/python3.8/site-packages/torch/_dynamo/exc.py", line 12, in <module> from .utils import counters File "/home/robot/.local/lib/python3.8/site-packages/torch/_dynamo/utils.py", line 1063, in <module> if has_triton_package(): File "/home/robot/.local/lib/python3.8/site-packages/torch/utils/_triton.py", line 9, in has_triton_package import triton File "/home/robot/.local/lib/python3.8/site-packages/triton/__init__.py", line 8, in <module> from .runtime import ( File "/home/robot/.local/lib/python3.8/site-packages/triton/runtime/__init__.py", line 1, in <module> from .autotuner import (Autotuner, Config, Heuristics, autotune, heuristics) File "/home/robot/.local/lib/python3.8/site-packages/triton/runtime/autotuner.py", line 9, in <module> from ..testing import do_bench, do_bench_cudagraph File "/home/robot/.local/lib/python3.8/site-packages/triton/testing.py", line 7, in <module> from . import language as tl File "/home/robot/.local/lib/python3.8/site-packages/triton/language/__init__.py", line 4, in <module> from . import math File "/home/robot/.local/lib/python3.8/site-packages/triton/language/math.py", line 1, in <module> from . import core File "/home/robot/.local/lib/python3.8/site-packages/triton/language/core.py", line 10, in <module> from ..runtime.jit import jit File "/home/robot/.local/lib/python3.8/site-packages/triton/runtime/jit.py", line 12, in <module> from ..runtime.driver import driver File "/home/robot/.local/lib/python3.8/site-packages/triton/runtime/driver.py", line 1, in <module> from ..backends import backends File "/home/robot/.local/lib/python3.8/site-packages/triton/backends/__init__.py", line 50, in <module> backends = _discover_backends() File "/home/robot/.local/lib/python3.8/site-packages/triton/backends/__init__.py", line 44, in _discover_backends driver = _load_module(name, os.path.join(root, name, 'driver.py')) File "/home/robot/.local/lib/python3.8/site-packages/triton/backends/__init__.py", line 12, in _load_module spec.loader.exec_module(module) File "/home/robot/.local/lib/python3.8/site-packages/triton/backends/amd/driver.py", line 7, in <module> from triton.runtime.build import _build File "/home/robot/.local/lib/python3.8/site-packages/triton/runtime/build.py", line 8, in <module> import setuptools File "/home/robot/.local/lib/python3.8/site-packages/setuptools/__init__.py", line 27, in <module> from .dist import Distribution File "/home/robot/.local/lib/python3.8/site-packages/setuptools/dist.py", line 30, in <module> from . import ( File "/home/robot/.local/lib/python3.8/site-packages/setuptools/_entry_points.py", line 45, in <module> def validate(eps: metadata.EntryPoints): AttributeError: module 'importlib_metadata' has no attribute 'EntryPoints'
09-29
评论 19
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值