Skip to content

MNT: Change default optimization levels#84

Merged
greglucas merged 1 commit intoSWxTREC:mainfrom
greglucas:win-testing
Jul 2, 2025
Merged

MNT: Change default optimization levels#84
greglucas merged 1 commit intoSWxTREC:mainfrom
greglucas:win-testing

Conversation

@greglucas
Copy link
Member

Don't optimize windows, increase optimization on linux/mac

  • Add meson default buildtype=release (O3)
  • Add -ffast-math flag if compiler supports it

Profiling

Doing some quick timing examples locally to see what kind of difference this makes and it is larger than I expected, with ~3x difference. Windows friends, I'm sorry, perhaps someone with a Windows machine can debug how to fix the tests when we start including compiler optimizations.

Example script

import time

import numpy as np

from pymsis import msis


lons = np.arange(90)
lats = np.arange(37)
alts = np.arange(72) + 200
dates = np.datetime64("2010-01-01T00:00") + np.timedelta64(1, "h") * np.arange(6)

start = time.perf_counter()
for _ in range(20):
    output = msis.run(dates, lons, lats, alts)
end = time.perf_counter()
print("Time elapsed (20 calls): ", end - start)

Results

FFLAGS Time (s)
-Ofast 8.16
-O3 11.78
-O2 12.34
-O1 13.34
-O0 23.5

Don't optimize windows, increase optimization on linux/mac
Windows = -O0
Linux/Mac = -O2
@greglucas greglucas merged commit 4459b39 into SWxTREC:main Jul 2, 2025
26 checks passed
@greglucas greglucas deleted the win-testing branch July 2, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant