# Maxfpeed **Repository Path**: zydistai/Maxfpeed ## Basic Information - **Project Name**: Maxfpeed - **Description**: Maxfpeed:a floating-point error detection tool targeting floating-point expressions. - **Primary Language**: C++ - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2023-10-16 - **Last Updated**: 2025-08-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: 浮点误差检测 ## README # Maxfpeed #### 介绍 Maxfpeed是一个面向浮点算术表达式的误差检测工具,集成高精度版本程序自动生成、HSED(层级搜索算法)和EIFFEL(基于拟合函数预测)两种误差检测方法。 Maxfpeed支持单参和多参表达式的检测,其中高精度版本代码自动生成参考LLVM Tutorial-Chapter 2(https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl02.html)。 测试基准可参考FPBench基准测试集(http://fpbench.org/benchmarks.html)。 示例: * predatorPrey:((4.0 * x) * x) / (1.0 + ((x / 1.11) * (x / 1.11))) * sqrt_add:(1 / (sqrt((x + 1)) + sqrt(x))) * NMSEproblem333:((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0)) * hypot: sqrt((x1 * x1) + (x2 * x2)) * nonlin2: (x1 * x2 - 1.0) / ((x1 * x2) * (x1 * x2) - 1.0) * doppler1: ( − (331.4 + (0.6 ∗ x3)) ∗ x2) / (((331.4 + (0.6 ∗ x3)) + x1) ∗ ((331.4 + (0.6 ∗ x3)) + x1)) * ...... #### 软件架构 ``` . |—— bin |—— build |—— CMakeLists.txt |—— makefile |—— README.md |—— README.en.md |—— run.sh |—— detectModule | |—— EIFFEL | | |—— include | | | |—— createInput.h | | | |—— DBSCAN.h | | | |__ errordetect.h | | |—— src | | |—— createInput.cpp | | |—— curvefitting.py | | |—— DBSCAN.cpp | | |—— dbscan.py | | |—— errordetect.cpp | | |__ getMultiResult.cpp | |—— HSED | | |—— include | | | |—— common.h | | | |—— float.h | | | |__ getresult.h | | |__ src | | |—— common.cpp | | |—— float.cpp | | |__ getresult.cpp | |—— mpfrCodeGene | | |—— include | | | |——basic.h | | | |—— color.h | | | |—— geneCode.h | | | |—— laxerAST.h | | | |__ parserAST.h | | |__ src | | |——basic.cpp | | |—— geneCode.cpp | | |—— laxerAST.cpp | | |—— main.cpp | | |__ parserAST.cpp |__ |__ CMakeLists.txt ``` #### 安装教程 * 依赖环境 MPFR、GMP、python3 (numpy,scikit-learn、pandas)、cmake,你可以通过下面执行命令来安装依赖环境。 ``` $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install libgmp-dev ligmpfr-dev cmake python3 $ pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple numpy pandas scikit-learn ``` * 注意:Maxfpeed/CMakeLists.txt文件中可能需要修改两处地方,由于我的python版本是python3.8,所以有两处地方是python3.8。注意需要修改为你的python版本,可以使用 python3 --version 查看版本,如果是python3.10,将这两处改为python3.10即可。 #### 使用说明 Maxfpeed是一个命令行工具,用户可以基于Ubuntu来使用。 ``` $ git clone https://gitee.com/zhangzuoyan/Maxfpeed.git $ cd Maxfpeed $ mkdir bin ``` 接着你可以执行run.sh脚本来进行误差检测。 ``` $ ./run.sh "para1" para2 para3 para4 ``` 其中para1是表达式,para2是区间左端点,para3是区间右端点,para4是检测方法(--HSED 或 --EIFFEL)。 例如,执行./run.sh "(4.0 * x * x) / (1 + x / 1.11 * x / 1.11)" 0 100 --HSED 输出结果如下: ``` ------------------------------------------------------------ | step1: generate high-precision version code successfully | ------------------------------------------------------------ --------------------------------------- | step2: detect FP errors | | now you choose HSED method to detect | --------------------------------------- Detection interval: [0, 100] preprocessing: x = 2.001953, maximumULP = 2.34, maximumRelative = 2.754374e-16 ---------------No significant error, excute two-layer search------------------ float-precision layer: x = 2.13522115, maximumULP = 2.87, maximumRelative = 3.279387e-16 double-precision layer: x = 2.1352211012717968, maximumULP = 3.19, maximumRelative = 3.655532e-16, BitsError = 2.1 ------------------------------------------------------------------------------- ``` 例如,执行./run.sh "(4.0 * x * x) / (1 + (x / 1.11) * (x / 1.11))" 0 100 --EIFFEL 输出结果如下: ``` ------------------------------------------------------------ | step1: generate high-precision version code successfully | ------------------------------------------------------------ ----------------------------------------- | step2: detect FP errors | | now you choose EIFFEL method to detect | ----------------------------------------- =====1. Data set construction completed!===== =====2. Boundary extraction completed!===== =====3. Automatic determination of MinPts and Eps parameters completed!===== MinPts: 12, Eps: 0.66636 =====4. DBSCAN completed and successfully!===== no. x ULP 1 0.823919 2.10557 2 2.9681 2.25284 3 4.45136 2.33375 4 9.46925 2.31113 5 17.9898 2.43869 6 37.0861 2.51231 7 72.7679 2.52831 =====5. Curve function completed!===== The lower bound function is: x_i = 1.00445 * pow(2.03817, i - 1), i >= 1 The upper bound function is: x_i = 1.41848 * pow(1.93146, i - 1), i >= 1 =====6. Prediction interval completed!===== Above are the intervals: [5.55717e-06, 1.9578e-05] [1.13264e-05, 3.78141e-05] [2.30852e-05, 7.30364e-05] [4.70515e-05, 0.000141067] [9.58987e-05, 0.000272465] [0.000195458, 0.000526255] [0.000398375, 0.00101644] [0.000811955, 0.00196321] [0.0016549, 0.00379187] [0.00337296, 0.00732384] [0.00687466, 0.0141457] [0.0140117, 0.0273218] [0.0285582, 0.052771] [0.0582064, 0.101925] [0.118634, 0.196864] [0.241797, 0.380235] [0.492822, 0.734409] [1.00445, 1.41848] [2.04724, 2.73974] [4.17263, 5.2917] [8.50451, 10.2207] [17.3336, 19.7409] [35.3288, 38.1287] [72.006, 73.644] Please wait, error detection is currently underway~ =====7. Error detection completed!===== x = 2.254804438626276, maximum ULP = 3.4609 ``` 注意:HSED目前仅支持单参表达式的检测,所以当使用--HSED时注意检测对象是单参表达式。EIFFEL支持多参表达式的检测,使用--EIFFEL时检测区间必须是[left,right](left >= 0 或者 right <= 0)。