info.c File Reference
`#include <dirent.h>`
`#include <errno.h>`
`#include <stdio.h>`
`#include "info.h"`
Include dependency graph for info.c:

Go to the source code of this file.

## Functions

int | _base_spe_count_physical_cpus (int cpu_node)
int | _base_spe_count_usable_spes (int cpu_node)
int | _base_spe_count_physical_spes (int cpu_node)
int | _base_spe_cpu_info_get (int info_requested, int cpu_node)

## Function Documentation

int _base_spe_count_physical_cpus | ( | int | cpu_node) |  |

Definition at line 30 of file info.c.

References DEBUG_PRINTF, and THREADS_PER_BE.

Referenced by _base_spe_count_physical_spes(), and _base_spe_cpu_info_get().

{
const char *buff = "/sys/devices/system/cpu";
DIR *dirp;
int ret = -2;
struct dirent *dptr;
DEBUG_PRINTF ("spe_count_physical_cpus()\n");
// make sure, cpu_node is in the correct range
if (cpu_node != -1) {
errno = EINVAL;
return -1;
}
// Count number of CPUs in /sys/devices/system/cpu
if((dirp=opendir(buff))==NULL) {
fprintf(stderr,"Error opening %s ",buff);
perror("dirlist");
errno = EINVAL;
return -1;
}
while((dptr=readdir(dirp))) {
ret++;
}
closedir(dirp);
return ret/THREADS_PER_BE;
}

int _base_spe_count_physical_spes | ( | int | cpu_node) |  |

Definition at line 71 of file info.c.

References _base_spe_count_physical_cpus(), and DEBUG_PRINTF.

Referenced by _base_spe_count_usable_spes(), and _base_spe_cpu_info_get().

{
const char *buff = "/sys/devices/system/spu";
DIR *dirp;
int ret = -2;
struct dirent *dptr;
int no_of_bes;
DEBUG_PRINTF ("spe_count_physical_spes()\n");
// make sure, cpu_node is in the correct range
no_of_bes = _base_spe_count_physical_cpus(-1);
if (cpu_node < -1 || cpu_node >= no_of_bes ) {
errno = EINVAL;
return -1;
}
// Count number of SPUs in /sys/devices/system/spu
if((dirp=opendir(buff))==NULL) {
fprintf(stderr,"Error opening %s ",buff);
perror("dirlist");
errno = EINVAL;
return -1;
}
while((dptr=readdir(dirp))) {
ret++;
}
closedir(dirp);
if(cpu_node != -1) ret /= no_of_bes; // FIXME
return ret;
}

Here is the call graph for this function:

int _base_spe_count_usable_spes | ( | int | cpu_node) |  |

Definition at line 62 of file info.c.

References _base_spe_count_physical_spes().

Referenced by _base_spe_cpu_info_get().

{
return _base_spe_count_physical_spes(cpu_node); // FIXME
}

Here is the call graph for this function:

int _base_spe_cpu_info_get | ( | int | info_requested,
|  | int | cpu_node
| ) |  |

_base_spe_info_get

Definition at line 105 of file info.c.

References _base_spe_count_physical_cpus(), _base_spe_count_physical_spes(), _base_spe_count_usable_spes(), SPE_COUNT_PHYSICAL_CPU_NODES, SPE_COUNT_PHYSICAL_SPES, and SPE_COUNT_USABLE_SPES.

{
int ret = 0;
errno = 0;
switch (info_requested) {
case SPE_COUNT_PHYSICAL_CPU_NODES:
ret = _base_spe_count_physical_cpus(cpu_node);
break;
case SPE_COUNT_PHYSICAL_SPES:
ret = _base_spe_count_physical_spes(cpu_node);
break;
case SPE_COUNT_USABLE_SPES:
ret = _base_spe_count_usable_spes(cpu_node);
break;
default:
errno = EINVAL;
ret = -1;
}
return ret;
}

Here is the call graph for this function: