CPU vendor agnostic performance optimizations

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
misterice
Kobold
Posts: 33
Joined: Thu Jan 12, 2006 12:06 am
Location: Austria

CPU vendor agnostic performance optimizations

Post by misterice » Fri Mar 13, 2009 4:22 pm

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.
0 x

User avatar
misterice
Kobold
Posts: 33
Joined: Thu Jan 12, 2006 12:06 am
Location: Austria

Re: CPU vendor agnostic performance optimizations

Post by misterice » Fri Mar 13, 2009 8:50 pm

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: -------------------------
0 x

User avatar
Nargil
Greenskin
Posts: 124
Joined: Thu Feb 15, 2007 8:47 pm

Re: CPU vendor agnostic performance optimizations

Post by Nargil » Fri Mar 13, 2009 10:18 pm

does it give you a performance boost ?
0 x
Hardcore libertarian, hardcore programmer.
Dell M6300: T9300, 4GB, Quadro FX1600M, 17" 1920x1200p non-glare, OCZ Vertex 120 + external Seagate 120GB 7200.3
Use the power of 2 - literally. Non 2^n texture sizes may crash your graphic driver

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: CPU vendor agnostic performance optimizations

Post by reptor » Fri Mar 13, 2009 10:56 pm

Well, it does sound crazy that the detection only works for "GenuineIntel" and "AuthenticAMD".
0 x

Post Reply