You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_simatcopy.c 24 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915
  1. /*****************************************************************************
  2. Copyright (c) 2023, 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
  16. permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  23. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  24. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  26. USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  27. **********************************************************************************/
  28. #include "utest/openblas_utest.h"
  29. #include "common.h"
  30. #define DATASIZE 100
  31. struct DATA_SIMATCOPY {
  32. float a_test[DATASIZE* DATASIZE];
  33. float a_verify[DATASIZE* DATASIZE];
  34. };
  35. #ifdef BUILD_SINGLE
  36. static struct DATA_SIMATCOPY data_simatcopy;
  37. /**
  38. * Comapare results computed by simatcopy and reference func
  39. *
  40. * param api specifies tested api (C or Fortran)
  41. * param order specifies row or column major order
  42. * param trans specifies op(A), the transposition operation
  43. * applied to the matrix A
  44. * param rows specifies number of rows of A
  45. * param cols specifies number of columns of A
  46. * param alpha specifies scaling factor for matrix A
  47. * param lda_src - leading dimension of the matrix A
  48. * param lda_dst - leading dimension of output matrix A
  49. * return norm of difference between openblas and reference func
  50. */
  51. static float check_simatcopy(char api, char order, char trans, blasint rows, blasint cols, float alpha,
  52. blasint lda_src, blasint lda_dst)
  53. {
  54. blasint m, n;
  55. blasint rows_out, cols_out;
  56. enum CBLAS_ORDER corder;
  57. enum CBLAS_TRANSPOSE ctrans;
  58. if (order == 'C') {
  59. n = rows; m = cols;
  60. }
  61. else {
  62. m = rows; n = cols;
  63. }
  64. if(trans == 'T' || trans == 'C') {
  65. rows_out = n; cols_out = m;
  66. }
  67. else {
  68. rows_out = m; cols_out = n;
  69. }
  70. srand_generate(data_simatcopy.a_test, lda_src*m);
  71. if (trans == 'T' || trans == 'C') {
  72. stranspose(m, n, alpha, data_simatcopy.a_test, lda_src, data_simatcopy.a_verify, lda_dst);
  73. }
  74. else {
  75. scopy(m, n, alpha, data_simatcopy.a_test, lda_src, data_simatcopy.a_verify, lda_dst);
  76. }
  77. if (api == 'F') {
  78. BLASFUNC(simatcopy)(&order, &trans, &rows, &cols, &alpha, data_simatcopy.a_test,
  79. &lda_src, &lda_dst);
  80. }
  81. else {
  82. if (order == 'C') corder = CblasColMajor;
  83. if (order == 'R') corder = CblasRowMajor;
  84. if (trans == 'T') ctrans = CblasTrans;
  85. if (trans == 'N') ctrans = CblasNoTrans;
  86. if (trans == 'C') ctrans = CblasConjTrans;
  87. if (trans == 'R') ctrans = CblasConjNoTrans;
  88. cblas_simatcopy(corder, ctrans, rows, cols, alpha, data_simatcopy.a_test,
  89. lda_src, lda_dst);
  90. }
  91. // Find the differences between output matrix computed by simatcopy and reference func
  92. return smatrix_difference(data_simatcopy.a_test, data_simatcopy.a_verify, cols_out, rows_out, lda_dst);
  93. }
  94. /**
  95. * Check if error function was called with expected function name
  96. * and param info
  97. *
  98. * param order specifies row or column major order
  99. * param trans specifies op(A), the transposition operation
  100. * applied to the matrix A
  101. * param rows specifies number of rows of A
  102. * param cols specifies number of columns of A
  103. * param lda_src - leading dimension of the matrix A
  104. * param lda_dst - leading dimension of output matrix A
  105. * param expected_info - expected invalid parameter number
  106. * return TRUE if everything is ok, otherwise FALSE
  107. */
  108. static int check_badargs(char order, char trans, blasint rows, blasint cols,
  109. blasint lda_src, blasint lda_dst, int expected_info)
  110. {
  111. float alpha = 1.0f;
  112. set_xerbla("SIMATCOPY", expected_info);
  113. BLASFUNC(simatcopy)(&order, &trans, &rows, &cols, &alpha, data_simatcopy.a_test,
  114. &lda_src, &lda_dst);
  115. return check_error();
  116. }
  117. /**
  118. * Fortran API specific test
  119. * Test simatcopy by comparing it against reference
  120. * with the following options:
  121. *
  122. * Column Major
  123. * Transposition
  124. * Square matrix
  125. * alpha = 1.0f
  126. */
  127. CTEST(simatcopy, colmajor_trans_col_100_row_100_alpha_one)
  128. {
  129. blasint m = 100, n = 100;
  130. blasint lda_src = 100, lda_dst = 100;
  131. char order = 'C';
  132. char trans = 'T';
  133. float alpha = 1.0f;
  134. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  135. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  136. }
  137. /**
  138. * Fortran API specific test
  139. * Test simatcopy by comparing it against reference
  140. * with the following options:
  141. *
  142. * Column Major
  143. * Copy only
  144. * Square matrix
  145. * alpha = 1.0f
  146. */
  147. CTEST(simatcopy, colmajor_notrans_col_100_row_100_alpha_one)
  148. {
  149. blasint m = 100, n = 100;
  150. blasint lda_src = 100, lda_dst = 100;
  151. char order = 'C';
  152. char trans = 'N';
  153. float alpha = 1.0f;
  154. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  155. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  156. }
  157. /**
  158. * Fortran API specific test
  159. * Test simatcopy by comparing it against reference
  160. * with the following options:
  161. *
  162. * Column Major
  163. * Transposition
  164. * Square matrix
  165. * alpha = 0.0f
  166. */
  167. CTEST(simatcopy, colmajor_trans_col_100_row_100_alpha_zero)
  168. {
  169. blasint m = 100, n = 100;
  170. blasint lda_src = 100, lda_dst = 100;
  171. char order = 'C';
  172. char trans = 'T';
  173. float alpha = 0.0f;
  174. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  175. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  176. }
  177. /**
  178. * Fortran API specific test
  179. * Test simatcopy by comparing it against reference
  180. * with the following options:
  181. *
  182. * Column Major
  183. * Copy only
  184. * Square matrix
  185. * alpha = 0.0f
  186. */
  187. CTEST(simatcopy, colmajor_notrans_col_100_row_100_alpha_zero)
  188. {
  189. blasint m = 100, n = 100;
  190. blasint lda_src = 100, lda_dst = 100;
  191. char order = 'C';
  192. char trans = 'N';
  193. float alpha = 0.0f;
  194. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  195. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  196. }
  197. /**
  198. * Fortran API specific test
  199. * Test simatcopy by comparing it against reference
  200. * with the following options:
  201. *
  202. * Column Major
  203. * Transposition
  204. * Square matrix
  205. * alpha = 2.0f
  206. */
  207. CTEST(simatcopy, colmajor_trans_col_100_row_100)
  208. {
  209. blasint m = 100, n = 100;
  210. blasint lda_src = 100, lda_dst = 100;
  211. char order = 'C';
  212. char trans = 'T';
  213. float alpha = 2.0f;
  214. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  215. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  216. }
  217. /**
  218. * Fortran API specific test
  219. * Test simatcopy by comparing it against reference
  220. * with the following options:
  221. *
  222. * Column Major
  223. * Copy only
  224. * Square matrix
  225. * alpha = 2.0f
  226. */
  227. CTEST(simatcopy, colmajor_notrans_col_100_row_100)
  228. {
  229. blasint m = 100, n = 100;
  230. blasint lda_src = 100, lda_dst = 100;
  231. char order = 'C';
  232. char trans = 'N';
  233. float alpha = 2.0f;
  234. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  235. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  236. }
  237. /**
  238. * Fortran API specific test
  239. * Test simatcopy by comparing it against reference
  240. * with the following options:
  241. *
  242. * Column Major
  243. * Transposition
  244. * Rectangular matrix
  245. * alpha = 1.0f
  246. */
  247. CTEST(simatcopy, colmajor_trans_col_50_row_100_alpha_one)
  248. {
  249. blasint m = 100, n = 50;
  250. blasint lda_src = 100, lda_dst = 50;
  251. char order = 'C';
  252. char trans = 'T';
  253. float alpha = 1.0f;
  254. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  255. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  256. }
  257. /**
  258. * Fortran API specific test
  259. * Test simatcopy by comparing it against reference
  260. * with the following options:
  261. *
  262. * Column Major
  263. * Copy only
  264. * Rectangular matrix
  265. * alpha = 1.0f
  266. */
  267. CTEST(simatcopy, colmajor_notrans_col_50_row_100_alpha_one)
  268. {
  269. blasint m = 100, n = 50;
  270. blasint lda_src = 100, lda_dst = 100;
  271. char order = 'C';
  272. char trans = 'N';
  273. float alpha = 1.0f;
  274. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  275. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  276. }
  277. /**
  278. * Fortran API specific test
  279. * Test simatcopy by comparing it against reference
  280. * with the following options:
  281. *
  282. * Column Major
  283. * Transposition
  284. * Rectangular matrix
  285. * alpha = 0.0f
  286. */
  287. CTEST(simatcopy, colmajor_trans_col_50_row_100_alpha_zero)
  288. {
  289. blasint m = 100, n = 50;
  290. blasint lda_src = 100, lda_dst = 50;
  291. char order = 'C';
  292. char trans = 'T';
  293. float alpha = 0.0f;
  294. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  295. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  296. }
  297. /**
  298. * Fortran API specific test
  299. * Test simatcopy by comparing it against reference
  300. * with the following options:
  301. *
  302. * Column Major
  303. * Copy only
  304. * Rectangular matrix
  305. * alpha = 0.0f
  306. */
  307. CTEST(simatcopy, colmajor_notrans_col_50_row_100_alpha_zero)
  308. {
  309. blasint m = 100, n = 50;
  310. blasint lda_src = 100, lda_dst = 100;
  311. char order = 'C';
  312. char trans = 'N';
  313. float alpha = 0.0f;
  314. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  315. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  316. }
  317. /**
  318. * Fortran API specific test
  319. * Test simatcopy by comparing it against reference
  320. * with the following options:
  321. *
  322. * Column Major
  323. * Transposition
  324. * Rectangular matrix
  325. * alpha = 2.0f
  326. */
  327. CTEST(simatcopy, colmajor_trans_col_50_row_100)
  328. {
  329. blasint m = 100, n = 50;
  330. blasint lda_src = 100, lda_dst = 50;
  331. char order = 'C';
  332. char trans = 'T';
  333. float alpha = 2.0f;
  334. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  335. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  336. }
  337. /**
  338. * Fortran API specific test
  339. * Test simatcopy by comparing it against reference
  340. * with the following options:
  341. *
  342. * Column Major
  343. * Copy only
  344. * Rectangular matrix
  345. * alpha = 2.0f
  346. */
  347. CTEST(simatcopy, colmajor_notrans_col_50_row_100)
  348. {
  349. blasint m = 100, n = 50;
  350. blasint lda_src = 100, lda_dst = 100;
  351. char order = 'C';
  352. char trans = 'N';
  353. float alpha = 2.0f;
  354. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  355. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  356. }
  357. /**
  358. * Fortran API specific test
  359. * Test simatcopy by comparing it against reference
  360. * with the following options:
  361. *
  362. * Row Major
  363. * Transposition
  364. * Square matrix
  365. * alpha = 1.0f
  366. */
  367. CTEST(simatcopy, rowmajor_trans_col_100_row_100_alpha_one)
  368. {
  369. blasint m = 100, n = 100;
  370. blasint lda_src = 100, lda_dst = 100;
  371. char order = 'R';
  372. char trans = 'T';
  373. float alpha = 1.0f;
  374. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  375. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  376. }
  377. /**
  378. * Fortran API specific test
  379. * Test simatcopy by comparing it against reference
  380. * with the following options:
  381. *
  382. * Row Major
  383. * Copy only
  384. * Square matrix
  385. * alpha = 1.0f
  386. */
  387. CTEST(simatcopy, rowmajor_notrans_col_100_row_100_alpha_one)
  388. {
  389. blasint m = 100, n = 100;
  390. blasint lda_src = 100, lda_dst = 100;
  391. char order = 'R';
  392. char trans = 'N';
  393. float alpha = 1.0f;
  394. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  395. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  396. }
  397. /**
  398. * Fortran API specific test
  399. * Test simatcopy by comparing it against reference
  400. * with the following options:
  401. *
  402. * Row Major
  403. * Transposition
  404. * Square matrix
  405. * alpha = 0.0f
  406. */
  407. CTEST(simatcopy, rowmajor_trans_col_100_row_100_alpha_zero)
  408. {
  409. blasint m = 100, n = 100;
  410. blasint lda_src = 100, lda_dst = 100;
  411. char order = 'R';
  412. char trans = 'T';
  413. float alpha = 0.0f;
  414. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  415. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  416. }
  417. /**
  418. * Fortran API specific test
  419. * Test simatcopy by comparing it against reference
  420. * with the following options:
  421. *
  422. * Row Major
  423. * Copy only
  424. * Square matrix
  425. * alpha = 0.0f
  426. */
  427. CTEST(simatcopy, rowmajor_notrans_col_100_row_100_alpha_zero)
  428. {
  429. blasint m = 100, n = 100;
  430. blasint lda_src = 100, lda_dst = 100;
  431. char order = 'R';
  432. char trans = 'N';
  433. float alpha = 0.0f;
  434. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  435. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  436. }
  437. /**
  438. * Fortran API specific tests
  439. * Test simatcopy by comparing it against reference
  440. * with the following options:
  441. *
  442. * Row Major
  443. * Transposition
  444. * Square matrix
  445. * alpha = 2.0f
  446. */
  447. CTEST(simatcopy, rowmajor_trans_col_100_row_100)
  448. {
  449. blasint m = 100, n = 100;
  450. blasint lda_src = 100, lda_dst = 100;
  451. char order = 'R';
  452. char trans = 'T';
  453. float alpha = 2.0f;
  454. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  455. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  456. }
  457. /**
  458. * Fortran API specific test
  459. * Test simatcopy by comparing it against reference
  460. * with the following options:
  461. *
  462. * Row Major
  463. * Copy only
  464. * Square matrix
  465. * alpha = 2.0f
  466. */
  467. CTEST(simatcopy, rowmajor_notrans_col_100_row_100)
  468. {
  469. blasint m = 100, n = 100;
  470. blasint lda_src = 100, lda_dst = 100;
  471. char order = 'R';
  472. char trans = 'N';
  473. float alpha = 2.0f;
  474. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  475. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  476. }
  477. /**
  478. * Fortran API specific test
  479. * Test simatcopy by comparing it against reference
  480. * with the following options:
  481. *
  482. * Row Major
  483. * Transposition
  484. * Rectangular matrix
  485. * alpha = 1.0f
  486. */
  487. CTEST(simatcopy, rowmajor_trans_col_100_row_50_alpha_one)
  488. {
  489. blasint m = 50, n = 100;
  490. blasint lda_src = 100, lda_dst = 50;
  491. char order = 'R';
  492. char trans = 'C'; // same as trans for real matrix
  493. float alpha = 1.0f;
  494. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  495. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  496. }
  497. /**
  498. * Fortran API specific test
  499. * Test simatcopy by comparing it against reference
  500. * with the following options:
  501. *
  502. * Row Major
  503. * Copy only
  504. * Rectangular matrix
  505. * alpha = 1.0f
  506. */
  507. CTEST(simatcopy, rowmajor_notrans_col_100_row_50_alpha_one)
  508. {
  509. blasint m = 50, n = 100;
  510. blasint lda_src = 100, lda_dst = 100;
  511. char order = 'R';
  512. char trans = 'N';
  513. float alpha = 1.0f;
  514. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  515. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  516. }
  517. /**
  518. * Fortran API specific test
  519. * Test simatcopy by comparing it against reference
  520. * with the following options:
  521. *
  522. * Row Major
  523. * Transposition
  524. * Rectangular matrix
  525. * alpha = 0.0f
  526. */
  527. CTEST(simatcopy, rowmajor_trans_col_100_row_50_alpha_zero)
  528. {
  529. blasint m = 50, n = 100;
  530. blasint lda_src = 100, lda_dst = 50;
  531. char order = 'R';
  532. char trans = 'C'; // same as trans for real matrix
  533. float alpha = 0.0f;
  534. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  535. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  536. }
  537. /**
  538. * Fortran API specific test
  539. * Test simatcopy by comparing it against reference
  540. * with the following options:
  541. *
  542. * Row Major
  543. * Copy only
  544. * Rectangular matrix
  545. * alpha = 0.0f
  546. */
  547. CTEST(simatcopy, rowmajor_notrans_col_100_row_50_alpha_zero)
  548. {
  549. blasint m = 50, n = 100;
  550. blasint lda_src = 100, lda_dst = 100;
  551. char order = 'R';
  552. char trans = 'N';
  553. float alpha = 0.0f;
  554. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  555. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  556. }
  557. /**
  558. * Fortran API specific test
  559. * Test simatcopy by comparing it against reference
  560. * with the following options:
  561. *
  562. * Row Major
  563. * Transposition
  564. * Rectangular matrix
  565. * alpha = 2.0f
  566. */
  567. CTEST(simatcopy, rowmajor_trans_col_100_row_50)
  568. {
  569. blasint m = 50, n = 100;
  570. blasint lda_src = 100, lda_dst = 50;
  571. char order = 'R';
  572. char trans = 'C'; // same as trans for real matrix
  573. float alpha = 2.0f;
  574. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  575. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  576. }
  577. /**
  578. * Fortran API specific test
  579. * Test simatcopy by comparing it against reference
  580. * with the following options:
  581. *
  582. * Row Major
  583. * Copy only
  584. * Rectangular matrix
  585. * alpha = 2.0f
  586. */
  587. CTEST(simatcopy, rowmajor_notrans_col_100_row_50)
  588. {
  589. blasint m = 50, n = 100;
  590. blasint lda_src = 100, lda_dst = 100;
  591. char order = 'R';
  592. char trans = 'N';
  593. float alpha = 2.0f;
  594. float norm = check_simatcopy('F', order, trans, m, n, alpha, lda_src, lda_dst);
  595. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  596. }
  597. /**
  598. * C API specific test
  599. * Test simatcopy by comparing it against reference
  600. * with the following options:
  601. *
  602. * Column Major
  603. * Transposition
  604. * Square matrix
  605. * alpha = 2.0f
  606. */
  607. CTEST(simatcopy, c_api_colmajor_trans_col_100_row_100)
  608. {
  609. blasint m = 100, n = 100;
  610. blasint lda_src = 100, lda_dst = 100;
  611. char order = 'C';
  612. char trans = 'T';
  613. float alpha = 2.0f;
  614. float norm = check_simatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  615. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  616. }
  617. /**
  618. * C API specific test
  619. * Test simatcopy by comparing it against reference
  620. * with the following options:
  621. *
  622. * Column Major
  623. * Copy only
  624. * Square matrix
  625. * alpha = 2.0f
  626. */
  627. CTEST(simatcopy, c_api_colmajor_notrans_col_100_row_100)
  628. {
  629. blasint m = 100, n = 100;
  630. blasint lda_src = 100, lda_dst = 100;
  631. char order = 'C';
  632. char trans = 'N';
  633. float alpha = 2.0f;
  634. float norm = check_simatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  635. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  636. }
  637. /**
  638. * C API specific test
  639. * Test simatcopy by comparing it against reference
  640. * with the following options:
  641. *
  642. * Row Major
  643. * Transposition
  644. * Square matrix
  645. * alpha = 2.0f
  646. */
  647. CTEST(simatcopy, c_api_rowmajor_trans_col_100_row_100)
  648. {
  649. blasint m = 100, n = 100;
  650. blasint lda_src = 100, lda_dst = 100;
  651. char order = 'R';
  652. char trans = 'T';
  653. float alpha = 2.0f;
  654. float norm = check_simatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  655. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  656. }
  657. /**
  658. * C API specific test
  659. * Test simatcopy by comparing it against reference
  660. * with the following options:
  661. *
  662. * Row Major
  663. * Copy only
  664. * Square matrix
  665. * alpha = 2.0f
  666. */
  667. CTEST(simatcopy, c_api_rowmajor_notrans_col_100_row_100)
  668. {
  669. blasint m = 100, n = 100;
  670. blasint lda_src = 100, lda_dst = 100;
  671. char order = 'R';
  672. char trans = 'N';
  673. float alpha = 2.0f;
  674. float norm = check_simatcopy('C', order, trans, m, n, alpha, lda_src, lda_dst);
  675. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  676. }
  677. /**
  678. * Test error function for an invalid param order.
  679. * Must be column (C) or row major (R).
  680. */
  681. CTEST(simatcopy, xerbla_invalid_order)
  682. {
  683. blasint m = 100, n = 100;
  684. blasint lda_src = 100, lda_dst = 100;
  685. char order = 'O';
  686. char trans = 'T';
  687. int expected_info = 1;
  688. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  689. ASSERT_EQUAL(TRUE, passed);
  690. }
  691. /**
  692. * Test error function for an invalid param trans.
  693. * Must be trans (T/C) or no-trans (N/R).
  694. */
  695. CTEST(simatcopy, xerbla_invalid_trans)
  696. {
  697. blasint m = 100, n = 100;
  698. blasint lda_src = 100, lda_dst = 100;
  699. char order = 'C';
  700. char trans = 'O';
  701. int expected_info = 2;
  702. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  703. ASSERT_EQUAL(TRUE, passed);
  704. }
  705. /**
  706. * Test error function for an invalid param lda_src.
  707. * If matrices are stored using row major layout,
  708. * lda_src must be at least n.
  709. */
  710. CTEST(simatcopy, xerbla_rowmajor_invalid_lda)
  711. {
  712. blasint m = 50, n = 100;
  713. blasint lda_src = 50, lda_dst = 100;
  714. char order = 'R';
  715. char trans = 'T';
  716. int expected_info = 7;
  717. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  718. ASSERT_EQUAL(TRUE, passed);
  719. }
  720. /**
  721. * Test error function for an invalid param lda_src.
  722. * If matrices are stored using column major layout,
  723. * lda_src must be at least m.
  724. */
  725. CTEST(simatcopy, xerbla_colmajor_invalid_lda)
  726. {
  727. blasint m = 100, n = 50;
  728. blasint lda_src = 50, lda_dst = 100;
  729. char order = 'C';
  730. char trans = 'T';
  731. int expected_info = 7;
  732. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  733. ASSERT_EQUAL(TRUE, passed);
  734. }
  735. /**
  736. * Test error function for an invalid param lda_dst.
  737. * If matrices are stored using row major layout and
  738. * there is no transposition, lda_dst must be at least n.
  739. */
  740. CTEST(simatcopy, xerbla_rowmajor_notrans_invalid_ldb)
  741. {
  742. blasint m = 50, n = 100;
  743. blasint lda_src = 100, lda_dst = 50;
  744. char order = 'R';
  745. char trans = 'N';
  746. int expected_info = 9;
  747. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  748. ASSERT_EQUAL(TRUE, passed);
  749. }
  750. /**
  751. * Test error function for an invalid param lda_dst.
  752. * If matrices are stored using row major layout and
  753. * there is transposition, lda_dst must be at least m.
  754. */
  755. CTEST(simatcopy, xerbla_rowmajor_trans_invalid_ldb)
  756. {
  757. blasint m = 100, n = 50;
  758. blasint lda_src = 100, lda_dst = 50;
  759. char order = 'R';
  760. char trans = 'T';
  761. int expected_info = 9;
  762. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  763. ASSERT_EQUAL(TRUE, passed);
  764. }
  765. /**
  766. * Test error function for an invalid param lda_dst.
  767. * If matrices are stored using column major layout and
  768. * there is no transposition, lda_dst must be at least m.
  769. */
  770. CTEST(simatcopy, xerbla_colmajor_notrans_invalid_ldb)
  771. {
  772. blasint m = 100, n = 50;
  773. blasint lda_src = 100, lda_dst = 50;
  774. char order = 'C';
  775. char trans = 'N';
  776. int expected_info = 9;
  777. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  778. ASSERT_EQUAL(TRUE, passed);
  779. }
  780. /**
  781. * Test error function for an invalid param lda_dst.
  782. * If matrices are stored using column major layout and
  783. * there is transposition, lda_dst must be at least n.
  784. */
  785. CTEST(simatcopy, xerbla_colmajor_trans_invalid_ldb)
  786. {
  787. blasint m = 50, n = 100;
  788. blasint lda_src = 100, lda_dst = 50;
  789. char order = 'C';
  790. char trans = 'T';
  791. int expected_info = 9;
  792. int passed = check_badargs(order, trans, m, n, lda_src, lda_dst, expected_info);
  793. ASSERT_EQUAL(TRUE, passed);
  794. }
  795. #endif