Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you wish this to cleanly work on Windows and take full advantage in 64bit capable platforms of the additional 1. Addressing space and 2. registers (likely of more use to you) you must have at a minimum a separate process for the 64bit ones.</p> <p>You can achieve this by having a separate executable with the relevant PE64 header. Simply using CreateProcess will launch this as the relevant bitness (unless the executable launched is in some redirected location there is no need to worry about <a href="http://msdn.microsoft.com/en-us/library/aa384187%28VS.85%29.aspx" rel="noreferrer">WoW64 folder redirection</a></p> <p>Given this limitation on windows it is likely that simply 'chaining along' to the relevant executable will be the simplest option for all different options, as well as making testing an individual one simpler.</p> <p>It also means you 'main' executable is free to be totally separate depending on the target operating system (as detecting the cpu/OS capabilities is, by it's nature, very OS specific) and then do most of the rest of your code as shared objects/dlls. Also you can 'share' the same files for two different architectures if you currently do not feel that there is any point using the differing capabilities. </p> <p>I would suggest that the main executable is capable of being forced into making a specific choice so you can see what happens with 'lesser' versions on a more capable machine (or what errors come up if you try something different).</p> <p>Other possibilities given this model are:</p> <ul> <li>Statically linking to different versions of the standard runtimes (for ones with/without thread safety) and using them appropriately if you are running without any SMP/SMT capabilities.</li> <li>Detect if multiple cores are present and whether they are real or hyper threading (also whether the OS knows how the schedule effectively in those cases)</li> <li>checking the performance of things like the system timer/high performance timers and using code optimized to this behaviour, say if you do anything where you look for a certain amount of time to expire and thus can know your best possible granularity.</li> <li>If you wish to optimize you choice of code based on cache sizing/other load on the box. If you are using unrolled loops then more aggressive unrolling options may depend on having a certain amount level 1/2 cache.</li> <li>Compiling conditionally to use doubles/floats depending on the architecture. Less important on intel hardware but if you are targetting certain ARM cpu's some have actual floating point hardware support and others require emulation. The optimal code would change heavily, even to the extent you just use conditional compilation rather than using the optimizing compiler(1).</li> <li>Making use of co-processor hardware like CUDA capable graphics cards. </li> <li>detect virtualization and alter behaviour (perhaps trying to avoid file system writes)</li> </ul> <hr> <p>As to <strong>doing</strong> this check you have a few options, the most useful one on Intel being the the <a href="http://softpixel.com/~cwright/programming/simd/cpuid.php" rel="noreferrer">cpuid</a> instruction. </p> <ul> <li>Windows <ul> <li>Use <a href="http://www.cpuid-pro.com/sysinfo.php" rel="noreferrer">someone else's implementation</a> but you'll have to pay</li> <li>Use a <a href="http://sourceforge.net/projects/cpuid/" rel="noreferrer">free open source one</a></li> </ul></li> <li>Linux <ul> <li>Use the <a href="http://linux.die.net/man/1/cpuid" rel="noreferrer">built in one</a></li> <li>You could also look at open source software doing the same thing</li> <li>Pixman does a <a href="http://git.debian.org/?p=pkg-xorg/lib/pixman.git;a=blob;f=pixman/pixman-pict.c" rel="noreferrer">fair amount of this</a> and is a permissive licence.</li> </ul></li> </ul> <p>Alternatively re-implement/update an existing one using available documentation on the features you need.</p> <p>Quite a lot of separate documents to work out how to detect things:</p> <ul> <li>Intel: <ul> <li><a href="http://software.intel.com/en-us/articles/using-cpuid-to-detect-the-presence-of-sse-41-and-sse-42-instruction-sets/" rel="noreferrer">SSE 4.1/4.2</a></li> <li><a href="http://software.intel.com/en-us/articles/implement-application-programming-model-for-streaming-simd-extensions-3-instructions/" rel="noreferrer">SSE3</a></li> <li><a href="http://www.linuxjournal.com/article/3244" rel="noreferrer">MMX</a> </li> </ul></li> </ul> <p>A large part of what you would be paying for in the CPU-Z library is someone doing all this (and the nasty little issues involved) for you.</p> <hr> <ol> <li>be careful with this - it is hard to beat decent optimizing compilers on this</li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload