在单次 Jacobian 构建内按完整输入精确复用储气物性、PH 反算、密度和管路求根结果,保持原有求值副作用、差分政策与失败回退。八路模型求解 CPU 中位数减少 19.27%,循环和不循环的完整原始采样均与恢复基线一致。 增加独立的跨平台时间剖析工具,记录互斥阶段耗时、Newton/LU 统计、矩阵复用与内核复用,保存 UD00 两种工况的调查报告和机器可读汇总。 补充 Windows/Linux 运行、测试、原生编译和剖析所需依赖文档及索引,不修改依赖清单、版本锁或安装环境。 验证:8 项新增专项回归通过;2270 次完整 Jacobian 核对零差异;16 次剖析配对及预热运行保持完整数值一致。既有固定样本哈希失败和 Linux 实机验收限制见报告。
28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
/* Diagnostic-only scopes for one standalone worker. Never linked in production. */
|
|
#ifndef SOLVER_PROFILE_H
|
|
#define SOLVER_PROFILE_H
|
|
enum {
|
|
P_TOTAL, P_INTEGRATION, P_CVODE, P_RHS, P_RESIDUAL, P_JACOBIAN,
|
|
P_JACOBIAN_PROBE, P_LSETUP, P_LU, P_LSOLVE, P_NEWTON, P_EVENT,
|
|
P_PROPERTY, P_SAMPLING, P_APPEND, P_FLUSH, P_REPLAY, P_ENCODING,
|
|
P_POLL, P_COUNT
|
|
};
|
|
enum {
|
|
C_STEPS, C_RHS, C_LINEAR_RHS, C_JACOBIANS, C_SETUPS, C_ERROR_FAILS,
|
|
C_NEWTON_ITERS, C_NEWTON_FAILS, C_STEP_SOLVE_FAILS, C_SEGMENTS,
|
|
C_JAC_REUSES, C_JAC_REFRESHES, C_SETUP_FAILURES, C_LU_FAILURES,
|
|
C_SOLVE_FAILURES, C_FRICTION_EVALS, C_BOUNDARIES, C_COUNT
|
|
};
|
|
typedef struct ProfileScope {
|
|
double start, children;
|
|
int id, active;
|
|
struct ProfileScope *parent;
|
|
} ProfileScope;
|
|
ProfileScope profile_begin(int id);
|
|
void profile_link(ProfileScope *scope);
|
|
void profile_end(ProfileScope *scope);
|
|
void profile_add(int id, int status, long int value);
|
|
void profile_dump(void);
|
|
#define PROFILE_SCOPE(id) ProfileScope profile_scope __attribute__((cleanup(profile_end)))=profile_begin(id); profile_link(&profile_scope)
|
|
#endif
|