mscroggs.co.uk
mscroggs.co.uk

subscribe

Comment

Comments

Comments in green were written by me. Comments in blue were not written by me.
@Oleg:

I removed my macros:
#define __tzcnt_u32(v) ((v) ? (_tzcnt_u32(v)) : (32))
#define __lzcnt32(v) ((v) ? (_lzcnt_u32(v)) : (32))
replacing them with simple inline code


Util.h

//#include // not including all
#include // just include what's needed
#include // just include what's needed
#include // just include what's needed

#if 1 // use safe localtime
struct tm buf; // use safe localtime
auto err = localtime_s(&buf, &cur_time); // use safe localtime
return std::put_time(&buf, "%F %T"); // use safe localtime
#else // use safe localtime
return std::put_time(std::localtime(&cur_time), "%F %T");
#endif // use safe localtime


State.h

changed _mm_set_epi8(0x80 to -0x80 to stop warnings

inline replacement:
//int i = __tzcnt_u32(mask); // for no BMI; without zero test, as not needed here
int i = _tzcnt_u32(mask); // for no BMI; without zero test, as not needed here

inline replacement:
//int last_idx_before_mid = 31 - __lzcnt32(off_mask); // for no BMI; without zero test, as not needed here
int last_idx_before_mid = _lzcnt_u32(off_mask); // for no BMI; without zero test, as not needed here


Solver.h

inline replacement:
//return ini.size(); // to stop warning
return (int)ini.size(); // to stop warning

inline replacement:
//const int dim = __tzcnt_u32(mask); // for no BMI; without zero test, as not needed here
const int dim = _tzcnt_u32(mask); // for no BMI; without zero test, as not needed here


I tried '9' runs: with asserts: 10:31, without: 10:18 (saved 2%)
A minute slower than the faulty version, but still not too bad for a 2013 (Q3) CPU :)
Lord Sméagol
on /blog/119
               

Archive

Show me a random blog post
 2026 

Feb 2026

Christmas (2025) is over
 2025 
▼ show ▼
 2024 
▼ show ▼
 2023 
▼ show ▼
 2022 
▼ show ▼
 2021 
▼ show ▼
 2020 
▼ show ▼
 2019 
▼ show ▼
 2018 
▼ show ▼
 2017 
▼ show ▼
 2016 
▼ show ▼
 2015 
▼ show ▼
 2014 
▼ show ▼
 2013 
▼ show ▼
 2012 
▼ show ▼

Tags

tmip phd cross stitch final fantasy determinants propositional calculus speed coins data preconditioning hats weak imposition databet matrix of cofactors pi approximation day royal baby machine learning numerical analysis football pi php graphs palindromes menace quadrilaterals tennis map projections polynomials noughts and crosses rugby javascript game of life weather station pascal's triangle plastic ratio simultaneous equations big internet math-off live stream the aperiodical standard deviation convergence dragon curves hexapawn crossnumber bots braiding zines accuracy people maths go logo national lottery matrix multiplication draughts binary asteroids mathsteroids mathsjam light reddit probability chebyshev youtube video games martin gardner newcastle fence posts graph theory regular expressions kings london underground computational complexity approximation ucl sorting talking maths in public manchester cambridge bubble bobble royal institution guest posts kenilworth pac-man raspberry pi wave scattering partridge puzzle ternary london game show probability python puzzles exponential growth oeis folding tube maps correlation golden spiral chalkdust magazine coventry hyperbolic surfaces arithmetic hannah fry pizza cutting european cup misleading statistics fractals advent calendar chess inverse matrices warwick anscombe's quartet pythagoras radio 4 rhombicuboctahedron captain scarlet flexagons gaussian elimination platonic solids bempp statistics error bars books finite group squares alphabets folding paper edinburgh sound boundary element methods electromagnetic field dinosaurs nine men's morris trigonometry countdown matt parker nonograms reuleaux polygons dates signorini conditions triangles interpolation gerry anderson craft programming rust realhats recursion runge's phenomenon data visualisation geometry bodmas thirteen games friendly squares manchester science festival dataset harriss spiral gather town numbers christmas frobel matrices news 24 hour maths stickers golden ratio crosswords inline code finite element method crossnumbers a gamut of games mean sport estimation matrix of minors turtles mathslogicbot fonts datasaurus dozen latex logic logs geogebra stirling numbers crochet world cup sobolev spaces curvature wool errors christmas card

Archive

Show me a random blog post
▼ show ▼
© Matthew Scroggs 2012–2026