Page 1 of 1

CPU vendor agnostic performance optimizations

Posted: Fri Mar 13, 2009 4:22 pm
by misterice
I recently tried to run some ogre apps on my HP 2133 Laptop which has a VIA C7-M processor. While the performance was really bad (as I expected), I also noticed that Ogre.log says that no MMX, SSE, etc. are being used:

Code: Select all

19:03:07: CPU Identifier & Features
19:03:07: -------------------------
19:03:07:  *   CPU ID: CentaurHauls: VIA C7-M Processor 1600MHz
19:03:07:  *      SSE: no
19:03:07:  *     SSE2: no
19:03:07:  *     SSE3: no
19:03:07:  *      MMX: no
19:03:07:  *   MMXEXT: no
19:03:07:  *    3DNOW: no
19:03:07:  * 3DNOWEXT: no
19:03:07:  *     CMOV: no
19:03:07:  *      TSC: no
19:03:07:  *      FPU: no
19:03:07:  *      PRO: no
19:03:07:  *       HT: no
19:03:07: -------------------------

Since the CPU supports MMX, SSE, SSE2 and SSE3 (oh yes, and a FPU ;-) ), I investigated further and noticed that in OgrePlatformInformation.cpp, the feature detection only distinguishes between the vendor strings "GenuineIntel" and "AuthenticAMD", otherwise all optimizations are disabled.

Since there are other x86 CPU manufacturers out there and the usage of netbooks & nettops with alternate CPUs (e.g. VIA Nano) will increase, I think it wouldn't hurt to make feature detection aware of other CPUs.

Re: CPU vendor agnostic performance optimizations

Posted: Fri Mar 13, 2009 8:50 pm
by misterice
Well, I just added an else section to the feature detection. It only detects the standard stuff, so I _think_ it might be safe enough to add as default detection for non Intel/AMD machines?

Code: Select all

...

else
		{
			if (result._eax > 2)
				features |= PlatformInformation::CPU_FEATURE_PRO;

			// Check standard feature
			_performCpuid(1, result);

			if (result._edx & CPUID_STD_FPU)
				features |= PlatformInformation::CPU_FEATURE_FPU;
			if (result._edx & CPUID_STD_TSC)
				features |= PlatformInformation::CPU_FEATURE_TSC;
			if (result._edx & CPUID_STD_CMOV)
				features |= PlatformInformation::CPU_FEATURE_CMOV;
			if (result._edx & CPUID_STD_MMX)
				features |= PlatformInformation::CPU_FEATURE_MMX;
			if (result._edx & CPUID_STD_SSE)
				features |= PlatformInformation::CPU_FEATURE_MMXEXT | PlatformInformation::CPU_FEATURE_SSE;
			if (result._edx & CPUID_STD_SSE2)
				features |= PlatformInformation::CPU_FEATURE_SSE2;

			if (result._ecx & CPUID_STD_SSE3)
				features |= PlatformInformation::CPU_FEATURE_SSE3;
		}
...

At least it works with my VIA CPU:

Code: Select all

20:41:45: CPU Identifier & Features
20:41:45: -------------------------
20:41:45:  *   CPU ID: CentaurHauls: VIA C7-M Processor 1600MHz
20:41:45:  *      SSE: yes
20:41:45:  *     SSE2: yes
20:41:45:  *     SSE3: yes
20:41:45:  *      MMX: yes
20:41:45:  *   MMXEXT: yes
20:41:45:  *    3DNOW: no
20:41:45:  * 3DNOWEXT: no
20:41:45:  *     CMOV: yes
20:41:45:  *      TSC: yes
20:41:45:  *      FPU: yes
20:41:45:  *      PRO: no
20:41:45:  *       HT: no
20:41:45: -------------------------

Re: CPU vendor agnostic performance optimizations

Posted: Fri Mar 13, 2009 10:18 pm
by Nargil
does it give you a performance boost ?

Re: CPU vendor agnostic performance optimizations

Posted: Fri Mar 13, 2009 10:56 pm
by reptor
Well, it does sound crazy that the detection only works for "GenuineIntel" and "AuthenticAMD".