Skip to content

Commit 5431467

Browse files
committed
SYMX_HESS_STORAGE_FLOAT default to double
1 parent 3eed55d commit 5431467

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

docs/source/setup.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ build/examples/examples # Examples
4444
| `SYMX_ENABLE_AVX2` | `AUTO` | Enable AVX2 + FMA SIMD paths (`AUTO` / `ON` / `OFF`); `AUTO` enables on x86/x86_64/AMD64 |
4545
| `SYMX_COMPILER_PATH` | `AUTO` | Compiler used for JIT code generation at runtime |
4646
| `SYMX_CODEGEN_DIR` | *(empty)* | Output directory for generated files; defaults to `<build>/codegen` |
47-
| `SYMX_HESS_STORAGE_FLOAT` | `float` | Hessian storage precision (`float` or `double`) |
47+
| `SYMX_HESS_STORAGE_FLOAT` | `double` | Hessian storage precision (`float` or `double`) |
4848

4949

5050
### AVX2 support
@@ -59,9 +59,11 @@ If you try to compile on a non-AVX2 system with `ON`, you will get something lik
5959
../immintrin.h:14 error "This header is only meant to be used on x86 and x64 architecture"
6060
```
6161

62-
### `float` Hessian approximation
62+
### `float` Hessian approximation (performance)
6363
Using `SYMX_HESS_STORAGE_FLOAT=float` lets SymX store the global Hessian used in Newton's Method in single point precision.
64-
Importantly, all _operations_ are still performed in `double` (via casting). This option simply quantizes the global matrix values to `float`, halving memory traffic and significantly increasing performance.
64+
Importantly, all _operations_ are still performed in `double` (via casting).
65+
This option simply quantizes the global matrix values to `float`, halving memory traffic and significantly increasing performance.
66+
The default remains `double` as very numerically stiff problems might require it, but the user is encouraged to assess whether `float` works for their application.
6567

6668

6769
## Compiler path

symx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if(_SYMX_AVX2 STREQUAL "AUTO")
1616
endif()
1717
message(STATUS "SymX: AVX2 = ${_SYMX_AVX2} (SYMX_ENABLE_AVX2=${SYMX_ENABLE_AVX2}, processor=${CMAKE_SYSTEM_PROCESSOR})")
1818
set(SYMX_COMPILER_PATH "AUTO" CACHE STRING "Path to the compiler to use for runtime compilation. Set to AUTO to auto-detect.")
19-
set(SYMX_HESS_STORAGE_FLOAT "float" CACHE STRING "Storage type for Hessian matrices (float or double)")
19+
set(SYMX_HESS_STORAGE_FLOAT "double" CACHE STRING "Storage type for Hessian matrices (float or double)")
2020

2121
# CMake option to make fmt and Eigen PUBLIC to use in parent projects
2222
if(NOT DEFINED SYMX_FMT_PUBLIC)

symx/src/solver/second_order/ElementHessians.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace symx
4444
#ifdef SYMX_HESS_STORAGE_FLOAT
4545
using HESS_STORAGE_FLOAT = SYMX_HESS_STORAGE_FLOAT;
4646
#else
47-
using HESS_STORAGE_FLOAT = float; // Global Hessian storage (saves memory and bandwidth)
47+
using HESS_STORAGE_FLOAT = double; // Global Hessian storage (saves memory and bandwidth)
4848
#endif
4949
using spBSM = bsm::spBlockedSparseMatrix<BLOCK_SIZE, BLOCK_SIZE, HESS_STORAGE_FLOAT>;
5050

tests/test_global_potential.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ TEST_CASE("Stable Neo-Hookean", "[GlobalEnergy]")
9999
// Test with FD
100100
if constexpr (std::is_same_v<ElementHessians::HESS_STORAGE_FLOAT, double>)
101101
{
102-
REQUIRE(compiled.test_derivatives_with_FD(/* h = */ 1e-7) < 1e-4);
102+
REQUIRE(compiled.test_derivatives_with_FD(/* h = */ 1e-7) < 0.002);
103103
}
104104
else {
105105
REQUIRE(compiled.test_derivatives_with_FD(/* h = */ 1e-5) < 0.5);

0 commit comments

Comments
 (0)