Skip to content

Commit 79cfc24

Browse files
authored
Add interface for ?sum (derived from ?asum)
1 parent 5c42287 commit 79cfc24

File tree

3 files changed

+143
-13
lines changed

3 files changed

+143
-13
lines changed

interface/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ set(BLAS1_REAL_ONLY_SOURCES
1212
rotm.c rotmg.c # N.B. these do not have complex counterparts
1313
rot.c
1414
asum.c
15+
sum.c
1516
)
1617

1718
# these will have 'z' prepended for the complex version
@@ -124,6 +125,7 @@ foreach (float_type ${FLOAT_TYPES})
124125
GenerateNamedObjects("max.c" "USE_ABS;USE_MIN" "scamin" ${CBLAS_FLAG} "" "" true "COMPLEX")
125126
GenerateNamedObjects("max.c" "USE_ABS" "scamax" ${CBLAS_FLAG} "" "" true "COMPLEX")
126127
GenerateNamedObjects("asum.c" "" "scasum" ${CBLAS_FLAG} "" "" true "COMPLEX")
128+
GenerateNamedObjects("sum.c" "" "scsum" ${CBLAS_FLAG} "" "" true "COMPLEX")
127129
endif ()
128130
if (${float_type} STREQUAL "ZCOMPLEX")
129131
GenerateNamedObjects("zscal.c" "SSCAL" "dscal" ${CBLAS_FLAG} "" "" false "ZCOMPLEX")
@@ -132,6 +134,7 @@ foreach (float_type ${FLOAT_TYPES})
132134
GenerateNamedObjects("max.c" "USE_ABS;USE_MIN" "dzamin" ${CBLAS_FLAG} "" "" true "ZCOMPLEX")
133135
GenerateNamedObjects("max.c" "USE_ABS" "dzamax" ${CBLAS_FLAG} "" "" true "ZCOMPLEX")
134136
GenerateNamedObjects("asum.c" "" "dzasum" ${CBLAS_FLAG} "" "" true "ZCOMPLEX")
137+
GenerateNamedObjects("sum.c" "" "dzsum" ${CBLAS_FLAG} "" "" true "ZCOMPLEX")
135138
endif ()
136139
endforeach ()
137140

interface/Makefile

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SBLAS1OBJS = \
2525
saxpy.$(SUFFIX) sswap.$(SUFFIX) \
2626
scopy.$(SUFFIX) sscal.$(SUFFIX) \
2727
sdot.$(SUFFIX) sdsdot.$(SUFFIX) dsdot.$(SUFFIX) \
28-
sasum.$(SUFFIX) snrm2.$(SUFFIX) \
28+
sasum.$(SUFFIX) ssum.$(SUFFIX) snrm2.$(SUFFIX) \
2929
smax.$(SUFFIX) samax.$(SUFFIX) ismax.$(SUFFIX) isamax.$(SUFFIX) \
3030
smin.$(SUFFIX) samin.$(SUFFIX) ismin.$(SUFFIX) isamin.$(SUFFIX) \
3131
srot.$(SUFFIX) srotg.$(SUFFIX) srotm.$(SUFFIX) srotmg.$(SUFFIX) \
@@ -51,7 +51,7 @@ DBLAS1OBJS = \
5151
daxpy.$(SUFFIX) dswap.$(SUFFIX) \
5252
dcopy.$(SUFFIX) dscal.$(SUFFIX) \
5353
ddot.$(SUFFIX) \
54-
dasum.$(SUFFIX) dnrm2.$(SUFFIX) \
54+
dasum.$(SUFFIX) dsum.$(SUFFIX) dnrm2.$(SUFFIX) \
5555
dmax.$(SUFFIX) damax.$(SUFFIX) idmax.$(SUFFIX) idamax.$(SUFFIX) \
5656
dmin.$(SUFFIX) damin.$(SUFFIX) idmin.$(SUFFIX) idamin.$(SUFFIX) \
5757
drot.$(SUFFIX) drotg.$(SUFFIX) drotm.$(SUFFIX) drotmg.$(SUFFIX) \
@@ -76,7 +76,7 @@ CBLAS1OBJS = \
7676
caxpy.$(SUFFIX) caxpyc.$(SUFFIX) cswap.$(SUFFIX) \
7777
ccopy.$(SUFFIX) cscal.$(SUFFIX) csscal.$(SUFFIX) \
7878
cdotc.$(SUFFIX) cdotu.$(SUFFIX) \
79-
scasum.$(SUFFIX) scnrm2.$(SUFFIX) \
79+
scasum.$(SUFFIX) scsum.$(SUFFIX) scnrm2.$(SUFFIX) \
8080
scamax.$(SUFFIX) icamax.$(SUFFIX) \
8181
scamin.$(SUFFIX) icamin.$(SUFFIX) \
8282
csrot.$(SUFFIX) crotg.$(SUFFIX) \
@@ -105,7 +105,7 @@ ZBLAS1OBJS = \
105105
zaxpy.$(SUFFIX) zaxpyc.$(SUFFIX) zswap.$(SUFFIX) \
106106
zcopy.$(SUFFIX) zscal.$(SUFFIX) zdscal.$(SUFFIX) \
107107
zdotc.$(SUFFIX) zdotu.$(SUFFIX) \
108-
dzasum.$(SUFFIX) dznrm2.$(SUFFIX) \
108+
dzasum.$(SUFFIX) dzsum.$(SUFFIX) dznrm2.$(SUFFIX) \
109109
dzamax.$(SUFFIX) izamax.$(SUFFIX) \
110110
dzamin.$(SUFFIX) izamin.$(SUFFIX) \
111111
zdrot.$(SUFFIX) zrotg.$(SUFFIX) \
@@ -146,7 +146,7 @@ QBLAS1OBJS = \
146146
qaxpy.$(SUFFIX) qswap.$(SUFFIX) \
147147
qcopy.$(SUFFIX) qscal.$(SUFFIX) \
148148
qdot.$(SUFFIX) \
149-
qasum.$(SUFFIX) qnrm2.$(SUFFIX) \
149+
qasum.$(SUFFIX) qsum.$(SUFFIX) qnrm2.$(SUFFIX) \
150150
qmax.$(SUFFIX) qamax.$(SUFFIX) iqmax.$(SUFFIX) iqamax.$(SUFFIX) \
151151
qmin.$(SUFFIX) qamin.$(SUFFIX) iqmin.$(SUFFIX) iqamin.$(SUFFIX) \
152152
qrot.$(SUFFIX) qrotg.$(SUFFIX) qrotm.$(SUFFIX) qrotmg.$(SUFFIX) \
@@ -168,7 +168,7 @@ XBLAS1OBJS = \
168168
xaxpy.$(SUFFIX) xaxpyc.$(SUFFIX) xswap.$(SUFFIX) \
169169
xcopy.$(SUFFIX) xscal.$(SUFFIX) xqscal.$(SUFFIX) \
170170
xdotc.$(SUFFIX) xdotu.$(SUFFIX) \
171-
qxasum.$(SUFFIX) qxnrm2.$(SUFFIX) \
171+
qxasum.$(SUFFIX) qxsum.$(SUFFIX) qxnrm2.$(SUFFIX) \
172172
qxamax.$(SUFFIX) ixamax.$(SUFFIX) \
173173
qxamin.$(SUFFIX) ixamin.$(SUFFIX) \
174174
xqrot.$(SUFFIX) xrotg.$(SUFFIX) \
@@ -203,7 +203,7 @@ ifdef QUAD_PRECISION
203203
QBLAS1OBJS = \
204204
qaxpy.$(SUFFIX) qswap.$(SUFFIX) \
205205
qcopy.$(SUFFIX) qscal.$(SUFFIX) \
206-
qasum.$(SUFFIX) qnrm2.$(SUFFIX) \
206+
qasum.$(SUFFIX) qsum.$(SUFFIX) qnrm2.$(SUFFIX) \
207207
qmax.$(SUFFIX) qamax.$(SUFFIX) iqmax.$(SUFFIX) iqamax.$(SUFFIX) \
208208
qmin.$(SUFFIX) qamin.$(SUFFIX) iqmin.$(SUFFIX) iqamin.$(SUFFIX) \
209209
qrot.$(SUFFIX) qrotg.$(SUFFIX) qrotm.$(SUFFIX) qrotmg.$(SUFFIX) \
@@ -224,7 +224,7 @@ QBLAS3OBJS = \
224224
XBLAS1OBJS = \
225225
xaxpy.$(SUFFIX) xaxpyc.$(SUFFIX) xswap.$(SUFFIX) \
226226
xcopy.$(SUFFIX) xscal.$(SUFFIX) xqscal.$(SUFFIX) \
227-
qxasum.$(SUFFIX) qxnrm2.$(SUFFIX) \
227+
qxasum.$(SUFFIX) qxsum.$(SUFFIX) qxnrm2.$(SUFFIX) \
228228
qxamax.$(SUFFIX) ixamax.$(SUFFIX) \
229229
qxamin.$(SUFFIX) ixamin.$(SUFFIX) \
230230
xqrot.$(SUFFIX) xrotg.$(SUFFIX) \
@@ -264,7 +264,7 @@ CSBLAS1OBJS = \
264264
cblas_scopy.$(SUFFIX) cblas_sdot.$(SUFFIX) cblas_sdsdot.$(SUFFIX) cblas_dsdot.$(SUFFIX) \
265265
cblas_srot.$(SUFFIX) cblas_srotg.$(SUFFIX) cblas_srotm.$(SUFFIX) cblas_srotmg.$(SUFFIX) \
266266
cblas_sscal.$(SUFFIX) cblas_sswap.$(SUFFIX) cblas_snrm2.$(SUFFIX) cblas_saxpby.$(SUFFIX) \
267-
cblas_ismin.$(SUFFIX) cblas_ismax.$(SUFFIX)
267+
cblas_ismin.$(SUFFIX) cblas_ismax.$(SUFFIX) cblas_ssum.$(SUFFIX)
268268

269269
CSBLAS2OBJS = \
270270
cblas_sgemv.$(SUFFIX) cblas_sger.$(SUFFIX) cblas_ssymv.$(SUFFIX) cblas_strmv.$(SUFFIX) \
@@ -282,7 +282,7 @@ CDBLAS1OBJS = \
282282
cblas_dcopy.$(SUFFIX) cblas_ddot.$(SUFFIX) \
283283
cblas_drot.$(SUFFIX) cblas_drotg.$(SUFFIX) cblas_drotm.$(SUFFIX) cblas_drotmg.$(SUFFIX) \
284284
cblas_dscal.$(SUFFIX) cblas_dswap.$(SUFFIX) cblas_dnrm2.$(SUFFIX) cblas_daxpby.$(SUFFIX) \
285-
cblas_idmin.$(SUFFIX) cblas_idmax.$(SUFFIX)
285+
cblas_idmin.$(SUFFIX) cblas_idmax.$(SUFFIX) cblas_dsum.$(SUFFIX)
286286

287287
CDBLAS2OBJS = \
288288
cblas_dgemv.$(SUFFIX) cblas_dger.$(SUFFIX) cblas_dsymv.$(SUFFIX) cblas_dtrmv.$(SUFFIX) \
@@ -303,7 +303,7 @@ CCBLAS1OBJS = \
303303
cblas_cscal.$(SUFFIX) cblas_csscal.$(SUFFIX) \
304304
cblas_cswap.$(SUFFIX) cblas_scnrm2.$(SUFFIX) \
305305
cblas_caxpby.$(SUFFIX) \
306-
cblas_icmin.$(SUFFIX) cblas_icmax.$(SUFFIX)
306+
cblas_icmin.$(SUFFIX) cblas_icmax.$(SUFFIX) cblas_scsum.$(SUFFIX)
307307

308308
CCBLAS2OBJS = \
309309
cblas_cgemv.$(SUFFIX) cblas_cgerc.$(SUFFIX) cblas_cgeru.$(SUFFIX) \
@@ -330,7 +330,7 @@ CZBLAS1OBJS = \
330330
cblas_zscal.$(SUFFIX) cblas_zdscal.$(SUFFIX) \
331331
cblas_zswap.$(SUFFIX) cblas_dznrm2.$(SUFFIX) \
332332
cblas_zaxpby.$(SUFFIX) \
333-
cblas_izmin.$(SUFFIX) cblas_izmax.$(SUFFIX)
333+
cblas_izmin.$(SUFFIX) cblas_izmax.$(SUFFIX) cblas_dzsum.$(SUFFIX)
334334

335335

336336
CZBLAS2OBJS = \
@@ -565,6 +565,24 @@ dzasum.$(SUFFIX) dzasum.$(PSUFFIX) : asum.c
565565
qxasum.$(SUFFIX) qxasum.$(PSUFFIX) : asum.c
566566
$(CC) $(CFLAGS) -c $< -o $(@F)
567567

568+
ssum.$(SUFFIX) ssum.$(PSUFFIX) : sum.c
569+
$(CC) $(CFLAGS) -c $< -o $(@F)
570+
571+
dsum.$(SUFFIX) dsum.$(PSUFFIX) : sum.c
572+
$(CC) $(CFLAGS) -c $< -o $(@F)
573+
574+
qsum.$(SUFFIX) qsum.$(PSUFFIX) : sum.c
575+
$(CC) $(CFLAGS) -c $< -o $(@F)
576+
577+
scsum.$(SUFFIX) scsum.$(PSUFFIX) : sum.c
578+
$(CC) $(CFLAGS) -c $< -o $(@F)
579+
580+
dzsum.$(SUFFIX) dzsum.$(PSUFFIX) : sum.c
581+
$(CC) $(CFLAGS) -c $< -o $(@F)
582+
583+
qxsum.$(SUFFIX) qxsum.$(PSUFFIX) : sum.c
584+
$(CC) $(CFLAGS) -c $< -o $(@F)
585+
568586
snrm2.$(SUFFIX) snrm2.$(PSUFFIX) : nrm2.c
569587
$(CC) $(CFLAGS) -c $< -o $(@F)
570588

@@ -1412,14 +1430,26 @@ cblas_scasum.$(SUFFIX) cblas_scasum.$(PSUFFIX) : asum.c
14121430
cblas_dzasum.$(SUFFIX) cblas_dzasum.$(PSUFFIX) : asum.c
14131431
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
14141432

1433+
cblas_ssum.$(SUFFIX) cblas_ssum.$(PSUFFIX) : sum.c
1434+
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
1435+
1436+
cblas_dsum.$(SUFFIX) cblas_dsum.$(PSUFFIX) : sum.c
1437+
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
1438+
1439+
cblas_scsum.$(SUFFIX) cblas_scsum.$(PSUFFIX) : sum.c
1440+
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
1441+
1442+
cblas_dzsum.$(SUFFIX) cblas_dzsum.$(PSUFFIX) : sum.c
1443+
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
1444+
14151445
cblas_sdsdot.$(SUFFIX) cblas_sdsdot.$(PSUFFIX) : sdsdot.c
14161446
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
14171447

14181448
cblas_dsdot.$(SUFFIX) cblas_dsdot.$(PSUFFIX) : dsdot.c
14191449
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
14201450

14211451
cblas_sdot.$(SUFFIX) cblas_sdot.$(PSUFFIX) : dot.c
1422-
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
1452+
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)
14231453

14241454
cblas_ddot.$(SUFFIX) cblas_ddot.$(PSUFFIX) : dot.c
14251455
$(CC) $(CFLAGS) -DCBLAS -c $< -o $(@F)

interface/sum.c

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*********************************************************************/
2+
/* Copyright 2009, 2010 The University of Texas at Austin. */
3+
/* All rights reserved. */
4+
/* */
5+
/* Redistribution and use in source and binary forms, with or */
6+
/* without modification, are permitted provided that the following */
7+
/* conditions are met: */
8+
/* */
9+
/* 1. Redistributions of source code must retain the above */
10+
/* copyright notice, this list of conditions and the following */
11+
/* disclaimer. */
12+
/* */
13+
/* 2. Redistributions in binary form must reproduce the above */
14+
/* copyright notice, this list of conditions and the following */
15+
/* disclaimer in the documentation and/or other materials */
16+
/* provided with the distribution. */
17+
/* */
18+
/* THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY OF TEXAS AT */
19+
/* AUSTIN ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, */
20+
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
21+
/* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22+
/* DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT */
23+
/* AUSTIN OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, */
24+
/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
25+
/* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE */
26+
/* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR */
27+
/* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
28+
/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
29+
/* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT */
30+
/* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE */
31+
/* POSSIBILITY OF SUCH DAMAGE. */
32+
/* */
33+
/* The views and conclusions contained in the software and */
34+
/* documentation are those of the authors and should not be */
35+
/* interpreted as representing official policies, either expressed */
36+
/* or implied, of The University of Texas at Austin. */
37+
/*********************************************************************/
38+
39+
#include <stdio.h>
40+
#include "common.h"
41+
#ifdef FUNCTION_PROFILE
42+
#include "functable.h"
43+
#endif
44+
45+
#ifndef CBLAS
46+
47+
FLOATRET NAME(blasint *N, FLOAT *x, blasint *INCX){
48+
49+
BLASLONG n = *N;
50+
BLASLONG incx = *INCX;
51+
FLOATRET ret;
52+
53+
PRINT_DEBUG_NAME;
54+
55+
if (n <= 0) return 0;
56+
57+
IDEBUG_START;
58+
59+
FUNCTION_PROFILE_START();
60+
61+
ret = (FLOATRET)SUM_K(n, x, incx);
62+
63+
FUNCTION_PROFILE_END(COMPSIZE, n, n);
64+
65+
IDEBUG_END;
66+
67+
return ret;
68+
}
69+
70+
#else
71+
#ifdef COMPLEX
72+
FLOAT CNAME(blasint n, void *vx, blasint incx){
73+
FLOAT *x = (FLOAT*) vx;
74+
#else
75+
FLOAT CNAME(blasint n, FLOAT *x, blasint incx){
76+
#endif
77+
78+
FLOAT ret;
79+
80+
PRINT_DEBUG_CNAME;
81+
82+
if (n <= 0) return 0;
83+
84+
IDEBUG_START;
85+
86+
FUNCTION_PROFILE_START();
87+
88+
ret = SUM_K(n, x, incx);
89+
90+
FUNCTION_PROFILE_END(COMPSIZE, n, n);
91+
92+
IDEBUG_END;
93+
94+
return ret;
95+
}
96+
97+
#endif

0 commit comments

Comments
 (0)