Add support for AVX2 and runtime feature detection (#174)

- [x] run unit tests
- [x] run all samples
This commit is contained in:
Ethan Rutherford 2026-10-04 00:14:34 +02:00 • committed by GitHub
commit e77352cd60
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 4681 additions and 3376 deletions

View file

@ -0,0 +1,9 @@
threads,ms
1,5092.19
2,2694.4
3,1855.5
4,1450.33
5,1195.15
6,1032.87
7,924.237
8,843.199
1 threads ms
2 1 5092.19
3 2 2694.4
4 3 1855.5
5 4 1450.33
6 5 1195.15
7 6 1032.87
8 7 924.237
9 8 843.199

View file

@ -0,0 +1,9 @@
threads,ms
1,1308.56
2,683.543
3,461.149
4,351.313
5,283.848
6,239.34
7,208.293
8,185.43
1 threads ms
2 1 1308.56
3 2 683.543
4 3 461.149
5 4 351.313
6 5 283.848
7 6 239.34
8 7 208.293
9 8 185.43

View file

@ -0,0 +1,9 @@
threads,ms
1,11252.9
2,5915.73
3,4113.86
4,3194.52
5,2626.44
6,2261.77
7,2009.22
8,1824.68
1 threads ms
2 1 11252.9
3 2 5915.73
4 3 4113.86
5 4 3194.52
6 5 2626.44
7 6 2261.77
8 7 2009.22
9 8 1824.68

View file

@ -0,0 +1,9 @@
threads,ms
1,1067.06
2,558.46
3,390.698
4,300.188
5,249.834
6,218.912
7,193.65
8,175.819
1 threads ms
2 1 1067.06
3 2 558.46
4 3 390.698
5 4 300.188
6 5 249.834
7 6 218.912
8 7 193.65
9 8 175.819

View file

@ -0,0 +1,9 @@
threads,ms
1,5.0616
2,6.9262
3,7.827
4,8.2244
5,8.7631
6,8.6223
7,8.7636
8,8.9294
1 threads ms
2 1 5.0616
3 2 6.9262
4 3 7.827
5 4 8.2244
6 5 8.7631
7 6 8.6223
8 7 8.7636
9 8 8.9294

View file

@ -0,0 +1,9 @@
threads,ms
1,1163.37
2,605.215
3,411.543
4,307.527
5,249.396
6,216.535
7,184.334
8,165.442
1 threads ms
2 1 1163.37
3 2 605.215
4 3 411.543
5 4 307.527
6 5 249.396
7 6 216.535
8 7 184.334
9 8 165.442

View file

@ -0,0 +1,9 @@
threads,ms
1,2038.39
2,1110.3
3,773.18
4,603.397
5,502.292
6,434.461
7,389.414
8,355.206
1 threads ms
2 1 2038.39
3 2 1110.3
4 3 773.18
5 4 603.397
6 5 502.292
7 6 434.461
8 7 389.414
9 8 355.206

View file

@ -0,0 +1,9 @@
threads,ms
1,596.258
2,328.927
3,231.57
4,187.904
5,159.347
6,142.58
7,131.034
8,124.711
1 threads ms
2 1 596.258
3 2 328.927
4 3 231.57
5 4 187.904
6 5 159.347
7 6 142.58
8 7 131.034
9 8 124.711

View file

@ -0,0 +1,9 @@
threads,ms
1,2919.32
2,1674.26
3,1200.43
4,960.786
5,821.659
6,728.967
7,669.058
8,626.733
1 threads ms
2 1 2919.32
3 2 1674.26
4 3 1200.43
5 4 960.786
6 5 821.659
7 6 728.967
8 7 669.058
9 8 626.733

View file

@ -0,0 +1,9 @@
threads,ms
1,167.468
2,110.54
3,87.5729
4,77.6966
5,73.9776
6,71.7265
7,69.6889
8,69.3954
1 threads ms
2 1 167.468
3 2 110.54
4 3 87.5729
5 4 77.6966
6 5 73.9776
7 6 71.7265
8 7 69.6889
9 8 69.3954

View file

@ -0,0 +1,9 @@
threads,ms
1,657.535
2,386.678
3,284.076
4,245.238
5,223.137
6,208.401
7,197.529
8,194.169
1 threads ms
2 1 657.535
3 2 386.678
4 3 284.076
5 4 245.238
6 5 223.137
7 6 208.401
8 7 197.529
9 8 194.169

View file

@ -0,0 +1,9 @@
threads,ms
1,285.043
2,176.584
3,135.305
4,117.663
5,109.496
6,104.289
7,101.186
8,98.9602
1 threads ms
2 1 285.043
3 2 176.584
4 3 135.305
5 4 117.663
6 5 109.496
7 6 104.289
8 7 101.186
9 8 98.9602

View file

@ -0,0 +1,9 @@
threads,ms
1,15669.7
2,8410.7
3,5793.28
4,4493.58
5,3722.97
6,3219.45
7,2849.15
8,2562.49
1 threads ms
2 1 15669.7
3 2 8410.7
4 3 5793.28
5 4 4493.58
6 5 3722.97
7 6 3219.45
8 7 2849.15
9 8 2562.49

View file

@ -125,7 +125,7 @@ static void RunSatBenchmarks( int runCount )
int repeatCount = 1;
#endif
printf( "benchmark: sat, pairs = %d, repeats = %d\n", SAT_PAIR_COUNT, repeatCount );
printf( "benchmark: sat, pairs = %d, repeats = %d, simd width = %d\n", SAT_PAIR_COUNT, repeatCount, GetSimdWidth() );
printf( "time per query (us), sat full has the inscribed sphere bound disabled\n" );
printf( "%-20s %10s %10s %10s %10s\n", "pair", "gjk cold", "gjk warm", "sat", "sat full" );
@ -284,6 +284,7 @@ int main( int argc, char** argv )
bool enableContinuous = true;
bool recordStepTimes = false;
bool runSat = false;
int simdWidth = 0;
assert( maxThreadCount <= B3_MAX_WORKERS );
@ -338,6 +339,20 @@ int main( int argc, char** argv )
#else
printf( "The SAT benchmark requires static linkage\n" );
exit( 1 );
#endif
}
else if ( ( value = MatchValue( arg, "-simd=", "--simd-width=" ) ) != NULL )
{
simdWidth = atoi( value );
if ( simdWidth != 4 && simdWidth != 8 )
{
printf( "The SIMD width must be 4 or 8\n" );
exit( 1 );
}
#ifndef BOX3D_INTERNAL_BENCHMARKS
printf( "Forcing the SIMD width requires static linkage\n" );
exit( 1 );
#endif
}
else if ( strcmp( arg, "-l" ) == 0 || strcmp( arg, "--list" ) == 0 )
@ -355,6 +370,7 @@ int main( int argc, char** argv )
"-nc, --no-continuous: disable continuous collision\n"
"-s, --record-steps: record step times\n"
"-sat, --sat: compare GJK and SAT on hull pairs, then exit\n"
"-simd, --simd-width=<4|8>: force the SIMD width (static Box3D only)\n"
"-l, --list: list the registered benchmarks\n"
"-h, --help: print this help\n" );
exit( 0 );
@ -371,6 +387,11 @@ int main( int argc, char** argv )
}
#ifdef BOX3D_INTERNAL_BENCHMARKS
if ( simdWidth != 0 )
{
SetSimdWidth( simdWidth );
}
if ( runSat )
{
RunSatBenchmarks( runCount );
@ -381,6 +402,9 @@ int main( int argc, char** argv )
printf( "Starting benchmarks\n" );
printf( "======================================\n" );
#ifdef BOX3D_INTERNAL_BENCHMARKS
printf( "simd width = %d\n", GetSimdWidth() );
#endif
for ( int benchmarkIndex = 0; benchmarkIndex < benchmarkCount; ++benchmarkIndex )
{