Jack Lloyd
Jack Lloyd

Reputation: 8405

How do you detect processor features on AIX?

On PowerPC/POWER, there is no consistent way for a userspace program to detect processor features like SIMD instruction sets.

The architecture defines a model specific register PVR which contains the processor identifier. However the mfspr instruction used to read it is priveledged. Linux and NetBSD will trap and emulate PVR reads for userspace.

On OpenBSD and OS X, sysctl(3) calls allow access to this information.

However AIX neither allows userspace access to PVR, nor has a sysctl API. So, how does one detect the existence/absence of a processor feature when running on AIX?

Upvotes: 2

Views: 139

Answers (1)

Qiu Chaofan
Qiu Chaofan

Reputation: 135

In Power sytems, SIMD facility is included in VMX and VSX instruction sets. systemcfg may help:

#include <stdio.h>
#include <sys/systemcfg.h>

int main(void) {
  unsigned vmx_version = getsystemcfg(SC_VMX_VER);
  switch (vmx_version) {
  case 0: puts("VMX disabled"); break;
  case 1: puts("VMX enabled"); break;
  default: puts ("VSX enabled"); break;
  }
  return 0;
}

Actually systemcfg.h defined a list of macros to test system functionality:

__power_64(): is 64-bit or not
__power_4() to __power_10(): is specific Power version
__power_4_andup() to __power_10_andup(): similar, but includes previous versions
__power_vmx(): VMX enabled
__power_vsx(): VSX enabled
__power_dfp(): decimal FP enabled
__power_tm(): transactional memory enabled

Upvotes: 0

Related Questions