hpl_blas.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  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. #ifndef HPL_BLAS_H
  47. #define HPL_BLAS_H
  48. /*
  49. * ---------------------------------------------------------------------
  50. * Include files
  51. * ---------------------------------------------------------------------
  52. */
  53. #include "hpl_misc.h"
  54. #include "mkl_blas.h"
  55. /*
  56. * ---------------------------------------------------------------------
  57. * typedef definitions
  58. * ---------------------------------------------------------------------
  59. */
  60. enum HPL_ORDER
  61. { HplRowMajor = 101, HplColumnMajor = 102 };
  62. enum HPL_TRANS
  63. { HplNoTrans = 111, HplTrans = 112, HplConjTrans = 113 };
  64. enum HPL_UPLO
  65. { HplUpper = 121, HplLower = 122 };
  66. enum HPL_DIAG
  67. { HplNonUnit = 131, HplUnit = 132 };
  68. enum HPL_SIDE
  69. { HplLeft = 141, HplRight = 142 };
  70. #ifdef HPL_CALL_CBLAS
  71. /*
  72. * ---------------------------------------------------------------------
  73. * The C interface of the BLAS is available ...
  74. * ---------------------------------------------------------------------
  75. * #define macro constants
  76. * ---------------------------------------------------------------------
  77. */
  78. #define CBLAS_INDEX int
  79. #define CBLAS_ORDER HPL_ORDER
  80. #define CblasRowMajor HplRowMajor
  81. #define CblasColMajor HplColMajor
  82. #define CBLAS_TRANSPOSE HPL_TRANS
  83. #define CblasNoTrans HplNoTrans
  84. #define CblasTrans HplTrans
  85. #define CblasConjTrans HplConjTrans
  86. #define CBLAS_UPLO HPL_UPLO
  87. #define CblasUpper HplUpper
  88. #define CblasLower HplLower
  89. #define CBLAS_DIAG HPL_DIAG
  90. #define CblasNonUnit HplNonUnit
  91. #define CblasUnit HplUnit
  92. #define CBLAS_SIDE HPL_SIDE
  93. #define CblasLeft HplLeft
  94. #define CblasRight HplRight
  95. /*
  96. * ---------------------------------------------------------------------
  97. * CBLAS Function prototypes
  98. * ---------------------------------------------------------------------
  99. */
  100. CBLAS_INDEX cblas_idamax
  101. STDC_ARGS(
  102. ( const int, const double *, const int ) );
  103. void cblas_dswap
  104. STDC_ARGS(
  105. ( const int, double *, const int, double *,
  106. const int ) );
  107. void cblas_dcopy
  108. STDC_ARGS(
  109. ( const int, const double *, const int, double *,
  110. const int ) );
  111. void cblas_daxpy
  112. STDC_ARGS(
  113. ( const int, const double, const double *, const int,
  114. double *, const int ) );
  115. void cblas_dscal
  116. STDC_ARGS(
  117. ( const int, const double, double *, const int ) );
  118. void cblas_dgemv
  119. STDC_ARGS(
  120. ( const enum CBLAS_ORDER, const enum CBLAS_TRANSPOSE,
  121. const int, const int, const double, const double *,
  122. const int, const double *, const int, const double,
  123. double *, const int ) );
  124. void cblas_dger
  125. STDC_ARGS(
  126. ( const enum CBLAS_ORDER, const int, const int,
  127. const double, const double *, const int, const double *,
  128. const int, double *, const int ) );
  129. void cblas_dtrsv
  130. STDC_ARGS(
  131. ( const enum CBLAS_ORDER, const enum CBLAS_UPLO,
  132. const enum CBLAS_TRANSPOSE, const enum CBLAS_DIAG,
  133. const int, const double *, const int, double *,
  134. const int ) );
  135. void cblas_dgemm
  136. STDC_ARGS(
  137. ( const enum CBLAS_ORDER, const enum CBLAS_TRANSPOSE,
  138. const enum CBLAS_TRANSPOSE, const int, const int,
  139. const int, const double, const double *, const int,
  140. const double *, const int, const double, double *,
  141. const int ) );
  142. void cblas_dtrsm
  143. STDC_ARGS(
  144. ( const enum CBLAS_ORDER, const enum CBLAS_SIDE,
  145. const enum CBLAS_UPLO, const enum CBLAS_TRANSPOSE,
  146. const enum CBLAS_DIAG, const int, const int,
  147. const double, const double *, const int, double *,
  148. const int ) );
  149. /*
  150. * ---------------------------------------------------------------------
  151. * HPL C BLAS macro definition
  152. * ---------------------------------------------------------------------
  153. */
  154. #define HPL_dswap cblas_dswap
  155. #define HPL_dcopy cblas_dcopy
  156. #define HPL_daxpy cblas_daxpy
  157. #define HPL_dscal cblas_dscal
  158. #define HPL_idamax cblas_idamax
  159. #define HPL_dgemv cblas_dgemv
  160. #define HPL_dtrsv cblas_dtrsv
  161. #define HPL_dger cblas_dger
  162. #define HPL_dgemm cblas_dgemm
  163. #define HPL_dtrsm cblas_dtrsm
  164. #endif
  165. #ifdef HPL_CALL_FBLAS
  166. /*
  167. * ---------------------------------------------------------------------
  168. * Use the Fortran 77 interface of the BLAS ...
  169. * ---------------------------------------------------------------------
  170. * Defaults: Add_, F77_INTEGER=int, StringSunStyle
  171. * ---------------------------------------------------------------------
  172. */
  173. #ifndef NoChange
  174. #ifndef UpCase
  175. #ifndef Add__
  176. #ifndef Add_
  177. #define Add_
  178. #endif
  179. #endif
  180. #endif
  181. #endif
  182. #ifndef F77_INTEGER
  183. #define F77_INTEGER int
  184. #else
  185. #define HPL_USE_F77_INTEGER_DEF
  186. #endif
  187. #ifndef StringCrayStyle
  188. #ifndef StringStructVal
  189. #ifndef StringStructPtr
  190. #ifndef StringSunStyle
  191. #define StringSunStyle
  192. #endif
  193. #endif
  194. #endif
  195. #endif
  196. /*
  197. * ---------------------------------------------------------------------
  198. * Fortran 77 <-> C interface
  199. * ---------------------------------------------------------------------
  200. *
  201. * These macros identifies how Fortran routines will be called.
  202. *
  203. * Add_ : the Fortran compiler expects the name of C functions to be
  204. * in all lower case and to have an underscore postfixed it (Suns, Intel
  205. * compilers expect this).
  206. *
  207. * NoChange : the Fortran compiler expects the name of C functions to be
  208. * in all lower case (IBM RS6K compilers do this).
  209. *
  210. * UpCase : the Fortran compiler expects the name of C functions to be
  211. * in all upcase. (Cray compilers expect this).
  212. *
  213. * Add__ : the Fortran compiler in use is f2c, a Fortran to C conver-
  214. * ter.
  215. */
  216. #ifdef NoChange
  217. /*
  218. * These defines set up the naming scheme required to have a FORTRAN
  219. * routine called by a C routine with the following FORTRAN to C inter-
  220. * face:
  221. *
  222. * FORTRAN DECLARATION C CALL
  223. * SUBROUTINE DGEMM(...) dgemm(...)
  224. */
  225. #define F77dswap dswap
  226. #define F77dscal dscal
  227. #define F77dcopy dcopy
  228. #define F77daxpy daxpy
  229. #define F77idamax idamax
  230. #define F77dgemv dgemv
  231. #define F77dtrsv dtrsv
  232. #define F77dger dger
  233. #define F77dgemm dgemm
  234. #define F77dtrsm dtrsm
  235. #endif
  236. #ifdef UpCase
  237. /*
  238. * These defines set up the naming scheme required to have a FORTRAN
  239. * routine called by a C routine with the following FORTRAN to C inter-
  240. * face:
  241. *
  242. * FORTRAN DECLARATION C CALL
  243. * SUBROUTINE DGEMM(...) DGEMM(...)
  244. */
  245. #ifdef CRAY_BLAS
  246. #define F77dswap SSWAP
  247. #define F77dscal SSCAL
  248. #define F77dcopy SCOPY
  249. #define F77daxpy SAXPY
  250. #define F77idamax ISAMAX
  251. #define F77dgemv SGEMV
  252. #define F77dtrsv STRSV
  253. #define F77dger SGER
  254. #define F77dgemm SGEMM
  255. #define F77dtrsm STRSM
  256. #else
  257. #define F77dswap DSWAP
  258. #define F77dscal DSCAL
  259. #define F77dcopy DCOPY
  260. #define F77daxpy DAXPY
  261. #define F77idamax IDAMAX
  262. #define F77dgemv DGEMV
  263. #define F77dtrsv DTRSV
  264. #define F77dger DGER
  265. #define F77dgemm DGEMM
  266. #define F77dtrsm DTRSM
  267. #endif
  268. #endif
  269. #ifdef Add_
  270. /*
  271. * These defines set up the naming scheme required to have a FORTRAN
  272. * routine called by a C routine with the following FORTRAN to C inter-
  273. * face:
  274. *
  275. * FORTRAN DECLARATION C CALL
  276. * SUBROUTINE DGEMM(...) dgemm_(...)
  277. */
  278. #define F77dswap dswap_
  279. #define F77dscal dscal_
  280. #define F77dcopy dcopy_
  281. #define F77daxpy daxpy_
  282. #define F77idamax idamax_
  283. #define F77dgemv dgemv_
  284. #define F77dtrsv dtrsv_
  285. #define F77dger dger_
  286. #define F77dgemm dgemm_
  287. #define F77dtrsm dtrsm_
  288. #endif
  289. #ifdef Add__
  290. /*
  291. * These defines set up the naming scheme required to have a FORTRAN
  292. * routine called by a C routine with the following FORTRAN to C inter-
  293. * face:
  294. *
  295. * FORTRAN DECLARATION C CALL
  296. * SUBROUTINE DGEMM(...) dgemm_(...)
  297. */
  298. #define F77dswap dswap_
  299. #define F77dscal dscal_
  300. #define F77dcopy dcopy_
  301. #define F77daxpy daxpy_
  302. #define F77idamax idamax_
  303. #define F77dgemv dgemv_
  304. #define F77dtrsv dtrsv_
  305. #define F77dger dger_
  306. #define F77dgemm dgemm_
  307. #define F77dtrsm dtrsm_
  308. #endif
  309. /*
  310. * ---------------------------------------------------------------------
  311. * Typedef definitions and conversion utilities
  312. * ---------------------------------------------------------------------
  313. */
  314. #ifdef StringCrayStyle
  315. #include <fortran.h>
  316. /* Type of character argument in a FORTRAN call */
  317. #define F77_CHAR _fcd
  318. /* Character conversion utilities */
  319. #define HPL_F2C_CHAR(c) (*(_fcdtocp(c) ))
  320. #define HPL_C2F_CHAR(c) (_cptofcd(&(c), 1))
  321. #define F77_CHAR_DECL F77_CHAR /* input CHARACTER*1 */
  322. #endif
  323. /* ------------------------------------------------------------------ */
  324. #ifdef StringStructVal
  325. /* Type of character argument in a FORTRAN call */
  326. typedef struct { char *cp; F77_INTEGER len; } F77_CHAR;
  327. /* Character conversion utilities */
  328. #define HPL_F2C_CHAR(c) (*(c.cp))
  329. #define F77_CHAR_DECL F77_CHAR /* input CHARACTER*1 */
  330. #endif
  331. /* ------------------------------------------------------------------ */
  332. #ifdef StringStructPtr
  333. /* Type of character argument in a FORTRAN call */
  334. typedef struct { char *cp; F77_INTEGER len; } F77_CHAR;
  335. /* Character conversion utilities */
  336. #define HPL_F2C_CHAR(c) (*(c->cp))
  337. #define F77_CHAR_DECL F77_CHAR * /* input CHARACTER*1 */
  338. #endif
  339. /* ------------------------------------------------------------------ */
  340. #ifdef StringSunStyle
  341. /* Type of character argument in a FORTRAN call */
  342. #define F77_CHAR char *
  343. /* Character conversion utilities */
  344. #define HPL_F2C_CHAR(c) (*(c))
  345. #define HPL_C2F_CHAR(c) (&(c))
  346. #define F77_CHAR_DECL F77_CHAR /* input CHARACTER*1 */
  347. #define F77_1_CHAR , F77_INTEGER
  348. #define F77_2_CHAR F77_1_CHAR F77_1_CHAR
  349. #define F77_3_CHAR F77_2_CHAR F77_1_CHAR
  350. #define F77_4_CHAR F77_3_CHAR F77_1_CHAR
  351. #endif
  352. /* ------------------------------------------------------------------ */
  353. #ifndef F77_1_CHAR
  354. #define F77_1_CHAR
  355. #define F77_2_CHAR
  356. #define F77_3_CHAR
  357. #define F77_4_CHAR
  358. #endif
  359. #define F77_INT_DECL const F77_INTEGER * /* input integer */
  360. #define F77_SIN_DECL const double * /* input scalar */
  361. #define F77_VIN_DECL const double * /* input vector */
  362. #define F77_VINOUT_DECL double * /* input/output matrix */
  363. #define F77_MIN_DECL const double * /* input matrix */
  364. #define F77_MINOUT_DECL double * /* input/output matrix */
  365. #ifdef CRAY_PVP_ENV /* Type of FORTRAN functions */
  366. #define F77_VOID_FUN extern fortran void /* subroutine */
  367. #define F77_INT_FUN extern fortran int /* integer function */
  368. #else
  369. #define F77_VOID_FUN extern void /* subroutine */
  370. #define F77_INT_FUN extern int /* integer function */
  371. #endif
  372. /*
  373. * ---------------------------------------------------------------------
  374. * Fortran 77 BLAS function prototypes
  375. * ---------------------------------------------------------------------
  376. */
  377. F77_VOID_FUN F77dswap
  378. STDC_ARGS(
  379. ( F77_INT_DECL, F77_VINOUT_DECL, F77_INT_DECL, F77_VINOUT_DECL,
  380. F77_INT_DECL ) );
  381. F77_VOID_FUN F77dscal
  382. STDC_ARGS(
  383. ( F77_INT_DECL, F77_SIN_DECL, F77_VINOUT_DECL, F77_INT_DECL ) );
  384. F77_VOID_FUN F77dcopy
  385. STDC_ARGS(
  386. ( F77_INT_DECL, F77_VIN_DECL, F77_INT_DECL, F77_VINOUT_DECL,
  387. F77_INT_DECL ) );
  388. F77_VOID_FUN F77daxpy
  389. STDC_ARGS(
  390. ( F77_INT_DECL, F77_SIN_DECL, F77_VIN_DECL, F77_INT_DECL,
  391. F77_VINOUT_DECL, F77_INT_DECL ) );
  392. F77_INT_FUN F77idamax
  393. STDC_ARGS(
  394. ( F77_INT_DECL, F77_VIN_DECL, F77_INT_DECL ) );
  395. F77_VOID_FUN F77dgemv
  396. STDC_ARGS(
  397. ( F77_CHAR_DECL, F77_INT_DECL, F77_INT_DECL, F77_SIN_DECL,
  398. F77_MIN_DECL, F77_INT_DECL, F77_VIN_DECL, F77_INT_DECL,
  399. F77_SIN_DECL, F77_VINOUT_DECL, F77_INT_DECL F77_1_CHAR ) );
  400. F77_VOID_FUN F77dger
  401. STDC_ARGS(
  402. ( F77_INT_DECL, F77_INT_DECL, F77_SIN_DECL, F77_VIN_DECL,
  403. F77_INT_DECL, F77_VIN_DECL, F77_INT_DECL, F77_MINOUT_DECL,
  404. F77_INT_DECL ) );
  405. F77_VOID_FUN F77dtrsv
  406. STDC_ARGS(
  407. ( F77_CHAR_DECL, F77_CHAR_DECL, F77_CHAR_DECL, F77_INT_DECL,
  408. F77_MIN_DECL, F77_INT_DECL, F77_VINOUT_DECL, F77_INT_DECL
  409. F77_3_CHAR ) );
  410. F77_VOID_FUN F77dgemm
  411. STDC_ARGS(
  412. ( F77_CHAR_DECL, F77_CHAR_DECL, F77_INT_DECL, F77_INT_DECL,
  413. F77_INT_DECL, F77_SIN_DECL, F77_MIN_DECL, F77_INT_DECL,
  414. F77_MIN_DECL, F77_INT_DECL, F77_SIN_DECL, F77_MINOUT_DECL,
  415. F77_INT_DECL F77_2_CHAR ) );
  416. F77_VOID_FUN F77dtrsm
  417. STDC_ARGS(
  418. ( F77_CHAR_DECL, F77_CHAR_DECL, F77_CHAR_DECL, F77_CHAR_DECL,
  419. F77_INT_DECL, F77_INT_DECL, F77_SIN_DECL, F77_MIN_DECL,
  420. F77_INT_DECL, F77_MINOUT_DECL, F77_INT_DECL F77_4_CHAR ) );
  421. #endif
  422. /*
  423. * ---------------------------------------------------------------------
  424. * HPL BLAS Function prototypes
  425. * ---------------------------------------------------------------------
  426. */
  427. #ifndef HPL_CALL_CBLAS
  428. int HPL_idamax
  429. STDC_ARGS( (
  430. const int,
  431. const double *,
  432. const int
  433. ) );
  434. void HPL_daxpy
  435. STDC_ARGS( (
  436. const int,
  437. const double,
  438. const double *,
  439. const int,
  440. double *,
  441. const int
  442. ) );
  443. void HPL_dcopy
  444. STDC_ARGS( (
  445. const int,
  446. const double *,
  447. const int,
  448. double *,
  449. const int
  450. ) );
  451. void HPL_dscal
  452. STDC_ARGS( (
  453. const int,
  454. const double,
  455. double *,
  456. const int
  457. ) );
  458. void HPL_dswap
  459. STDC_ARGS( (
  460. const int,
  461. double *,
  462. const int,
  463. double *,
  464. const int
  465. ) );
  466. void HPL_dgemv
  467. STDC_ARGS( (
  468. const enum HPL_ORDER,
  469. const enum HPL_TRANS,
  470. const int,
  471. const int,
  472. const double,
  473. const double *,
  474. const int,
  475. const double *,
  476. const int,
  477. const double,
  478. double *,
  479. const int
  480. ) );
  481. void HPL_dger
  482. STDC_ARGS( (
  483. const enum HPL_ORDER,
  484. const int,
  485. const int,
  486. const double,
  487. const double *,
  488. const int,
  489. double *,
  490. const int,
  491. double *,
  492. const int
  493. ) );
  494. void HPL_dtrsv
  495. STDC_ARGS( (
  496. const enum HPL_ORDER,
  497. const enum HPL_UPLO,
  498. const enum HPL_TRANS,
  499. const enum HPL_DIAG,
  500. const int,
  501. const double *,
  502. const int,
  503. double *,
  504. const int
  505. ) );
  506. void HPL_dgemm
  507. STDC_ARGS( (
  508. const enum HPL_ORDER,
  509. const enum HPL_TRANS,
  510. const enum HPL_TRANS,
  511. const int,
  512. const int,
  513. const int,
  514. const double,
  515. const double *,
  516. const int,
  517. const double *,
  518. const int,
  519. const double,
  520. double *,
  521. const int
  522. ) );
  523. void HPL_dtrsm
  524. STDC_ARGS( (
  525. const enum HPL_ORDER,
  526. const enum HPL_SIDE,
  527. const enum HPL_UPLO,
  528. const enum HPL_TRANS,
  529. const enum HPL_DIAG,
  530. const int,
  531. const int,
  532. const double,
  533. const double *,
  534. const int,
  535. double *,
  536. const int
  537. ) );
  538. #endif
  539. #endif
  540. /*
  541. * hpl_blas.h
  542. */