timing-irix.C

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 
00032 // $Id: timing-irix.C,v 1.7 2007/05/30 19:20:31 legendre Exp $
00033 
00034 #include <invent.h>
00035 #include <stdio.h>
00036 #include <assert.h>
00037 #include "common/h/timing.h"
00038 
00039 
00040 double calcCyclesPerSecond_invent()
00041 {
00042   if (setinvent() == -1) {
00043     return cpsMethodNotAvailable;
00044   }
00045 
00046   unsigned raw = 0;
00047   for (inventory_t *inv = getinvent(); inv != NULL; inv = getinvent()) {
00048     /* only need PROCESSOR/CPUBOARD inventory entries */
00049     if (inv->inv_class != INV_PROCESSOR) continue;
00050     if (inv->inv_type != INV_CPUBOARD) continue;
00051     /* check for clock speed mismatch */
00052     if (raw == 0) raw = inv->inv_controller;
00053     if (inv->inv_controller != raw) {
00054       fprintf(stderr, "!!! non-uniform CPU speeds\n");
00055       endinvent();
00056       return cpsMethodNotAvailable;
00057     }
00058   }
00059   endinvent();
00060 
00061   double cps = static_cast<double>(raw) * 1000000.0; // convert MHz to Hz
00062   return cps;
00063 }
00064 
00065 double calcCyclesPerSecondOS()
00066 {
00067   double cps;
00068   cps = calcCyclesPerSecond_invent();
00069   if(cps == cpsMethodNotAvailable) {
00070      return 0;
00071   }
00072   return cps;
00073 }
00074 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1