root / src / blas / HPL_dswap.c @ 9
Historique | Voir | Annoter | Télécharger (6,53 ko)
1 |
/*
|
---|---|
2 |
* -- High Performance Computing Linpack Benchmark (HPL)
|
3 |
* HPL - 2.0 - September 10, 2008
|
4 |
* Antoine P. Petitet
|
5 |
* University of Tennessee, Knoxville
|
6 |
* Innovative Computing Laboratory
|
7 |
* (C) Copyright 2000-2008 All Rights Reserved
|
8 |
*
|
9 |
* -- Copyright notice and Licensing terms:
|
10 |
*
|
11 |
* Redistribution and use in source and binary forms, with or without
|
12 |
* modification, are permitted provided that the following conditions
|
13 |
* are met:
|
14 |
*
|
15 |
* 1. Redistributions of source code must retain the above copyright
|
16 |
* notice, this list of conditions and the following disclaimer.
|
17 |
*
|
18 |
* 2. Redistributions in binary form must reproduce the above copyright
|
19 |
* notice, this list of conditions, and the following disclaimer in the
|
20 |
* documentation and/or other materials provided with the distribution.
|
21 |
*
|
22 |
* 3. All advertising materials mentioning features or use of this
|
23 |
* software must display the following acknowledgement:
|
24 |
* This product includes software developed at the University of
|
25 |
* Tennessee, Knoxville, Innovative Computing Laboratory.
|
26 |
*
|
27 |
* 4. The name of the University, the name of the Laboratory, or the
|
28 |
* names of its contributors may not be used to endorse or promote
|
29 |
* products derived from this software without specific written
|
30 |
* permission.
|
31 |
*
|
32 |
* -- Disclaimer:
|
33 |
*
|
34 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
35 |
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
36 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
37 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY
|
38 |
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
39 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
40 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
41 |
* DATA OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
42 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
43 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
44 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
45 |
* ---------------------------------------------------------------------
|
46 |
*/
|
47 |
/*
|
48 |
* Include files
|
49 |
*/
|
50 |
#include "hpl.h" |
51 |
|
52 |
#ifndef HPL_dswap
|
53 |
|
54 |
#ifdef STDC_HEADERS
|
55 |
void HPL_dswap
|
56 |
( |
57 |
const int N, |
58 |
double * X,
|
59 |
const int INCX, |
60 |
double * Y,
|
61 |
const int INCY |
62 |
) |
63 |
#else
|
64 |
void HPL_dswap
|
65 |
( N, X, INCX, Y, INCY ) |
66 |
const int N; |
67 |
double * X;
|
68 |
const int INCX; |
69 |
double * Y;
|
70 |
const int INCY; |
71 |
#endif
|
72 |
{ |
73 |
/*
|
74 |
* Purpose
|
75 |
* =======
|
76 |
*
|
77 |
* HPL_dswap swaps the vectors x and y.
|
78 |
*
|
79 |
*
|
80 |
* Arguments
|
81 |
* =========
|
82 |
*
|
83 |
* N (local input) const int
|
84 |
* On entry, N specifies the length of the vectors x and y. N
|
85 |
* must be at least zero.
|
86 |
*
|
87 |
* X (local input/output) double *
|
88 |
* On entry, X is an incremented array of dimension at least
|
89 |
* ( 1 + ( n - 1 ) * abs( INCX ) ) that contains the vector x.
|
90 |
* On exit, the entries of the incremented array X are updated
|
91 |
* with the entries of the incremented array Y.
|
92 |
*
|
93 |
* INCX (local input) const int
|
94 |
* On entry, INCX specifies the increment for the elements of X.
|
95 |
* INCX must not be zero.
|
96 |
*
|
97 |
* Y (local input/output) double *
|
98 |
* On entry, Y is an incremented array of dimension at least
|
99 |
* ( 1 + ( n - 1 ) * abs( INCY ) ) that contains the vector y.
|
100 |
* On exit, the entries of the incremented array Y are updated
|
101 |
* with the entries of the incremented array X.
|
102 |
*
|
103 |
* INCY (local input) const int
|
104 |
* On entry, INCY specifies the increment for the elements of Y.
|
105 |
* INCY must not be zero.
|
106 |
*
|
107 |
* ---------------------------------------------------------------------
|
108 |
*/
|
109 |
#ifdef HPL_CALL_CBLAS
|
110 |
cblas_dswap( N, X, INCX, Y, INCY ); |
111 |
#endif
|
112 |
#ifdef HPL_CALL_VSIPL
|
113 |
register double x0, x1, x2, x3, y0, y1, y2, y3; |
114 |
double * StX;
|
115 |
register int i; |
116 |
int nu;
|
117 |
const int incX2 = 2 * INCX, incY2 = 2 * INCY, |
118 |
incX3 = 3 * INCX, incY3 = 3 * INCY, |
119 |
incX4 = 4 * INCX, incY4 = 4 * INCY; |
120 |
|
121 |
if( N > 0 ) |
122 |
{ |
123 |
if( ( nu = ( N >> 2 ) << 2 ) != 0 ) |
124 |
{ |
125 |
StX = X + nu * INCX; |
126 |
|
127 |
do
|
128 |
{ |
129 |
x0 = (*X); y0 = (*Y); x1 = X[INCX ]; y1 = Y[INCY ]; |
130 |
x2 = X[incX2]; y2 = Y[incY2]; x3 = X[incX3]; y3 = Y[incY3]; |
131 |
*Y = x0; *X = y0; Y[INCY ] = x1; X[INCX ] = y1; |
132 |
Y[incY2] = x2; X[incX2] = y2; Y[incY3] = x3; X[incX3] = y3; |
133 |
X += incX4; Y += incY4; |
134 |
|
135 |
} while( X != StX );
|
136 |
} |
137 |
|
138 |
for( i = N - nu; i != 0; i-- ) |
139 |
{ x0 = (*X); y0 = (*Y); *Y = x0; *X = y0; X += INCX; Y += INCY; } |
140 |
} |
141 |
#endif
|
142 |
#ifdef HPL_CALL_FBLAS
|
143 |
#ifdef HPL_USE_F77_INTEGER_DEF
|
144 |
const F77_INTEGER F77N = N, F77incx = INCX, F77incy = INCY;
|
145 |
#else
|
146 |
#define F77N N
|
147 |
#define F77incx INCX
|
148 |
#define F77incy INCY
|
149 |
#endif
|
150 |
F77dswap( &F77N, X, &F77incx, Y, &F77incy ); |
151 |
#endif
|
152 |
|
153 |
#ifdef HPL_CALL_CUBLAS
|
154 |
#define CUBLASN N
|
155 |
#define CUBLASincx INCX
|
156 |
#define CUBLASincy INCY
|
157 |
CUBLAS_DSWAP( &CUBLASN, X, &CUBLASincx, Y, &CUBLASincy ); |
158 |
#endif
|
159 |
|
160 |
/*
|
161 |
* End of HPL_dswap
|
162 |
*/
|
163 |
} |
164 |
|
165 |
#endif
|