1

I'm writing a program in gcc that has asm language for performance-critical sections, and I want to ensure at run-time the program is running on the correct architecture. In particular, I need to differentiate ia64 (Itanium) and x86_64 on Linux.

Do I just read /proc/cpuinfo? Seems clunky, but I can't find an appropriate kernel call.

0

3 Answers 3

2

IA64 and x86_64 are entirely different architectures. A program built for one will simply not run on the other, so your question doesn't make sense (in fact, incompatibility with the x86 instruction set is one of the reasons for IA64's lackluster market penetration, because IA64-based systems couldn't run the wide array of existing, legacy 32-bit x86-based applicaitons).

The best you could do is compile two different versions of the program, and then use a wrapper script to select the appropriate binary when the user invokes the program.

Sign up to request clarification or add additional context in comments.

Comments

2

/proc/cpuinfo is the standard interface to CPU information on linux.

It is the best option, as it is intended to be architecture-independent.

1 Comment

2

The answer is already posted, but I'll add this:

If the machine is x86 or x64, you can get more detailed information through the cpuid instruction.

http://en.wikipedia.org/wiki/CPUID

1 Comment

Thanks... this was exactly what I needed since I wanted to detect if SSE/MMX was available. Looking at other responses, looks like this is relevant only on x86_64 versus ia32.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.