The Gaudi Framework  v33r1 (b1225454)
CPUFamily.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 /*
12  * CPUFamily.cpp
13  *
14  * Created on: Sep 23, 2010
15  */
16 
23 #include <boost/python.hpp>
24 
25 #define cpuid( func, ax, bx, cx, dx ) \
26  __asm__ __volatile__( "cpuid" : "=a"( ax ), "=b"( bx ), "=c"( cx ), "=d"( dx ) : "a"( func ) );
27 
28 bool is_nehalem() {
29  int a, b, c, d;
30  cpuid( 1, a, b, c, d );
31  int sse4_2_mask = 1 << 20;
32  return ( c & sse4_2_mask );
33 }
34 
35 const char* CPUFamily() {
36  if ( is_nehalem() ) {
37  return "nehalem";
38  } else {
39  return "core";
40  }
41 }
42 
43 BOOST_PYTHON_MODULE( PyCPUFamily ) {
44  using namespace boost::python;
45  def( "CPUFamily", CPUFamily );
46 }
BOOST_PYTHON_MODULE(PyCPUFamily)
Definition: CPUFamily.cpp:43
#define cpuid(func, ax, bx, cx, dx)
Definition: CPUFamily.cpp:25
bool is_nehalem()
Definition: CPUFamily.cpp:28
const char * CPUFamily()
Definition: CPUFamily.cpp:35