Skip to content

Commit 180f971

Browse files
committed
Added support for SPARC.
From: shamir rabinovitch <[email protected]> Change-Id: Ide7735ea6c51bfcab097c8809831133a316b55df Signed-off-by: Gil Rockah <[email protected]>
1 parent eb08797 commit 180f971

File tree

5 files changed

+77
-1
lines changed

5 files changed

+77
-1
lines changed

README_sparc

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
=======================================
2+
Build instructions:
3+
=======================================
4+
5+
# ./autogen.sh
6+
7+
# ./configure --build= --host=sparc64-redhat-linux-gnu
8+
--target=sparc64-linux --program-prefix= --prefix=/usr
9+
--exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin
10+
--sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include
11+
--libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var
12+
--sharedstatedir=/var/lib --mandir=/usr/share/man
13+
--infodir=/usr/share/info
14+
15+
# make clean && make V=1
16+
17+
18+
=======================================
19+
RPM queries:
20+
=======================================
21+
22+
# rpm --eval %{_target}
23+
sparc64-linux
24+
25+
# rpm --eval %{_host}
26+
sparc64-redhat-linux-gnu
27+
28+
29+
=======================================
30+
GCC queries:
31+
=======================================
32+
33+
Get all the gcc definitions for the platform:
34+
35+
# gcc -E -dM - < /dev/null
36+
...
37+
#define __sparc__ 1
38+
...
39+
#define __arch64__ 1
40+
...
41+
42+

configure.ac

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ AC_SUBST(MAJOR_VERSION)
2222
AC_SUBST(MINOR_VERSION)
2323

2424
AC_ARG_VAR(CUDA_H_PATH, help-string)
25+
AC_ARG_VAR(RANLIB, ranlib tool)
2526

2627
AC_ARG_ENABLE([verbs_exp],
2728
[AS_HELP_STRING([--disable-verbs_exp],
@@ -37,6 +38,7 @@ AC_PROG_CXX
3738
AM_PROG_AS
3839
AC_PROG_INSTALL
3940
AC_PROG_LIBTOOL
41+
AC_PROG_RANLIB
4042
AC_HEADER_STDC
4143
AC_CHECK_HEADERS([infiniband/verbs.h],,[AC_MSG_ERROR([ibverbs header files not found])])
4244
AC_CHECK_LIB([ibverbs], [ibv_get_device_list], [], [AC_MSG_ERROR([libibverbs not found])])

src/get_clock.c

+18
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#include <unistd.h>
4646
#include <stdio.h>
47+
#include <string.h>
4748
#include "get_clock.h"
4849

4950
#ifndef DEBUG
@@ -154,6 +155,23 @@ static double proc_get_cpu_mhz(int no_cpu_freq_fail)
154155
#elif defined (__PPC__) || defined (__PPC64__)
155156
/* PPC has a different format as well */
156157
rc = sscanf(buf, "clock : %lf", &m);
158+
#elif defined (__sparc__) && defined (__arch64__)
159+
/*
160+
* on sparc the /proc/cpuinfo lines that hold
161+
* the cpu freq in HZ are as follow:
162+
* Cpu{cpu-num}ClkTck : 00000000a9beeee4
163+
*/
164+
int i;
165+
char *s;
166+
unsigned val;
167+
168+
s = strstr(buf, "ClkTck\t: ");
169+
if (!s)
170+
continue;
171+
s += (strlen("ClkTck\t: ") - strlen("0x"));
172+
strncpy(s, "0x", strlen("0x"));
173+
rc = sscanf(s, "%x", &val);
174+
m = val/1000000;
157175
#else
158176
rc = sscanf(buf, "cpu MHz : %lf", &m);
159177
#endif

src/get_clock.h

100644100755
+7
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ static inline cycles_t get_cycles(void)
7878
asm volatile("stck %0" : "=Q" (clk) : : "cc");
7979
return clk >> 2;
8080
}
81+
#elif defined(__sparc__) && defined(__arch64__)
82+
typedef unsigned long long cycles_t;
83+
cycles_t; static inline cycles_t get_cycles(void) {
84+
cycles_t v;
85+
asm volatile ("rd %%tick, %0" : "=r" (v) : );
86+
return v;
87+
}
8188
#elif defined(__aarch64__)
8289

8390
typedef unsigned long cycles_t;

src/perftest_parameters.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,14 @@ static int get_cache_line_size()
107107
int size = sysconf(_SC_LEVEL1_DCACHE_LINESIZE);
108108
if (size == 0)
109109
{
110-
char* file_name = "/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size";
110+
#if defined(__sparc__) && defined(__arch64__)
111+
char* file_name =
112+
"/sys/devices/system/cpu/cpu0/l2_cache_line_size";
113+
#else
114+
char* file_name =
115+
"/sys/devices/system/cpu/cpu0/cache/index0/coherency_line_size";
116+
#endif
117+
111118
FILE *fp;
112119
char line[10];
113120
fp = fopen(file_name, "r"); //open file , read only

0 commit comments

Comments
 (0)