Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 301635 Details for
Bug 433659
ib_send_bw test program fails on intel-s6e4533-01-mm
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
possibly fixed get_clock.c
get_clock.c (text/plain), 4.93 KB, created by
Doug Ledford
on 2008-04-08 14:22:32 UTC
(
hide
)
Description:
possibly fixed get_clock.c
Filename:
MIME Type:
Creator:
Doug Ledford
Created:
2008-04-08 14:22:32 UTC
Size:
4.93 KB
patch
obsolete
>/* > * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. > * > * This software is available to you under a choice of one of two > * licenses. You may choose to be licensed under the terms of the GNU > * General Public License (GPL) Version 2, available from the file > * COPYING in the main directory of this source tree, or the > * OpenIB.org BSD license below: > * > * Redistribution and use in source and binary forms, with or > * without modification, are permitted provided that the following > * conditions are met: > * > * - Redistributions of source code must retain the above > * copyright notice, this list of conditions and the following > * disclaimer. > * > * - Redistributions in binary form must reproduce the above > * copyright notice, this list of conditions and the following > * disclaimer in the documentation and/or other materials > * provided with the distribution. > * > * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, > * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND > * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS > * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN > * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN > * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > * SOFTWARE. > * > * $Id$ > * > * Author: Michael S. Tsirkin <mst@mellanox.co.il> > */ > >/* #define DEBUG 1 */ >/* #define DEBUG_DATA 1 */ >/* #define GET_CPU_MHZ_FROM_PROC 1 */ > >/* For gettimeofday */ >#define _BSD_SOURCE >#include <sys/time.h> > >#include <unistd.h> >#include <stdio.h> >#include "get_clock.h" > >#ifndef DEBUG >#define DEBUG 0 >#endif >#ifndef DEBUG_DATA >#define DEBUG_DATA 0 >#endif > >#define MEASUREMENTS 200 >#define USECSTEP 10 >#define USECSTART 100 > >/* > Use linear regression to calculate cycles per microsecond. > http://en.wikipedia.org/wiki/Linear_regression#Parameter_estimation >*/ >static double sample_get_cpu_mhz(void) >{ > struct timeval tv1, tv2; > cycles_t start; > double sx = 0, sy = 0, sxx = 0, syy = 0, sxy = 0; > double tx, ty; > int i; > > /* Regression: y = a + b x */ > long x[MEASUREMENTS]; > cycles_t y[MEASUREMENTS]; > double a; /* system call overhead in cycles */ > double b; /* cycles per microsecond */ > double r_2; > > for (i = 0; i < MEASUREMENTS; ++i) { > start = get_cycles(); > > if (gettimeofday(&tv1, NULL)) { > fprintf(stderr, "gettimeofday failed.\n"); > return 0; > } > > do { > if (gettimeofday(&tv2, NULL)) { > fprintf(stderr, "gettimeofday failed.\n"); > return 0; > } > } while ((tv2.tv_sec - tv1.tv_sec) * 1000000 + > (tv2.tv_usec - tv1.tv_usec) < USECSTART + i * USECSTEP); > > x[i] = (tv2.tv_sec - tv1.tv_sec) * 1000000 + > tv2.tv_usec - tv1.tv_usec; > y[i] = get_cycles() - start; > if (DEBUG_DATA) > fprintf(stderr, "x=%ld y=%Ld\n", x[i], (long long)y[i]); > } > > for (i = 0; i < MEASUREMENTS; ++i) { > tx = x[i]; > ty = y[i]; > sx += tx; > sy += ty; > sxx += tx * tx; > syy += ty * ty; > sxy += tx * ty; > } > > b = (MEASUREMENTS * sxy - sx * sy) / (MEASUREMENTS * sxx - sx * sx); > a = (sy - b * sx) / MEASUREMENTS; > > if (DEBUG) > fprintf(stderr, "a = %g\n", a); > if (DEBUG) > fprintf(stderr, "b = %g\n", b); > if (DEBUG) > fprintf(stderr, "a / b = %g\n", a / b); > r_2 = (MEASUREMENTS * sxy - sx * sy) * (MEASUREMENTS * sxy - sx * sy) / > (MEASUREMENTS * sxx - sx * sx) / > (MEASUREMENTS * syy - sy * sy); > > if (DEBUG) > fprintf(stderr, "r^2 = %g\n", r_2); > if (r_2 < 0.9) { > fprintf(stderr,"Correlation coefficient r^2: %g < 0.9\n", r_2); > return 0; > } > > return b; >} > >static double proc_get_cpu_mhz(void) >{ > FILE* f; > char buf[256]; > double mhz = 0.0; > > f = fopen("/proc/cpuinfo","r"); > if (!f) > return 0.0; > while(fgets(buf, sizeof(buf), f)) { > double m; > int rc; > rc = sscanf(buf, "cpu MHz : %lf", &m); > if (rc != 1) { /* PPC has a different format */ > rc = sscanf(buf, "clock : %lf", &m); > if (rc != 1) > continue; > } > if (mhz == 0.0) { > mhz = m; > continue; > } > if (mhz != m) { > fprintf(stderr, "Conflicting CPU frequency values" > " detected: %lf != %lf\n", mhz, m); > return 0.0; > } > } > fclose(f); > return mhz; >} > > >double get_cpu_mhz(void) >{ >#if defined(__ia64) > double i; >#endif > double sample, proc, delta; > sample = sample_get_cpu_mhz(); > proc = proc_get_cpu_mhz(); > > if (!proc || !sample) > return 0; >#if defined(__ia64) > /* > * We use the itc clock on ia64 to get cpu cycles, but the cpu > * clock may be a multiple of the itc clock. Try to pull out > * the multiple and then check for variance between proc and sample. > */ > for (i=1; i <= 10; i += .5) { > delta = proc > (sample * i) ? proc - (sample * i) : > (sample * i) - proc; > if (delta / proc < .05) > break; > } > if (i != 10.5) > sample *= i; >#endif > delta = proc > sample ? proc - sample : sample - proc; > if (delta / proc > 0.01) { > fprintf(stderr, "Warning: measured timestamp frequency " > "%g differs from nominal %g MHz\n", > sample, proc); > return sample; > } > return proc; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 433659
:
301633
|
301634
| 301635