Background on APUID

The idea of APUID is twofold:

1)      Provide sample code for developers to enumerate compute devices on an AMD processor-based system.

2)      Provide a way to detect whether an AMD processor-based system has an APU or not.

To expand on the above concept a bit more elaborately:

1)      Provide a sample code for developers to enumerate compute devices on an AMD processor-based system, and:

– list the compute devices (graphics and CPU) available

– describe their characteristics (such as feature bits, ISAs supported, cache size, etc.)

2)      Provide a way to detect whether an AMD processor-based system is one with an APU or not.

– An AMD APU is an AMD Accelerated Processing Unit. An APU has CPU and GPU devices on the same die for enhanced processing power. As is explained below, we want to distinguish an APU from older solutions using IGP (Integrated Graphics Processor).

– There’s no single API or OS method to detect an APU on a PC.

– This sample program shows two ways to detect an APU via Windows OS APIs.

– See more about APUs with a product overview here, and more details here on the main AMD site.

 

Why exactly do we care about this? There are a several motivations:

  • Optimization: AMD is promoting the Heterogeneous System Architecture. Programmers are faced with the challenge of optimizing their code for different hardware environments, and want to take advantage of the additional capabilities of an APU-based solution that go beyond older IGP. This can affect how programmers tune their programming (such as how they use OpenCL) for different platforms, including AMD’s evolving HSA-based solutions. APUID is one way for the programmer to identify they are on an APU easily.
  • Branding: Identifying an APU is important for those of us that help support custom programming projects, for example as in our AMD Elite Software program. Applications in this program use similar techniques as in APUID to ensure they are running right type of AMD processor. This was one of the motivations behind APUID.
  • Technical engagement: It’s about reaching out to developers and sharing our ideas. APUID is a sequel project from a previous sample code that is discussed and available for download in the article Processor and Core Enumeration Using CPUID. This adds to the previous sample program by enumerating more properties in the APU, and adds sample code to identify the graphics properties of an APU.

Note before proceeding: I’m planning on several more articles to discuss the CPU and GPU enumeration code and what they do on AMD-based systems.

CPU vs GPU Enumeration

CPU: There is a well-formed instruction in the x86 ISA known as CPUID, which makes querying a CPU’s capabilities relatively easy. Note the CPU enumeration code in this sample is designed to be specific to AMD processors. Some, but not all of the usage of CPUID as applied in this program is common between AMD and Intel.

GPU: Although the CPU enumeration is somewhat straightforward, GPU enumeration is not. It’s dependent on OS-provided APIs to detect GPU devices on the system, as well as a priori knowledge of what constitutes an APU. The technique utilized in this sample code is based on using Windows APIs to detect the PCI Device IDs, aka DIDs. A database of known AMD GPU devices and their DIDs is compiled into the program, with a binary flag on GPU devices known to be APUs.

A list of PCI DIDs for display devices is retrieved on the system using different OS-level APIs. If any of the DIDs is in the database of known AMD GPU devices and matches the flag for APU being true, then it’s an AMD APU. The obvious drawback to this is new AMD devices must be updated regularly into the database of devices. The database is in a C include file. When this program is published to developer.amd.com, the include file in question simply needs to be updated at periodic intervals for this program to work on new AMD devices. The intent with APUID is to maintain the source code with updated device IDs as new APUs are released into the market.

In fact, AMD’s maintained an analogous list of PCI device IDs and provided a simple program to retrieve the graphics DID for the current display here for some time: ATI Catalyst™ PC Vendor ID (1002). Not surprisingly, this is also one of the ideas that helped inspire APUID.

Running APUID

C:\>apuid
CPU information:
Processor Name: AMD A10-7850K APU with Radeon(TM) R7 Graphics
Vendor = AuthenticAMD Family = 21 = 0x15 Model = 48 Stepping = 1
Number of active logical processors: 4
Number of active physical processors: 1
Physical Processor ID 0 has 4 cores as logical processors 0 1 2 3
GPU information:
You have an AMD APU
APU Graphics Device ID is 130F
APU Graphics Name is AMD Radeon(TM) R7 Graphics
APU Graphics CodeName is  Kaveri
GPU Devices:
Graphics Device 0:
From SetupDi EnumDevices APIs
GraphicsName AMD HSA (with WDDM) VendorID 1002 Device ID 130F
Number of unique GPU Devices detected : 1
Note: -cpudetails gives you more details on CPUs.
-gpudetails gives you more details on GPUs.

Programming It

At a high level, the programming interface of the APUID utility and its sample code is simple.

Data structures are populated with the details of CPU and GPUs.  A PC “system” is defined like so:

typedef struct _AMDSYSTEM
{
PAMDCPUS                   pAMDCPUData;
PGPUS                      pGPUData;
} AMDSYSTEM, *PAMDSYSTEM;
The enumerate_xxxs routines fill in the structures for CPUs and GPUs.
/* Return and populate a data structure that will contain CPU and GPU information. */
pAMDSYSTEM = AMDSYSTEM_create( );
enumerate_cpus( pAMDSYSTEM->pAMDCPUData );
enumerate_gpus( pAMDSYSTEM->pGPUData );
The print_xxx_info routines print out the details for CPUs and GPUs.
print_cpu_info( pAMDSYSTEM->pAMDCPUData );
print_gpu_info( pAMDSYSTEM->pGPUData );
Finally, this routine cleans up the data as would be done before program exit.
/* Destroy the data structure with CPU and GPU information.                         */
AMDSYSTEM_destroy( pAMDSYSTEM );

Conclusion

APUID is a sample program intended to help programmers identify whether their AMD-based system uses an APU; it enumerates the CPU cores, the CPU, and informs them about the graphics devices on the system. I’m planning on several more articles to discuss the CPU and GPU enumeration code and what they do on AMD-based systems.

Meanwhile, please download APUID from the download table below, and please provide feedback by logging in to the Developer Forum and sending me a direct message from my profile page.

 

File Name Version Size Launch Date OS Bitness Description

File Name

Version

1.0

Size

75K

Launch Date

01/20/2014

OS

Windows

Bitness

32-bit

Description

Test program source code.