Im trying to make a few efficient maths classes that will optomise using SIMD SSE or SSE2 if the target CPU supports those SIMD variants or failing to support either use a normal CPU bound c++ version.
The issue im having is that i want to have for example a vector class
Vector3D which always looks the same to the developer but using function pointers or derived classes to change the implimentation based on a global var such as
int gloabalSSE// -1 for no sse, 1 for sse and 2 for sse2 support.
so when i create a Vector instance such as
the constructor will evaluate the global var (this is set by a function i have that is run upon program starting and it works how i want no problems there) and then use the correct version of each member function such as
the code looks the same to the programmer but the code implimenting the Normalise() function uses the best SIMD optomisation available on the target CPU.
Im using Win XP + Visual stuido 2008 express (have a pro install available to me as well)
So really to summarise the question im asking is, how do i make a class that always looks the same to the user but uses either function pointers or derived classes to achieve the best SIMD optomisation that the target CPU supports. IF i have to use derived classes i would aprpeciate if you could suggest how i can make all the derived classes still be called Vector3D when used in code.
Also i know there is no code here but i think this question is really idependant of the code as its more of a class usage thing than how the functions are implimented really but for completeness i attached my current function pointers attempt.
Ill admit im somewhat new to c++ and still geting used to using c++ features rather than c which i started a few years ago. so please dont think why such a n00b programmer is asking to use SIMD optomisation when he doesnt understand classes, it's cause i want to try make the class really good once then hopefully it wont need me to come back later to update it :)
Thanks again for your time.
Edited 6 Years Ago by Kanoisa: n/a