优化 Jacobian 确定性复用并补充性能剖析与平台依赖文档
在单次 Jacobian 构建内按完整输入精确复用储气物性、PH 反算、密度和管路求根结果,保持原有求值副作用、差分政策与失败回退。八路模型求解 CPU 中位数减少 19.27%,循环和不循环的完整原始采样均与恢复基线一致。 增加独立的跨平台时间剖析工具,记录互斥阶段耗时、Newton/LU 统计、矩阵复用与内核复用,保存 UD00 两种工况的调查报告和机器可读汇总。 补充 Windows/Linux 运行、测试、原生编译和剖析所需依赖文档及索引,不修改依赖清单、版本锁或安装环境。 验证:8 项新增专项回归通过;2270 次完整 Jacobian 核对零差异;16 次剖析配对及预热运行保持完整数值一致。既有固定样本哈希失败和 Linux 实机验收限制见报告。
This commit is contained in:
1 parent
2b07d996cf
commit
1aac220084
26 files changed
+2293
-13
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#ifndef NATIVE_KERNELS_H
|
||||
#define NATIVE_KERNELS_H
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
typedef struct { double p, T, rho, u, h; } NativeGas;
|
||||
typedef struct {
|
||||
int velocity_index;
|
||||
@@ -27,6 +28,7 @@ enum {
|
||||
/* Optional observer for one evaluation, independent of cache capacity.
|
||||
* Slots: EOS, ideal caloric data, dynamic viscosity; each has min/max T. */
|
||||
#define NATIVE_PROPERTY_DOMAINS 3
|
||||
typedef struct NativeJacobianScalars NativeJacobianScalars;
|
||||
typedef struct {
|
||||
unsigned seen;
|
||||
double minimum[NATIVE_PROPERTY_DOMAINS], maximum[NATIVE_PROPERTY_DOMAINS];
|
||||
@@ -36,16 +38,49 @@ typedef struct {
|
||||
double p, T, h, rho, mu, isentropic_factor, isentropic_exponent;
|
||||
unsigned valid;
|
||||
NativePropertyTemperatures *temperatures;
|
||||
NativeJacobianScalars *jacobian;
|
||||
} NativePropertyState;
|
||||
typedef struct {
|
||||
NativePropertyState *states;
|
||||
size_t count, capacity;
|
||||
NativePropertyTemperatures *temperatures;
|
||||
NativeJacobianScalars *jacobian;
|
||||
} NativePropertyCache;
|
||||
void native_properties_init(NativePropertyCache *, NativePropertyState *, size_t capacity);
|
||||
int native_gas_context(NativePropertyCache *, double m, double U, double V, NativeGas *);
|
||||
int native_medium_gas_context(NativePropertyCache *, const NativeMedium *, double m, double U, double V, NativeGas *);
|
||||
int native_polytropic_gas_context(NativePropertyCache *, const NativeMedium *, double mass, double T, double V, NativeGas *);
|
||||
/* Immutable baseline entries owned by ONE Jacobian construction. These
|
||||
* reviewed kernels are deterministic with a NULL property cache: no cache
|
||||
* seeds or temperature observations may be suppressed by a hit. */
|
||||
typedef int (*NativeCanonicalGas)(NativePropertyCache *,const NativeMedium *,double,double,double,NativeGas *);
|
||||
typedef struct {
|
||||
NativeCanonicalGas kernel;
|
||||
double inputs[10]; /* mass, thermal state, volume, and every medium double */
|
||||
NativeGas value;
|
||||
int medium_kind, valid;
|
||||
} NativeJacobianGasMemo;
|
||||
typedef struct { unsigned long evaluations, reuses; } NativeJacobianGasStats;
|
||||
int native_jacobian_gas(NativeJacobianGasMemo *,NativeCanonicalGas,const NativeMedium *,
|
||||
double mass,double thermal,double volume,NativeGas *,NativeJacobianGasStats *);
|
||||
enum { NATIVE_JACOBIAN_PH, NATIVE_JACOBIAN_DENSITY, NATIVE_JACOBIAN_PIPE, NATIVE_JACOBIAN_SCALAR_KINDS };
|
||||
#define NATIVE_JACOBIAN_SCALAR_KEYS 10
|
||||
typedef struct {
|
||||
uint64_t hash;
|
||||
double inputs[NATIVE_JACOBIAN_SCALAR_KEYS], value;
|
||||
int kind, medium_kind;
|
||||
size_t input_count;
|
||||
} NativeJacobianScalarEntry;
|
||||
struct NativeJacobianScalars {
|
||||
NativeJacobianScalarEntry *entries;
|
||||
size_t capacity; /* power of two; zero disables the optional cache */
|
||||
int recording;
|
||||
unsigned long evaluations[NATIVE_JACOBIAN_SCALAR_KINDS], reuses[NATIVE_JACOBIAN_SCALAR_KINDS];
|
||||
};
|
||||
int native_jacobian_scalar_get(NativeJacobianScalars *,int kind,int medium_kind,
|
||||
const double *inputs,size_t count,double *value);
|
||||
void native_jacobian_scalar_put(NativeJacobianScalars *,int kind,int medium_kind,
|
||||
const double *inputs,size_t count,double value);
|
||||
double native_temperature_ph_context(NativePropertyCache *, const NativeMedium *, double p, double h);
|
||||
double native_density_context(NativePropertyCache *, const NativeMedium *, double p, double T);
|
||||
int native_orifice_context(NativePropertyCache *, double p1, double p2, double h1, double h2,
|
||||
|
||||
Reference in new issue
Block a user