Skip to content

Commit c0da205

Browse files
authored
Merge pull request #38 from xianyi/develop
rebase
2 parents 9c22170 + af8a619 commit c0da205

23 files changed

Lines changed: 2737 additions & 36 deletions

Makefile.system

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,16 @@ endif
635635
ifeq ($(ARCH), arm64)
636636
NO_BINARY_MODE = 1
637637
BINARY_DEFINED = 1
638+
ifdef INTERFACE64
639+
ifneq ($(INTERFACE64), 0)
640+
ifeq ($(F_COMPILER), GFORTRAN)
641+
FCOMMON_OPT += -fdefault-integer-8
642+
endif
643+
ifeq ($(F_COMPILER), FLANG)
644+
FCOMMON_OPT += -i8
645+
endif
646+
endif
647+
endif
638648
endif
639649

640650

benchmark/Makefile

Lines changed: 297 additions & 1 deletion
Large diffs are not rendered by default.

benchmark/her.c

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
/***************************************************************************
2+
Copyright (c) 2020, The OpenBLAS Project
3+
All rights reserved.
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in
11+
the documentation and/or other materials provided with the
12+
distribution.
13+
3. Neither the name of the OpenBLAS project nor the names of
14+
its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*****************************************************************************/
27+
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#ifdef __CYGWIN32__
31+
#include <sys/time.h>
32+
#endif
33+
#include "common.h"
34+
35+
36+
#undef HER
37+
38+
39+
#ifdef DOUBLE
40+
#define HER BLASFUNC(zher)
41+
#else
42+
#define HER BLASFUNC(cher)
43+
#endif
44+
45+
46+
#if defined(__WIN32__) || defined(__WIN64__)
47+
48+
#ifndef DELTA_EPOCH_IN_MICROSECS
49+
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
50+
#endif
51+
52+
int gettimeofday(struct timeval *tv, void *tz){
53+
54+
FILETIME ft;
55+
unsigned __int64 tmpres = 0;
56+
static int tzflag;
57+
58+
if (NULL != tv)
59+
{
60+
GetSystemTimeAsFileTime(&ft);
61+
62+
tmpres |= ft.dwHighDateTime;
63+
tmpres <<= 32;
64+
tmpres |= ft.dwLowDateTime;
65+
66+
/*converting file time to unix epoch*/
67+
tmpres /= 10; /*convert into microseconds*/
68+
tmpres -= DELTA_EPOCH_IN_MICROSECS;
69+
tv->tv_sec = (long)(tmpres / 1000000UL);
70+
tv->tv_usec = (long)(tmpres % 1000000UL);
71+
}
72+
73+
return 0;
74+
}
75+
76+
#endif
77+
78+
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
79+
80+
static void *huge_malloc(BLASLONG size){
81+
int shmid;
82+
void *address;
83+
84+
#ifndef SHM_HUGETLB
85+
#define SHM_HUGETLB 04000
86+
#endif
87+
88+
if ((shmid =shmget(IPC_PRIVATE,
89+
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
90+
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
91+
printf( "Memory allocation failed(shmget).\n");
92+
exit(1);
93+
}
94+
95+
address = shmat(shmid, NULL, SHM_RND);
96+
97+
if ((BLASLONG)address == -1){
98+
printf( "Memory allocation failed(shmat).\n");
99+
exit(1);
100+
}
101+
102+
shmctl(shmid, IPC_RMID, 0);
103+
104+
return address;
105+
}
106+
107+
#define malloc huge_malloc
108+
109+
#endif
110+
111+
int main(int argc, char *argv[]){
112+
113+
FLOAT *a, *x;
114+
FLOAT alpha[] = {1.0, 1.0};
115+
blasint incx = 1;
116+
char *p;
117+
118+
char uplo='U';
119+
char trans='N';
120+
121+
if ((p = getenv("OPENBLAS_UPLO"))) uplo=*p;
122+
if ((p = getenv("OPENBLAS_TRANS"))) trans=*p;
123+
124+
blasint m, i, j;
125+
126+
int from = 1;
127+
int to = 200;
128+
int step = 1;
129+
130+
struct timeval start, stop;
131+
double time1;
132+
133+
argc--;argv++;
134+
135+
if (argc > 0) { from = atol(*argv); argc--; argv++;}
136+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
137+
if (argc > 0) { step = atol(*argv); argc--; argv++;}
138+
139+
fprintf(stderr, "From : %3d To : %3d Step = %3d Uplo = %c Trans = %c\n", from, to, step,uplo,trans);
140+
141+
142+
if (( a = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL){
143+
fprintf(stderr,"Out of Memory!!\n");exit(1);
144+
}
145+
146+
if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * COMPSIZE)) == NULL){
147+
fprintf(stderr,"Out of Memory!!\n");exit(1);
148+
}
149+
150+
151+
152+
#ifdef linux
153+
srandom(getpid());
154+
#endif
155+
156+
fprintf(stderr, " SIZE Flops\n");
157+
158+
for(m = from; m <= to; m += step)
159+
{
160+
fprintf(stderr, " %6d : ", (int)m);
161+
162+
for(j = 0; j < m; j++){
163+
for(i = 0; i < m * COMPSIZE; i++){
164+
a[(long)i + (long)j * (long)m * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
165+
}
166+
x[ (long)j * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
167+
}
168+
169+
gettimeofday( &start, (struct timezone *)0);
170+
171+
HER (&uplo, &m, alpha, x, &incx, a, &m );
172+
173+
gettimeofday( &stop, (struct timezone *)0);
174+
175+
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
176+
177+
gettimeofday( &start, (struct timezone *)0);
178+
179+
fprintf(stderr,
180+
" %10.2f MFlops\n",
181+
COMPSIZE * COMPSIZE * 1. * (double)m * (double)m / time1 * 1.e-6);
182+
183+
}
184+
185+
return 0;
186+
}

benchmark/her2.c

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
/***************************************************************************
2+
Copyright (c) 2020, The OpenBLAS Project
3+
All rights reserved.
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Redistributions in binary form must reproduce the above copyright
10+
notice, this list of conditions and the following disclaimer in
11+
the documentation and/or other materials provided with the
12+
distribution.
13+
3. Neither the name of the OpenBLAS project nor the names of
14+
its contributors may be used to endorse or promote products
15+
derived from this software without specific prior written permission.
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
ARE DISCLAIMED. IN NO EVENT SHALL THE OPENBLAS PROJECT OR CONTRIBUTORS BE
20+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25+
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
*****************************************************************************/
27+
28+
#include <stdio.h>
29+
#include <stdlib.h>
30+
#ifdef __CYGWIN32__
31+
#include <sys/time.h>
32+
#endif
33+
#include "common.h"
34+
35+
36+
#undef HER2
37+
38+
39+
#ifdef DOUBLE
40+
#define HER2 BLASFUNC(zher2)
41+
#else
42+
#define HER2 BLASFUNC(cher2)
43+
#endif
44+
45+
46+
#if defined(__WIN32__) || defined(__WIN64__)
47+
48+
#ifndef DELTA_EPOCH_IN_MICROSECS
49+
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
50+
#endif
51+
52+
int gettimeofday(struct timeval *tv, void *tz){
53+
54+
FILETIME ft;
55+
unsigned __int64 tmpres = 0;
56+
static int tzflag;
57+
58+
if (NULL != tv)
59+
{
60+
GetSystemTimeAsFileTime(&ft);
61+
62+
tmpres |= ft.dwHighDateTime;
63+
tmpres <<= 32;
64+
tmpres |= ft.dwLowDateTime;
65+
66+
/*converting file time to unix epoch*/
67+
tmpres /= 10; /*convert into microseconds*/
68+
tmpres -= DELTA_EPOCH_IN_MICROSECS;
69+
tv->tv_sec = (long)(tmpres / 1000000UL);
70+
tv->tv_usec = (long)(tmpres % 1000000UL);
71+
}
72+
73+
return 0;
74+
}
75+
76+
#endif
77+
78+
#if !defined(__WIN32__) && !defined(__WIN64__) && !defined(__CYGWIN32__) && 0
79+
80+
static void *huge_malloc(BLASLONG size){
81+
int shmid;
82+
void *address;
83+
84+
#ifndef SHM_HUGETLB
85+
#define SHM_HUGETLB 04000
86+
#endif
87+
88+
if ((shmid =shmget(IPC_PRIVATE,
89+
(size + HUGE_PAGESIZE) & ~(HUGE_PAGESIZE - 1),
90+
SHM_HUGETLB | IPC_CREAT |0600)) < 0) {
91+
printf( "Memory allocation failed(shmget).\n");
92+
exit(1);
93+
}
94+
95+
address = shmat(shmid, NULL, SHM_RND);
96+
97+
if ((BLASLONG)address == -1){
98+
printf( "Memory allocation failed(shmat).\n");
99+
exit(1);
100+
}
101+
102+
shmctl(shmid, IPC_RMID, 0);
103+
104+
return address;
105+
}
106+
107+
#define malloc huge_malloc
108+
109+
#endif
110+
111+
int main(int argc, char *argv[]){
112+
113+
FLOAT *a, *x, *y;
114+
FLOAT alpha[] = {1.0, 1.0};
115+
blasint inc = 1;
116+
char *p;
117+
118+
char uplo='U';
119+
char trans='N';
120+
121+
if ((p = getenv("OPENBLAS_UPLO"))) uplo=*p;
122+
if ((p = getenv("OPENBLAS_TRANS"))) trans=*p;
123+
124+
blasint m, i, j;
125+
126+
int from = 1;
127+
int to = 200;
128+
int step = 1;
129+
130+
struct timeval start, stop;
131+
double time1;
132+
133+
argc--;argv++;
134+
135+
if (argc > 0) { from = atol(*argv); argc--; argv++;}
136+
if (argc > 0) { to = MAX(atol(*argv), from); argc--; argv++;}
137+
if (argc > 0) { step = atol(*argv); argc--; argv++;}
138+
139+
fprintf(stderr, "From : %3d To : %3d Step = %3d Uplo = %c Trans = %c\n", from, to, step,uplo,trans);
140+
141+
142+
if (( a = (FLOAT *)malloc(sizeof(FLOAT) * to * to * COMPSIZE)) == NULL){
143+
fprintf(stderr,"Out of Memory!!\n");exit(1);
144+
}
145+
146+
if (( x = (FLOAT *)malloc(sizeof(FLOAT) * to * COMPSIZE)) == NULL){
147+
fprintf(stderr,"Out of Memory!!\n");exit(1);
148+
}
149+
150+
if (( y = (FLOAT *)malloc(sizeof(FLOAT) * to * COMPSIZE)) == NULL){
151+
fprintf(stderr,"Out of Memory!!\n");exit(1);
152+
}
153+
154+
#ifdef linux
155+
srandom(getpid());
156+
#endif
157+
158+
fprintf(stderr, " SIZE Flops\n");
159+
160+
for(m = from; m <= to; m += step)
161+
{
162+
fprintf(stderr, " %6d : ", (int)m);
163+
164+
for(j = 0; j < m; j++){
165+
for(i = 0; i < m * COMPSIZE; i++){
166+
a[(long)i + (long)j * (long)m * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
167+
}
168+
x[ (long)j * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
169+
y[ (long)j * COMPSIZE] = ((FLOAT) rand() / (FLOAT) RAND_MAX) - 0.5;
170+
}
171+
172+
gettimeofday( &start, (struct timezone *)0);
173+
174+
175+
HER2 (&uplo, &m, alpha, x, &inc, y, &inc, a, &m );
176+
177+
gettimeofday( &stop, (struct timezone *)0);
178+
179+
time1 = (double)(stop.tv_sec - start.tv_sec) + (double)((stop.tv_usec - start.tv_usec)) * 1.e-6;
180+
181+
gettimeofday( &start, (struct timezone *)0);
182+
183+
fprintf(stderr,
184+
" %10.2f MFlops\n",
185+
COMPSIZE * COMPSIZE * 2. * (double)m * (double)m / time1 * 1.e-6);
186+
187+
}
188+
189+
return 0;
190+
}

0 commit comments

Comments
 (0)