Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/vis12/src/lib/parallel-target/cpu.c
ViewVC logotype

Diff of /branches/vis12/src/lib/parallel-target/cpu.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1830, Fri Apr 13 13:33:27 2012 UTC revision 1831, Fri Apr 13 13:33:40 2012 UTC
# Line 17  Line 17 
17  #endif  #endif
18  #include <errno.h>  #include <errno.h>
19    
20  /*! \brief determine the number of CPUs */  /*! \brief determine the number of CPUs
21  bool GetNumCPUs (CPUInfo_t *info)   *  \return true if there is an error, false otherwise.
22     */
23    bool Diderot_GetNumCPUs (CPUInfo_t *info)
24  {  {
25  #if defined(HAVE__PROC_CPUINFO)  #if defined(HAVE__PROC_CPUINFO)
26    /* Get information from /proc/cpuinfo.  The interesting    /* Get information from /proc/cpuinfo.  The interesting
# Line 63  Line 65 
65          info->numThdsPerCore = info->numHWThreads / info->numHWCores;          info->numThdsPerCore = info->numHWThreads / info->numHWCores;
66  #endif  #endif
67    
68          return true;          return false;
69      }      }
70      else {      else {
71          fprintf(stderr, "unable to determine the number of processors\n");          fprintf(stderr, "unable to determine the number of processors\n");
72          return false;          return true;
73      }      }
74  #elif defined(__APPLE__)  #elif defined(__APPLE__)
75      size_t      len = sizeof(int);      size_t      len = sizeof(int);
# Line 80  Line 82 
82          }          }
83          else {          else {
84              fprintf(stderr, "unable to determine the number of nodes\n");              fprintf(stderr, "unable to determine the number of nodes\n");
85              return false;              return true;
86          }          }
87      }      }
88    
89    /* the number of cores */    /* the number of cores */
90      if (sysctlbyname("hw.physicalcpu", &(info->numHWCores), &len, 0, 0) < 0) {      if (sysctlbyname("hw.physicalcpu", &(info->numHWCores), &len, 0, 0) < 0) {
91          fprintf(stderr, "unable to determine the number of physical CPUs\n");          fprintf(stderr, "unable to determine the number of physical CPUs\n");
92          return false;          return true;
93      }      }
94    
95    /* the number of hardware threads */    /* the number of hardware threads */
# Line 98  Line 100 
100          }          }
101          else {          else {
102              fprintf(stderr, "unable to determine the number of logical CPUs\n");              fprintf(stderr, "unable to determine the number of logical CPUs\n");
103              return false;              return true;
104          }          }
105      }      }
106    
107      info->numCoresPerNode = info->numHWCores / info->numHWNodes;      info->numCoresPerNode = info->numHWCores / info->numHWNodes;
108      info->numThdsPerCore = info->numHWThreads / info->numHWCores;      info->numThdsPerCore = info->numHWThreads / info->numHWCores;
109    
     return true;  
 #else  
110      return false;      return false;
111    #else
112        return true;
113  #endif  #endif
114    
115  } /* end of GetNumCPUs */  } /* end of GetNumCPUs */

Legend:
Removed from v.1830  
changed lines
  Added in v.1831

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0