c++ - Using SIMD in a Game Engine Math Library by using function pointers ~ A good idea? -
i have been reading game engine books since 14 (at time didn't understand thing:p) quite years later wanted start programming mathmatical basis game engine. i've been thinking long how design 'library'. (which mean "organized set of files") every few years new simd instructionsets come out, , wouldn't want them go waste. (tell me if wrong this.)
i wanted @ least have following properties:
- making able check if has simd @ runtime, , use simd if has , uses normal c++ version if doesn't. (might have call overhead, worth it?)
- making able compile simd or normal c++ if know target @ compile time. calls can inlined , made suitable cross-optimisation because compiler knows if simd or c++ used.
edit - want make sourcecode portable can run on other deviced x86(-64) too
so thought solution use function pointers make static , initialize @ start of program. , suited functions(for example multiplication of matrix/vector) call.
what think advantages , disadvantages(which outweights more?) of design , possible create both properties described above?
christian
it's important right granularity @ make decision on routine call. if @ low level function dispatch overhead becomes problem, e.g. small routine has few instructions become inefficient if called via kind of function pointer dispatch mechanism rather being inlined. ideally architecture-specific routines should processing reasonable amount of data function dispatch cost negligible, without being large significant code bloat due compiling additional non-architecture-specific code each supported architecture.
Comments
Post a Comment