root/src/getSystemCPUs.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. getSystemCPUs
  2. getSystemCPUs

   1 /*     CALCULIX - A 3-dimensional finite element program                 */
   2 /*              Copyright (C) 1998 Guido Dhondt                          */
   3 /*     This program is free software; you can redistribute it and/or     */
   4 /*     modify it under the terms of the GNU General Public License as    */
   5 /*     published by the Free Software Foundation; either version 2 of    */
   6 /*     the License, or (at your option) any later version.               */
   7 
   8 /*     This program is distributed in the hope that it will be useful,   */
   9 /*     but WITHOUT ANY WARRANTY; without even the implied warranty of    */ 
  10 /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the      */
  11 /*     GNU General Public License for more details.                      */
  12 
  13 /*     You should have received a copy of the GNU General Public License */
  14 /*     along with this program; if not, write to the Free Software       */
  15 /*     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         */
  16 /*
  17         Added for a consistent way to determine the number of available cores
  18         for both *NIX and Windows systems. Convergent Mechanical, Dec 5, 2012
  19 */
  20 
  21 #include <unistd.h>
  22 #include <stdio.h>
  23 #include <math.h>
  24 #include <stdlib.h>
  25 #include <pthread.h>
  26 #include "CalculiX.h"
  27 
  28 #ifdef __WIN32
  29 #include <windows.h>
  30 
  31 ITG getSystemCPUs(){
  32         SYSTEM_INFO sysinfo;
  33         GetSystemInfo( &sysinfo );
  34         return sysinfo.dwNumberOfProcessors;
  35 }
  36 
  37 #else
  38 #include <unistd.h>
  39 
  40 ITG getSystemCPUs(){
  41         return sysconf(_SC_NPROCESSORS_CONF);;
  42 }
  43 #endif

/* [<][>][^][v][top][bottom][index][help] */