| 1 | #if HAVE_CONFIG_H |
| 2 | # include "config.h" |
| 3 | #endif |
| 4 | |
| 5 | #if HAVE_STDIO_H |
| 6 | # include <stdio.h> |
| 7 | #endif |
| 8 | #if HAVE_STRING_H |
| 9 | # include <string.h> |
| 10 | #endif |
| 11 | |
| 12 | /* determine number of CPUs on the current SMP node- Linux version for now */ |
| 13 | |
| 14 | int armci_getnumcpus(void) |
| 15 | { |
| 16 | int numproc = 0; |
| 17 | FILE* fp; |
| 18 | char line[80]; |
| 19 | fp = fopen("/proc/cpuinfo","r"); |
| 20 | |
| 21 | if(fp == NULL) |
| 22 | return -1; |
| 23 | |
| 24 | while(!feof(fp)){ |
| 25 | fgets(line,80,fp); |
| 26 | if(strncmp(line,"processor",9)==0) |
| 27 | numproc++; |
| 28 | } |
| 29 | fclose(fp); |
| 30 | return numproc; |
| 31 | } |
| 32 |