pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
930 stars 154 forks source link

SIMD level must be easily controllable at runtime #2914

Open ankith26 opened 5 months ago

ankith26 commented 5 months ago

moving my comment from https://github.com/pygame-community/pygame-ce/pull/2897 to an issue:

Everytime someone has to test a lower SIMD level they have to mess with either the buildconfig or the source code itself, and this is not ideal. Especially if we want a user to test out something.

One approach is to have env variables PG_ENABLE_[AVX2|SSE2|NEON] that can be configured before pygame init. On init, these variables are read, and along with runtime detection, we set the corresponding runtime check values.

Another approach is to have some API, probably in pygame.system, to pythonically get/set this

A point by @Starbuck5

We will get this for free when SDL3 comes out, btw. SDL_HINT_CPU_FEATURE_MASK.

itzpr3d4t0r commented 5 months ago

This sounds pretty useful, sign me up!

oddbookworm commented 5 months ago

Everytime someone has to test a lower SIMD level they have to mess with either the buildconfig or the source code itself, and this is not ideal. Especially if we want a user to test out something. One approach is to have env variables PG_ENABLE_[AVX2|SSE2|NEON] that can be configured before pygame init. On init, these variables are read, and along with runtime detection, we set the corresponding runtime check values.

I'm thinking it should actually be kinda the other way around, the env variables disable specific things. We don't want end users to usually have to worry about enabling instruction sets unless they're doing something specific