spe_cpu_info_get

NAME

spe_cpu_info_get - Query basic CPU properties and resources.

SYNOPSIS

#include <libspe2.h>

int spe_cpu_info_get(unsigned int info_requested, int cpu_node)

Parameters  
info_requested Specifies the type of information requested.
cpu_node Specifies the node for which the information is requested. The numbering of CPU nodes is consistent with the numbering used by the NUMA control. This information can be used in conjunction with explicit NUMA control by the application.

DESCRIPTION

Applications often require some basic information about the system they are running on, such as number of CPUs (PPEs) or number of SPEs.

In the context of this API, the term "system" means the "hardware" seen by the currently running operating system, and the term "physical" refers to resources in that system. For example, in case of a hypervisor-based system, the result returned can be different from the actual number of items present in the hardware.

RETURN VALUE

On success, this function returns 0 (zero) or a positive value that indicates the value requested.

EXIT STATUS

On error, -1 is returned and errno is set to indicate the error.

Possible errors include:

EINVAL Function argument error

USAGE

The following values for info_requested are accepted:

Flag Description
SPE_COUNT_PHYSICAL_CPU_NODES Request the number of physical CPU nodes of the system
SPE_COUNT_PHYSICAL_SPES Request the total number of physical SPEs available either on the whole system or on a specified node.
SPE_COUNT_USABLE_SPES Request the number of SPEs that can actually be used by the application at this point in time. This is the number of SPEs that can actually be scheduled to run for the application, provided it has high enough scheduling priority. In particular, if the operating system reserves SPEs or (privileged) applications have "pinned" SPEs, that is, made them non-schedulable, these are not counted as usable SPEs.

The following values for cpu_node are accepted:

Flags Description
-1 Request an aggregated result for the whole system.
0..(n-1) Request information for this specific CPU node. n is the number of physical CPU nodes in the system. On platforms with enabled NUMA-support, the numbering of CPU nodes is consistent with the numbering used by the NUMA control. This information can be used in conjunction with explicit NUMA control by the application. On platforms with a single processor, the number of the CPU node is 0. On platforms with multiple processors but without enabled NUMA-support, the numbering of CPU nodes is not specified. In this case, the operating system may also not be able to determine the association of SPEs with CPU nodes properly.

EXAMPLES

Assume the application is running on a system which as two Cell BE processors with eight physical SPEs available on each CPU. The operating system has reserved one SPE on node 0 for some kernel tasks and a concurrently running application has two SPEs "pinned" ("reserved exclusively", "non-schedulable") on node 1.

  no_cpus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
  ==> 2
  no_phys_spes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
  ==> 16
  no_phys_spes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, 0);
  ==> 8
  no_phys_spes = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, 1);
  ==> 8
  no_usable_spes = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1);
  ==> 13
  no_usable_spes = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, 0);
  ==> 7
  no_usable_spes = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, 1);
  ==> 6