[openib-general] perftest-03: put C code in .c file
Grant Grundler
iod00d at hp.com
Wed May 11 07:58:50 PDT 2005
On Tue, May 10, 2005 at 06:48:20PM -0700, Tom Duffy wrote:
> Do a "svn add" on the new file. You don't need check in privileges to
> do this.
ah thanks!
Here's a new perftest-03 patch (with get_clock.c).
grant
diff -u get_clock.h get_clock.h
--- get_clock.h (working copy)
+++ get_clock.h (working copy)
@@ -32,9 +32,6 @@
* $Id$
*/
-#include <unistd.h>
-#include <stdio.h>
-
#if defined (__x86_64__) || defined(__i386__)
typedef unsigned long long cycles_t;
static inline cycles_t get_clock()
@@ -71,29 +68,2 @@
-double get_cpu_mhz()
-{
- 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)
- 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;
-}
+
+extern double get_cpu_mhz(void);
only in patch2:
unchanged:
--- Makefile (revision 2302)
+++ Makefile (working copy)
@@ -1,6 +1,9 @@
CFLAGS = -Wall -O2 -g -D_GNU_SOURCE
-rdma_lat: rdma_lat.c get_clock.h
- gcc $(CFLAGS) -o rdma_lat rdma_lat.c -libverbs
+RDMA_LAT_OBJ = rdma_lat.o get_clock.o
+
+rdma_lat: $(RDMA_LAT_OBJ)
+ gcc -o rdma_lat $(RDMA_LAT_OBJ) -libverbs
+
clean:
- rm -f rdma_lat
+ rm -f rdma_lat $(RDMA_LAT_OBJ)
only in patch2:
unchanged:
--- get_clock.c (revision 0)
+++ get_clock.c (revision 0)
@@ -0,0 +1,66 @@
+/*
+ * 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$
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+
+double get_cpu_mhz()
+{
+ 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)
+ 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;
+}
More information about the general
mailing list