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_saxpby.c 20 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. #define INCREMENT 2
  32. struct DATA_SAXPBY {
  33. float x_test[DATASIZE * INCREMENT];
  34. float x_verify[DATASIZE * INCREMENT];
  35. float y_test[DATASIZE * INCREMENT];
  36. float y_verify[DATASIZE * INCREMENT];
  37. };
  38. #ifdef BUILD_SINGLE
  39. static struct DATA_SAXPBY data_saxpby;
  40. /**
  41. * Fortran API specific function
  42. * Test saxpby by comparing it with sscal and saxpy.
  43. * Compare with the following options:
  44. *
  45. * param n - number of elements in vectors x and y
  46. * param alpha - scalar alpha
  47. * param incx - increment for the elements of x
  48. * param beta - scalar beta
  49. * param incy - increment for the elements of y
  50. * return norm of difference
  51. */
  52. static float check_saxpby(blasint n, float alpha, blasint incx, float beta, blasint incy)
  53. {
  54. blasint i;
  55. // sscal accept only positive increments
  56. blasint incx_abs = labs(incx);
  57. blasint incy_abs = labs(incy);
  58. // Fill vectors x, y
  59. srand_generate(data_saxpby.x_test, n * incx_abs);
  60. srand_generate(data_saxpby.y_test, n * incy_abs);
  61. // Copy vector x for saxpy
  62. for (i = 0; i < n * incx_abs; i++)
  63. data_saxpby.x_verify[i] = data_saxpby.x_test[i];
  64. // Copy vector y for sscal
  65. for (i = 0; i < n * incy_abs; i++)
  66. data_saxpby.y_verify[i] = data_saxpby.y_test[i];
  67. // Find beta*y
  68. BLASFUNC(sscal)(&n, &beta, data_saxpby.y_verify, &incy_abs);
  69. // Find sum of alpha*x and beta*y
  70. BLASFUNC(saxpy)(&n, &alpha, data_saxpby.x_verify, &incx,
  71. data_saxpby.y_verify, &incy);
  72. BLASFUNC(saxpby)(&n, &alpha, data_saxpby.x_test, &incx,
  73. &beta, data_saxpby.y_test, &incy);
  74. // Find the differences between output vector caculated by saxpby and saxpy
  75. for (i = 0; i < n * incy_abs; i++)
  76. data_saxpby.y_test[i] -= data_saxpby.y_verify[i];
  77. // Find the norm of differences
  78. return BLASFUNC(snrm2)(&n, data_saxpby.y_test, &incy_abs);
  79. }
  80. #ifndef NO_CBLAS
  81. /**
  82. * C API specific function
  83. * Test saxpby by comparing it with sscal and saxpy.
  84. * Compare with the following options:
  85. *
  86. * param n - number of elements in vectors x and y
  87. * param alpha - scalar alpha
  88. * param incx - increment for the elements of x
  89. * param beta - scalar beta
  90. * param incy - increment for the elements of y
  91. * return norm of difference
  92. */
  93. static float c_api_check_saxpby(blasint n, float alpha, blasint incx, float beta, blasint incy)
  94. {
  95. blasint i;
  96. // sscal accept only positive increments
  97. blasint incx_abs = labs(incx);
  98. blasint incy_abs = labs(incy);
  99. // Copy vector x for saxpy
  100. for (i = 0; i < n * incx_abs; i++)
  101. data_saxpby.x_verify[i] = data_saxpby.x_test[i];
  102. // Copy vector y for sscal
  103. for (i = 0; i < n * incy_abs; i++)
  104. data_saxpby.y_verify[i] = data_saxpby.y_test[i];
  105. // Find beta*y
  106. cblas_sscal(n, beta, data_saxpby.y_verify, incy_abs);
  107. // Find sum of alpha*x and beta*y
  108. cblas_saxpy(n, alpha, data_saxpby.x_verify, incx,
  109. data_saxpby.y_verify, incy);
  110. cblas_saxpby(n, alpha, data_saxpby.x_test, incx,
  111. beta, data_saxpby.y_test, incy);
  112. // Find the differences between output vector caculated by saxpby and saxpy
  113. for (i = 0; i < n * incy_abs; i++)
  114. data_saxpby.y_test[i] -= data_saxpby.y_verify[i];
  115. // Find the norm of differences
  116. return cblas_snrm2(n, data_saxpby.y_test, incy_abs);
  117. }
  118. #endif
  119. /**
  120. * Fortran API specific test
  121. * Test saxpby by comparing it with sscal and saxpy.
  122. * Test with the following options:
  123. *
  124. * Size of vectors x, y is 100
  125. * Stride of vector x is 1
  126. * Stride of vector y is 1
  127. */
  128. CTEST(saxpby, inc_x_1_inc_y_1_N_100)
  129. {
  130. blasint n = DATASIZE, incx = 1, incy = 1;
  131. float alpha = 1.0f;
  132. float beta = 1.0f;
  133. float norm = check_saxpby(n, alpha, incx, beta, incy);
  134. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  135. }
  136. /**
  137. * Fortran API specific test
  138. * Test saxpby by comparing it with sscal and saxpy.
  139. * Test with the following options:
  140. *
  141. * Size of vectors x, y is 100
  142. * Stride of vector x is 2
  143. * Stride of vector y is 1
  144. */
  145. CTEST(saxpby, inc_x_2_inc_y_1_N_100)
  146. {
  147. blasint n = DATASIZE, incx = 2, incy = 1;
  148. float alpha = 2.0f;
  149. float beta = 1.0f;
  150. float norm = check_saxpby(n, alpha, incx, beta, incy);
  151. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  152. }
  153. /**
  154. * Fortran API specific test
  155. * Test saxpby by comparing it with sscal and saxpy.
  156. * Test with the following options:
  157. *
  158. * Size of vectors x, y is 100
  159. * Stride of vector x is 1
  160. * Stride of vector y is 2
  161. */
  162. CTEST(saxpby, inc_x_1_inc_y_2_N_100)
  163. {
  164. blasint n = DATASIZE, incx = 1, incy = 2;
  165. float alpha = 1.0f;
  166. float beta = 2.0f;
  167. float norm = check_saxpby(n, alpha, incx, beta, incy);
  168. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  169. }
  170. /**
  171. * Fortran API specific test
  172. * Test saxpby by comparing it with sscal and saxpy.
  173. * Test with the following options:
  174. *
  175. * Size of vectors x, y is 100
  176. * Stride of vector x is 2
  177. * Stride of vector y is 2
  178. */
  179. CTEST(saxpby, inc_x_2_inc_y_2_N_100)
  180. {
  181. blasint n = DATASIZE, incx = 2, incy = 2;
  182. float alpha = 3.0f;
  183. float beta = 4.0f;
  184. float norm = check_saxpby(n, alpha, incx, beta, incy);
  185. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  186. }
  187. /**
  188. * Fortran API specific test
  189. * Test saxpby by comparing it with sscal and saxpy.
  190. * Test with the following options:
  191. *
  192. * Size of vectors x, y is 100
  193. * Stride of vector x is -1
  194. * Stride of vector y is 2
  195. */
  196. CTEST(saxpby, inc_x_neg_1_inc_y_2_N_100)
  197. {
  198. blasint n = DATASIZE, incx = -1, incy = 2;
  199. float alpha = 5.0f;
  200. float beta = 4.0f;
  201. float norm = check_saxpby(n, alpha, incx, beta, incy);
  202. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  203. }
  204. /**
  205. * Fortran API specific test
  206. * Test saxpby by comparing it with sscal and saxpy.
  207. * Test with the following options:
  208. *
  209. * Size of vectors x, y is 100
  210. * Stride of vector x is 2
  211. * Stride of vector y is -1
  212. */
  213. CTEST(saxpby, inc_x_2_inc_y_neg_1_N_100)
  214. {
  215. blasint n = DATASIZE, incx = 2, incy = -1;
  216. float alpha = 1.0f;
  217. float beta = 6.0f;
  218. float norm = check_saxpby(n, alpha, incx, beta, incy);
  219. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  220. }
  221. /**
  222. * Fortran API specific test
  223. * Test saxpby by comparing it with sscal and saxpy.
  224. * Test with the following options:
  225. *
  226. * Size of vectors x, y is 100
  227. * Stride of vector x is -2
  228. * Stride of vector y is -1
  229. */
  230. CTEST(saxpby, inc_x_neg_2_inc_y_neg_1_N_100)
  231. {
  232. blasint n = DATASIZE, incx = -2, incy = -1;
  233. float alpha = 7.0f;
  234. float beta = 3.5f;
  235. float norm = check_saxpby(n, alpha, incx, beta, incy);
  236. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  237. }
  238. /**
  239. * Fortran API specific test
  240. * Test saxpby by comparing it with sscal and saxpy.
  241. * Test with the following options:
  242. *
  243. * Size of vectors x, y is 100
  244. * Stride of vector x is 1
  245. * Stride of vector y is 1
  246. * Scalar alpha is zero
  247. */
  248. CTEST(saxpby, inc_x_1_inc_y_1_N_100_alpha_zero)
  249. {
  250. blasint n = DATASIZE, incx = 1, incy = 1;
  251. float alpha = 0.0f;
  252. float beta = 1.0f;
  253. float norm = check_saxpby(n, alpha, incx, beta, incy);
  254. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  255. }
  256. /**
  257. * Fortran API specific test
  258. * Test saxpby by comparing it with sscal and saxpy.
  259. * Test with the following options:
  260. *
  261. * Size of vectors x, y is 100
  262. * Stride of vector x is 1
  263. * Stride of vector y is 2
  264. * Scalar alpha is zero
  265. */
  266. CTEST(saxpby, inc_x_1_inc_y_2_N_100_alpha_zero)
  267. {
  268. blasint n = DATASIZE, incx = 1, incy = 2;
  269. float alpha = 0.0f;
  270. float beta = 1.0f;
  271. float norm = check_saxpby(n, alpha, incx, beta, incy);
  272. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  273. }
  274. /**
  275. * Fortran API specific test
  276. * Test saxpby by comparing it with sscal and saxpy.
  277. * Test with the following options:
  278. *
  279. * Size of vectors x, y is 100
  280. * Stride of vector x is 1
  281. * Stride of vector y is 1
  282. * Scalar beta is zero
  283. */
  284. CTEST(saxpby, inc_x_1_inc_y_1_N_100_beta_zero)
  285. {
  286. blasint n = DATASIZE, incx = 1, incy = 1;
  287. float alpha = 1.0f;
  288. float beta = 0.0f;
  289. float norm = check_saxpby(n, alpha, incx, beta, incy);
  290. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  291. }
  292. /**
  293. * Fortran API specific test
  294. * Test saxpby by comparing it with sscal and saxpy.
  295. * Test with the following options:
  296. *
  297. * Size of vectors x, y is 100
  298. * Stride of vector x is 2
  299. * Stride of vector y is 1
  300. * Scalar beta is zero
  301. */
  302. CTEST(saxpby, inc_x_2_inc_y_1_N_100_beta_zero)
  303. {
  304. blasint n = DATASIZE, incx = 2, incy = 1;
  305. float alpha = 1.0f;
  306. float beta = 0.0f;
  307. float norm = check_saxpby(n, alpha, incx, beta, incy);
  308. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  309. }
  310. /**
  311. * Fortran API specific test
  312. * Test saxpby by comparing it with sscal and saxpy.
  313. * Test with the following options:
  314. *
  315. * Size of vectors x, y is 100
  316. * Stride of vector x is 1
  317. * Stride of vector y is 2
  318. * Scalar beta is zero
  319. */
  320. CTEST(saxpby, inc_x_1_inc_y_2_N_100_beta_zero)
  321. {
  322. blasint n = DATASIZE, incx = 1, incy = 2;
  323. float alpha = 1.0f;
  324. float beta = 0.0f;
  325. float norm = check_saxpby(n, alpha, incx, beta, incy);
  326. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  327. }
  328. /**
  329. * Fortran API specific test
  330. * Test saxpby by comparing it with sscal and saxpy.
  331. * Test with the following options:
  332. *
  333. * Size of vectors x, y is 100
  334. * Stride of vector x is 2
  335. * Stride of vector y is 2
  336. * Scalar beta is zero
  337. */
  338. CTEST(saxpby, inc_x_2_inc_y_2_N_100_beta_zero)
  339. {
  340. blasint n = DATASIZE, incx = 2, incy = 2;
  341. float alpha = 1.0f;
  342. float beta = 0.0f;
  343. float norm = check_saxpby(n, alpha, incx, beta, incy);
  344. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  345. }
  346. /**
  347. * Fortran API specific test
  348. * Test saxpby by comparing it with sscal and saxpy.
  349. * Test with the following options:
  350. *
  351. * Size of vectors x, y is 100
  352. * Stride of vector x is 1
  353. * Stride of vector y is 1
  354. * Scalar alpha is zero
  355. * Scalar beta is zero
  356. */
  357. CTEST(saxpby, inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  358. {
  359. blasint n = DATASIZE, incx = 1, incy = 1;
  360. float alpha = 0.0f;
  361. float beta = 0.0f;
  362. float norm = check_saxpby(n, alpha, incx, beta, incy);
  363. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  364. }
  365. /**
  366. * Fortran API specific test
  367. * Test saxpby by comparing it with sscal and saxpy.
  368. * Test with the following options:
  369. *
  370. * Size of vectors x, y is 100
  371. * Stride of vector x is 1
  372. * Stride of vector y is 2
  373. * Scalar alpha is zero
  374. * Scalar beta is zero
  375. */
  376. CTEST(saxpby, inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  377. {
  378. blasint n = DATASIZE, incx = 1, incy = 2;
  379. float alpha = 0.0f;
  380. float beta = 0.0f;
  381. float norm = check_saxpby(n, alpha, incx, beta, incy);
  382. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  383. }
  384. /**
  385. * Fortran API specific test
  386. * Check if n - size of vectors x, y is zero
  387. */
  388. CTEST(saxpby, check_n_zero)
  389. {
  390. blasint n = 0, incx = 1, incy = 1;
  391. float alpha = 1.0f;
  392. float beta = 1.0f;
  393. float norm = check_saxpby(n, alpha, incx, beta, incy);
  394. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  395. }
  396. #ifndef NO_CBLAS
  397. /**
  398. * C API specific test
  399. * Test saxpby by comparing it with sscal and saxpy.
  400. * Test with the following options:
  401. *
  402. * Size of vectors x, y is 100
  403. * Stride of vector x is 1
  404. * Stride of vector y is 1
  405. */
  406. CTEST(saxpby, c_api_inc_x_1_inc_y_1_N_100)
  407. {
  408. blasint n = DATASIZE, incx = 1, incy = 1;
  409. float alpha = 1.0f;
  410. float beta = 1.0f;
  411. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  412. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  413. }
  414. /**
  415. * C API specific test
  416. * Test saxpby by comparing it with sscal and saxpy.
  417. * Test with the following options:
  418. *
  419. * Size of vectors x, y is 100
  420. * Stride of vector x is 2
  421. * Stride of vector y is 1
  422. */
  423. CTEST(saxpby, c_api_inc_x_2_inc_y_1_N_100)
  424. {
  425. blasint n = DATASIZE, incx = 2, incy = 1;
  426. float alpha = 2.0f;
  427. float beta = 1.0f;
  428. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  429. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  430. }
  431. /**
  432. * C API specific test
  433. * Test saxpby by comparing it with sscal and saxpy.
  434. * Test with the following options:
  435. *
  436. * Size of vectors x, y is 100
  437. * Stride of vector x is 1
  438. * Stride of vector y is 2
  439. */
  440. CTEST(saxpby, c_api_inc_x_1_inc_y_2_N_100)
  441. {
  442. blasint n = DATASIZE, incx = 1, incy = 2;
  443. float alpha = 1.0f;
  444. float beta = 2.0f;
  445. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  446. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  447. }
  448. /**
  449. * C API specific test
  450. * Test saxpby by comparing it with sscal and saxpy.
  451. * Test with the following options:
  452. *
  453. * Size of vectors x, y is 100
  454. * Stride of vector x is 2
  455. * Stride of vector y is 2
  456. */
  457. CTEST(saxpby, c_api_inc_x_2_inc_y_2_N_100)
  458. {
  459. blasint n = DATASIZE, incx = 2, incy = 2;
  460. float alpha = 3.0f;
  461. float beta = 4.0f;
  462. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  463. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  464. }
  465. /**
  466. * C API specific test
  467. * Test saxpby by comparing it with sscal and saxpy.
  468. * Test with the following options:
  469. *
  470. * Size of vectors x, y is 100
  471. * Stride of vector x is -1
  472. * Stride of vector y is 2
  473. */
  474. CTEST(saxpby, c_api_inc_x_neg_1_inc_y_2_N_100)
  475. {
  476. blasint n = DATASIZE, incx = -1, incy = 2;
  477. float alpha = 5.0f;
  478. float beta = 4.0f;
  479. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  480. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  481. }
  482. /**
  483. * C API specific test
  484. * Test saxpby by comparing it with sscal and saxpy.
  485. * Test with the following options:
  486. *
  487. * Size of vectors x, y is 100
  488. * Stride of vector x is 2
  489. * Stride of vector y is -1
  490. */
  491. CTEST(saxpby, c_api_inc_x_2_inc_y_neg_1_N_100)
  492. {
  493. blasint n = DATASIZE, incx = 2, incy = -1;
  494. float alpha = 1.0f;
  495. float beta = 6.0f;
  496. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  497. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  498. }
  499. /**
  500. * C API specific test
  501. * Test saxpby by comparing it with sscal and saxpy.
  502. * Test with the following options:
  503. *
  504. * Size of vectors x, y is 100
  505. * Stride of vector x is -2
  506. * Stride of vector y is -1
  507. */
  508. CTEST(saxpby, c_api_inc_x_neg_2_inc_y_neg_1_N_100)
  509. {
  510. blasint n = DATASIZE, incx = -2, incy = -1;
  511. float alpha = 7.0f;
  512. float beta = 3.5f;
  513. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  514. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  515. }
  516. /**
  517. * C API specific test
  518. * Test saxpby by comparing it with sscal and saxpy.
  519. * Test with the following options:
  520. *
  521. * Size of vectors x, y is 100
  522. * Stride of vector x is 1
  523. * Stride of vector y is 1
  524. * Scalar alpha is zero
  525. */
  526. CTEST(saxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_zero)
  527. {
  528. blasint n = DATASIZE, incx = 1, incy = 1;
  529. float alpha = 0.0f;
  530. float beta = 1.0f;
  531. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  532. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  533. }
  534. /**
  535. * C API specific test
  536. * Test saxpby by comparing it with sscal and saxpy.
  537. * Test with the following options:
  538. *
  539. * Size of vectors x, y is 100
  540. * Stride of vector x is 1
  541. * Stride of vector y is 2
  542. * Scalar alpha is zero
  543. */
  544. CTEST(saxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_zero)
  545. {
  546. blasint n = DATASIZE, incx = 1, incy = 2;
  547. float alpha = 0.0f;
  548. float beta = 1.0f;
  549. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  550. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  551. }
  552. /**
  553. * C API specific test
  554. * Test saxpby by comparing it with sscal and saxpy.
  555. * Test with the following options:
  556. *
  557. * Size of vectors x, y is 100
  558. * Stride of vector x is 1
  559. * Stride of vector y is 1
  560. * Scalar beta is zero
  561. */
  562. CTEST(saxpby, c_api_inc_x_1_inc_y_1_N_100_beta_zero)
  563. {
  564. blasint n = DATASIZE, incx = 1, incy = 1;
  565. float alpha = 1.0f;
  566. float beta = 0.0f;
  567. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  568. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  569. }
  570. /**
  571. * C API specific test
  572. * Test saxpby by comparing it with sscal and saxpy.
  573. * Test with the following options:
  574. *
  575. * Size of vectors x, y is 100
  576. * Stride of vector x is 2
  577. * Stride of vector y is 1
  578. * Scalar beta is zero
  579. */
  580. CTEST(saxpby, c_api_inc_x_2_inc_y_1_N_100_beta_zero)
  581. {
  582. blasint n = DATASIZE, incx = 2, incy = 1;
  583. float alpha = 1.0f;
  584. float beta = 0.0f;
  585. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  586. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  587. }
  588. /**
  589. * C API specific test
  590. * Test saxpby by comparing it with sscal and saxpy.
  591. * Test with the following options:
  592. *
  593. * Size of vectors x, y is 100
  594. * Stride of vector x is 1
  595. * Stride of vector y is 2
  596. * Scalar beta is zero
  597. */
  598. CTEST(saxpby, c_api_inc_x_1_inc_y_2_N_100_beta_zero)
  599. {
  600. blasint n = DATASIZE, incx = 1, incy = 2;
  601. float alpha = 1.0f;
  602. float beta = 0.0f;
  603. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  604. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  605. }
  606. /**
  607. * C API specific test
  608. * Test saxpby by comparing it with sscal and saxpy.
  609. * Test with the following options:
  610. *
  611. * Size of vectors x, y is 100
  612. * Stride of vector x is 2
  613. * Stride of vector y is 2
  614. * Scalar beta is zero
  615. */
  616. CTEST(saxpby, c_api_inc_x_2_inc_y_2_N_100_beta_zero)
  617. {
  618. blasint n = DATASIZE, incx = 2, incy = 2;
  619. float alpha = 1.0f;
  620. float beta = 0.0f;
  621. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  622. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  623. }
  624. /**
  625. * C API specific test
  626. * Test saxpby by comparing it with sscal and saxpy.
  627. * Test with the following options:
  628. *
  629. * Size of vectors x, y is 100
  630. * Stride of vector x is 1
  631. * Stride of vector y is 1
  632. * Scalar alpha is zero
  633. * Scalar beta is zero
  634. */
  635. CTEST(saxpby, c_api_inc_x_1_inc_y_1_N_100_alpha_beta_zero)
  636. {
  637. blasint n = DATASIZE, incx = 1, incy = 1;
  638. float alpha = 0.0f;
  639. float beta = 0.0f;
  640. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  641. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  642. }
  643. /**
  644. * C API specific test
  645. * Test saxpby by comparing it with sscal and saxpy.
  646. * Test with the following options:
  647. *
  648. * Size of vectors x, y is 100
  649. * Stride of vector x is 1
  650. * Stride of vector y is 2
  651. * Scalar alpha is zero
  652. * Scalar beta is zero
  653. */
  654. CTEST(saxpby, c_api_inc_x_1_inc_y_2_N_100_alpha_beta_zero)
  655. {
  656. blasint n = DATASIZE, incx = 1, incy = 2;
  657. float alpha = 0.0f;
  658. float beta = 0.0f;
  659. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  660. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  661. }
  662. /**
  663. * C API specific test
  664. * Check if n - size of vectors x, y is zero
  665. */
  666. CTEST(saxpby, c_api_check_n_zero)
  667. {
  668. blasint n = 0, incx = 1, incy = 1;
  669. float alpha = 1.0f;
  670. float beta = 1.0f;
  671. float norm = c_api_check_saxpby(n, alpha, incx, beta, incy);
  672. ASSERT_DBL_NEAR_TOL(0.0f, norm, SINGLE_EPS);
  673. }
  674. #endif
  675. #endif