setting the speed for the future of games programming
vectorc

contentsclose
 

DETECTING PC PROCESSORS

In order to use the advanced features of VectorC, you need to compile your program separately for different processors and run the best version for the user's processor. Therefore, you will need a way to detect the features of the user's processor. Remember that you need to detect the features of the processor in a future-proof way, so it is not correct to just detect a Pentium II, but also all processors that can execute all of the Pentium II's instructions.

You may also want to take into account the scheduling characteristics of a processor. Although two processors may execute the same instructions, they may not execute them with the same timings.

PC Processors are described here.

The easiest way to detect processors is to use the file 'cpuid.c'. This compiles to a simple demonstration program, but by cutting out 'main', you can include this file in your programs. The 'is' functions are the easiest to use - they will return TRUE for a processor and its compatible descendants.


isPentium returns true for Pentiums and compatible.

isPentiumMMX returns true for Pentiums with MMX and compatible. i.e. all processors with MMX support.

isPentiumPro returns true for PentiumPros and compatibles (Celeron, Pentium II, Pentium III and AMD K7).

isPentiumII returns true for Pentium IIs and compatibles. This is a Pentium Pro with MMX.

isPentiumIII returns true for Pentium IIIs and compatibles with operating system support. This is a Pentium II with SSE. This function only returns true when operating system support for SSE is present as this is required for SSE to function.

isAMDK6 returns true for AMD K6s with MMX. Some early K6s did not have MMX support and will return false with this instruction. This is similar to the isPentiumMMX function, except that it returns false for Intel CPUs. This is useful to determine scheduling characteristics.

isAMDK62 returns true for AMD K6-2s and all other processors that support MMX and 3D Now. No Intel processors currently support 3D Now.

isAthlon returns true for AMD Athlon.


You can also use the CPUID instruction yourself. The function is described by processor manufacturers.

top

contentsclose