34 template<
typename ScalarType>
37 if (s1 > s2 || s1 < s2)
38 return (s1 - s2) /
std::max(static_cast<ScalarType>(std::fabs(static_cast<double>(s1))),
39 static_cast<ScalarType>(std::fabs(static_cast<double>(s2))));
43 template<
typename ScalarType,
typename ViennaCLVectorType>
44 ScalarType diff(std::vector<ScalarType>
const &
v1, ViennaCLVectorType
const & vcl_vec)
46 std::vector<ScalarType> v2_cpu(vcl_vec.size());
51 for (
unsigned int i=0;i<v1.size(); ++i)
53 if (
std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) ) > 0 )
54 v2_cpu[i] = std::fabs(v2_cpu[i] - v1[i]) /
std::max( std::fabs(v2_cpu[i]), std::fabs(v1[i]) );
58 if (v2_cpu[i] > inf_norm)
65 template<
typename T,
typename U,
typename EpsilonT>
66 void check(T
const & t, U
const & u, EpsilonT eps)
68 EpsilonT rel_error = std::fabs(static_cast<EpsilonT>(
diff(t,u)));
71 std::cerr <<
"Relative error: " << rel_error << std::endl;
72 std::cerr <<
"Aborting!" << std::endl;
75 std::cout <<
"SUCCESS ";
80 std::size_t
size = 10;
81 float eps_float = 1e-5f;
82 double eps_double = 1e-12;
84 float ref_float_alpha;
85 double ref_double_alpha;
87 std::vector<float> ref_float_x(size, 1.0f);
88 std::vector<float> ref_float_y(size, 2.0f);
90 std::vector<double> ref_double_x(size, 1.0);
91 std::vector<double> ref_double_y(size, 2.0);
97 float host_float_alpha = 0;
101 double host_double_alpha = 0;
106 #ifdef VIENNACL_WITH_CUDA
107 float cuda_float_alpha = 0;
111 double cuda_double_alpha = 0;
117 #ifdef VIENNACL_WITH_OPENCL
119 float opencl_float_alpha = 0;
123 double opencl_double_alpha = 0;
136 check(ref_float_x, host_float_x, eps_float);
137 check(ref_float_y, host_float_y, eps_float);
138 check(ref_double_x, host_double_x, eps_double);
139 check(ref_double_y, host_double_y, eps_double);
140 #ifdef VIENNACL_WITH_CUDA
141 check(ref_float_x, cuda_float_x, eps_float);
142 check(ref_float_y, cuda_float_y, eps_float);
143 check(ref_double_x, cuda_double_x, eps_double);
144 check(ref_double_y, cuda_double_y, eps_double);
146 #ifdef VIENNACL_WITH_OPENCL
147 check(ref_float_x, opencl_float_x, eps_float);
148 check(ref_float_y, opencl_float_y, eps_float);
151 check(ref_double_x, *opencl_double_x, eps_double);
152 check(ref_double_y, *opencl_double_y, eps_double);
157 std::cout << std::endl <<
"-- Testing xASUM...";
159 ref_double_alpha = 0;
160 for (std::size_t i=0; i<size/4; ++i)
162 ref_float_alpha += std::fabs(ref_float_x[2 + 3*i]);
163 ref_double_alpha += std::fabs(ref_double_x[2 + 3*i]);
166 std::cout << std::endl <<
"Host: ";
169 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 2, 3);
170 check(ref_float_alpha, host_float_alpha, eps_float);
173 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 2, 3);
174 check(ref_double_alpha, host_double_alpha, eps_double);
177 #ifdef VIENNACL_WITH_CUDA
178 std::cout << std::endl <<
"CUDA: ";
182 check(ref_float_alpha, cuda_float_alpha, eps_float);
186 check(ref_double_alpha, cuda_double_alpha, eps_double);
189 #ifdef VIENNACL_WITH_OPENCL
190 std::cout << std::endl <<
"OpenCL: ";
191 ViennaCLOpenCLSasum(my_backend,
ViennaCLInt(size/4),
193 viennacl::traits::opencl_handle(opencl_float_x).
get(), 2, 3);
194 check(ref_float_alpha, opencl_float_alpha, eps_float);
197 ViennaCLOpenCLDasum(my_backend,
ViennaCLInt(size/4),
198 &opencl_double_alpha,
199 viennacl::traits::opencl_handle(*opencl_double_x).get(), 2, 3);
200 check(ref_double_alpha, opencl_double_alpha, eps_double);
207 std::cout << std::endl <<
"-- Testing xAXPY...";
208 for (std::size_t i=0; i<size/3; ++i)
210 ref_float_y[1 + 2*i] += 2.0f * ref_float_x[0 + 2*i];
211 ref_double_y[1 + 2*i] += 2.0 * ref_double_x[0 + 2*i];
214 std::cout << std::endl <<
"Host: ";
217 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 0, 2,
218 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_y), 1, 2);
219 check(ref_float_x, host_float_x, eps_float);
220 check(ref_float_y, host_float_y, eps_float);
223 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 0, 2,
224 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_y), 1, 2);
225 check(ref_double_x, host_double_x, eps_double);
226 check(ref_double_y, host_double_y, eps_double);
229 #ifdef VIENNACL_WITH_CUDA
230 std::cout << std::endl <<
"CUDA: ";
235 check(ref_float_x, cuda_float_x, eps_float);
236 check(ref_float_y, cuda_float_y, eps_float);
241 check(ref_double_x, cuda_double_x, eps_double);
242 check(ref_double_y, cuda_double_y, eps_double);
245 #ifdef VIENNACL_WITH_OPENCL
246 std::cout << std::endl <<
"OpenCL: ";
247 ViennaCLOpenCLSaxpy(my_backend,
ViennaCLInt(size/3),
249 viennacl::traits::opencl_handle(opencl_float_x).
get(), 0, 2,
250 viennacl::traits::opencl_handle(opencl_float_y).
get(), 1, 2);
251 check(ref_float_x, opencl_float_x, eps_float);
252 check(ref_float_y, opencl_float_y, eps_float);
255 ViennaCLOpenCLDaxpy(my_backend,
ViennaCLInt(size/3),
257 viennacl::traits::opencl_handle(*opencl_double_x).get(), 0, 2,
258 viennacl::traits::opencl_handle(*opencl_double_y).get(), 1, 2);
259 check(ref_double_x, *opencl_double_x, eps_double);
260 check(ref_double_y, *opencl_double_y, eps_double);
267 std::cout << std::endl <<
"-- Testing xCOPY...";
268 for (std::size_t i=0; i<size/3; ++i)
270 ref_float_y[0 + 2*i] = ref_float_x[1 + 2*i];
271 ref_double_y[0 + 2*i] = ref_double_x[1 + 2*i];
274 std::cout << std::endl <<
"Host: ";
276 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 1, 2,
277 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_y), 0, 2);
278 check(ref_float_x, host_float_x, eps_float);
279 check(ref_float_y, host_float_y, eps_float);
281 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 1, 2,
282 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_y), 0, 2);
283 check(ref_double_x, host_double_x, eps_double);
284 check(ref_double_y, host_double_y, eps_double);
287 #ifdef VIENNACL_WITH_CUDA
288 std::cout << std::endl <<
"CUDA: ";
292 check(ref_float_x, cuda_float_x, eps_float);
293 check(ref_float_y, cuda_float_y, eps_float);
297 check(ref_double_x, cuda_double_x, eps_double);
298 check(ref_double_y, cuda_double_y, eps_double);
301 #ifdef VIENNACL_WITH_OPENCL
302 std::cout << std::endl <<
"OpenCL: ";
303 ViennaCLOpenCLScopy(my_backend,
ViennaCLInt(size/3),
304 viennacl::traits::opencl_handle(opencl_float_x).
get(), 1, 2,
305 viennacl::traits::opencl_handle(opencl_float_y).
get(), 0, 2);
306 check(ref_float_x, opencl_float_x, eps_float);
307 check(ref_float_y, opencl_float_y, eps_float);
310 ViennaCLOpenCLDcopy(my_backend,
ViennaCLInt(size/3),
311 viennacl::traits::opencl_handle(*opencl_double_x).get(), 1, 2,
312 viennacl::traits::opencl_handle(*opencl_double_y).get(), 0, 2);
313 check(ref_double_x, *opencl_double_x, eps_double);
314 check(ref_double_y, *opencl_double_y, eps_double);
321 std::cout << std::endl <<
"-- Testing xDOT...";
323 ref_double_alpha = 0;
324 for (std::size_t i=0; i<size/2; ++i)
326 ref_float_alpha += ref_float_y[3 + i] * ref_float_x[2 + i];
327 ref_double_alpha += ref_double_y[3 + i] * ref_double_x[2 + i];
330 std::cout << std::endl <<
"Host: ";
333 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 2, 1,
334 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_y), 3, 1);
335 check(ref_float_alpha, host_float_alpha, eps_float);
338 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 2, 1,
339 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_y), 3, 1);
340 check(ref_double_alpha, host_double_alpha, eps_double);
343 #ifdef VIENNACL_WITH_CUDA
344 std::cout << std::endl <<
"CUDA: ";
349 check(ref_float_alpha, cuda_float_alpha, eps_float);
354 check(ref_double_alpha, cuda_double_alpha, eps_double);
357 #ifdef VIENNACL_WITH_OPENCL
358 std::cout << std::endl <<
"OpenCL: ";
359 ViennaCLOpenCLSdot(my_backend,
ViennaCLInt(size/2),
361 viennacl::traits::opencl_handle(opencl_float_x).
get(), 2, 1,
362 viennacl::traits::opencl_handle(opencl_float_y).
get(), 3, 1);
363 check(ref_float_alpha, opencl_float_alpha, eps_float);
366 ViennaCLOpenCLDdot(my_backend,
ViennaCLInt(size/2),
367 &opencl_double_alpha,
368 viennacl::traits::opencl_handle(*opencl_double_x).get(), 2, 1,
369 viennacl::traits::opencl_handle(*opencl_double_y).get(), 3, 1);
370 check(ref_double_alpha, opencl_double_alpha, eps_double);
377 std::cout << std::endl <<
"-- Testing xNRM2...";
379 ref_double_alpha = 0;
380 for (std::size_t i=0; i<size/3; ++i)
382 ref_float_alpha += ref_float_x[1 + 2*i] * ref_float_x[1 + 2*i];
383 ref_double_alpha += ref_double_x[1 + 2*i] * ref_double_x[1 + 2*i];
385 ref_float_alpha = std::sqrt(ref_float_alpha);
386 ref_double_alpha = std::sqrt(ref_double_alpha);
388 std::cout << std::endl <<
"Host: ";
391 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 1, 2);
392 check(ref_float_alpha, host_float_alpha, eps_float);
395 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 1, 2);
396 check(ref_double_alpha, host_double_alpha, eps_double);
399 #ifdef VIENNACL_WITH_CUDA
400 std::cout << std::endl <<
"CUDA: ";
404 check(ref_float_alpha, cuda_float_alpha, eps_float);
408 check(ref_double_alpha, cuda_double_alpha, eps_double);
411 #ifdef VIENNACL_WITH_OPENCL
412 std::cout << std::endl <<
"OpenCL: ";
413 ViennaCLOpenCLSnrm2(my_backend,
ViennaCLInt(size/3),
415 viennacl::traits::opencl_handle(opencl_float_x).
get(), 1, 2);
416 check(ref_float_alpha, opencl_float_alpha, eps_float);
419 ViennaCLOpenCLDnrm2(my_backend,
ViennaCLInt(size/3),
420 &opencl_double_alpha,
421 viennacl::traits::opencl_handle(*opencl_double_x).get(), 1, 2);
422 check(ref_double_alpha, opencl_double_alpha, eps_double);
430 std::cout << std::endl <<
"-- Testing xROT...";
431 for (std::size_t i=0; i<size/4; ++i)
433 float tmp = 0.6f * ref_float_x[2 + 3*i] + 0.8f * ref_float_y[1 + 2*i];
434 ref_float_y[1 + 2*i] = -0.8f * ref_float_x[2 + 3*i] + 0.6f * ref_float_y[1 + 2*i];;
435 ref_float_x[2 + 3*i] = tmp;
437 double tmp2 = 0.6 * ref_double_x[2 + 3*i] + 0.8 * ref_double_y[1 + 2*i];
438 ref_double_y[1 + 2*i] = -0.8 * ref_double_x[2 + 3*i] + 0.6 * ref_double_y[1 + 2*i];;
439 ref_double_x[2 + 3*i] = tmp2;
442 std::cout << std::endl <<
"Host: ";
444 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 2, 3,
445 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_y), 1, 2,
447 check(ref_float_x, host_float_x, eps_float);
448 check(ref_float_y, host_float_y, eps_float);
450 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 2, 3,
451 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_y), 1, 2,
453 check(ref_double_x, host_double_x, eps_double);
454 check(ref_double_y, host_double_y, eps_double);
457 #ifdef VIENNACL_WITH_CUDA
458 std::cout << std::endl <<
"CUDA: ";
463 check(ref_float_x, cuda_float_x, eps_float);
464 check(ref_float_y, cuda_float_y, eps_float);
469 check(ref_double_x, cuda_double_x, eps_double);
470 check(ref_double_y, cuda_double_y, eps_double);
473 #ifdef VIENNACL_WITH_OPENCL
474 std::cout << std::endl <<
"OpenCL: ";
475 ViennaCLOpenCLSrot(my_backend,
ViennaCLInt(size/4),
476 viennacl::traits::opencl_handle(opencl_float_x).
get(), 2, 3,
477 viennacl::traits::opencl_handle(opencl_float_y).
get(), 1, 2,
479 check(ref_float_x, opencl_float_x, eps_float);
480 check(ref_float_y, opencl_float_y, eps_float);
483 ViennaCLOpenCLDrot(my_backend,
ViennaCLInt(size/4),
484 viennacl::traits::opencl_handle(*opencl_double_x).get(), 2, 3,
485 viennacl::traits::opencl_handle(*opencl_double_y).get(), 1, 2,
487 check(ref_double_x, *opencl_double_x, eps_double);
488 check(ref_double_y, *opencl_double_y, eps_double);
495 std::cout << std::endl <<
"-- Testing xSCAL...";
496 for (std::size_t i=0; i<size/4; ++i)
498 ref_float_x[1 + 3*i] *= 2.0f;
499 ref_double_x[1 + 3*i] *= 2.0;
502 std::cout << std::endl <<
"Host: ";
505 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 1, 3);
506 check(ref_float_x, host_float_x, eps_float);
509 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 1, 3);
510 check(ref_double_x, host_double_x, eps_double);
512 #ifdef VIENNACL_WITH_CUDA
513 std::cout << std::endl <<
"CUDA: ";
517 check(ref_float_x, cuda_float_x, eps_float);
521 check(ref_double_x, cuda_double_x, eps_double);
524 #ifdef VIENNACL_WITH_OPENCL
525 std::cout << std::endl <<
"OpenCL: ";
526 ViennaCLOpenCLSscal(my_backend,
ViennaCLInt(size/4),
528 viennacl::traits::opencl_handle(opencl_float_x).
get(), 1, 3);
529 check(ref_float_x, opencl_float_x, eps_float);
532 ViennaCLOpenCLDscal(my_backend,
ViennaCLInt(size/4),
534 viennacl::traits::opencl_handle(*opencl_double_x).get(), 1, 3);
535 check(ref_double_x, *opencl_double_x, eps_double);
541 std::cout << std::endl <<
"-- Testing xSWAP...";
542 for (std::size_t i=0; i<size/3; ++i)
544 float tmp = ref_float_x[2 + 2*i];
545 ref_float_x[2 + 2*i] = ref_float_y[1 + 2*i];
546 ref_float_y[1 + 2*i] = tmp;
548 double tmp2 = ref_double_x[2 + 2*i];
549 ref_double_x[2 + 2*i] = ref_double_y[1 + 2*i];
550 ref_double_y[1 + 2*i] = tmp2;
553 std::cout << std::endl <<
"Host: ";
555 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 2, 2,
556 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_y), 1, 2);
557 check(ref_float_y, host_float_y, eps_float);
559 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 2, 2,
560 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_y), 1, 2);
561 check(ref_double_y, host_double_y, eps_double);
564 #ifdef VIENNACL_WITH_CUDA
565 std::cout << std::endl <<
"CUDA: ";
569 check(ref_float_y, cuda_float_y, eps_float);
573 check(ref_double_y, cuda_double_y, eps_double);
576 #ifdef VIENNACL_WITH_OPENCL
577 std::cout << std::endl <<
"OpenCL: ";
578 ViennaCLOpenCLSswap(my_backend,
ViennaCLInt(size/3),
579 viennacl::traits::opencl_handle(opencl_float_x).
get(), 2, 2,
580 viennacl::traits::opencl_handle(opencl_float_y).
get(), 1, 2);
581 check(ref_float_y, opencl_float_y, eps_float);
584 ViennaCLOpenCLDswap(my_backend,
ViennaCLInt(size/3),
585 viennacl::traits::opencl_handle(*opencl_double_x).get(), 2, 2,
586 viennacl::traits::opencl_handle(*opencl_double_y).get(), 1, 2);
587 check(ref_double_y, *opencl_double_y, eps_double);
593 std::cout << std::endl <<
"-- Testing IxASUM...";
596 for (std::size_t i=0; i<size/3; ++i)
598 if (ref_float_x[0 + 2*i] > std::fabs(ref_float_alpha))
601 ref_float_alpha = std::fabs(ref_float_x[0 + 2*i]);
605 std::cout << std::endl <<
"Host: ";
609 viennacl::linalg::host_based::detail::extract_raw_pointer<float>(host_float_x), 0, 2);
610 check(static_cast<float>(ref_index), static_cast<float>(idx), eps_float);
614 viennacl::linalg::host_based::detail::extract_raw_pointer<double>(host_double_x), 0, 2);
615 check(ref_index, idx, eps_double);
617 #ifdef VIENNACL_WITH_CUDA
618 std::cout << std::endl <<
"CUDA: ";
623 check(ref_float_x[2*ref_index], ref_float_x[2*idx], eps_float);
628 check(ref_double_x[2*ref_index], ref_double_x[2*idx], eps_double);
631 #ifdef VIENNACL_WITH_OPENCL
632 std::cout << std::endl <<
"OpenCL: ";
634 ViennaCLOpenCLiSamax(my_backend,
ViennaCLInt(size/3),
636 viennacl::traits::opencl_handle(opencl_float_x).
get(), 0, 2);
637 check(ref_float_x[2*static_cast<std::size_t>(ref_index)], ref_float_x[2*static_cast<std::size_t>(idx)], eps_float);
641 ViennaCLOpenCLiDamax(my_backend,
ViennaCLInt(size/3),
643 viennacl::traits::opencl_handle(*opencl_double_x).get(), 0, 2);
644 check(ref_double_x[2*static_cast<std::size_t>(ref_index)], ref_double_x[2*static_cast<std::size_t>(idx)], eps_double);
648 #ifdef VIENNACL_WITH_OPENCL
652 delete opencl_double_x;
653 delete opencl_double_y;
662 std::cout << std::endl <<
"!!!! TEST COMPLETED SUCCESSFULLY !!!!" << std::endl;
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDaxpy(ViennaCLBackend backend, ViennaCLInt n, double alpha, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSscal(ViennaCLBackend backend, ViennaCLInt n, float alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLBackendCreate(ViennaCLBackend *backend)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostScopy(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
Generic backend for CUDA, OpenCL, host-based stuff.
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDrot(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy, double c, double s)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDdot(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADscal(ViennaCLBackend backend, ViennaCLInt n, double alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADdot(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADnrm2(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDscal(ViennaCLBackend backend, ViennaCLInt n, double alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
void finish()
Synchronizes the execution. finish() will only return after all compute kernels (CUDA, OpenCL) have completed.
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLBackendSetOpenCLContextID(ViennaCLBackend backend, ViennaCLInt context_id)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDnrm2(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSswap(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDcopy(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSdot(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
viennacl::scalar< int > s2
viennacl::scalar< float > s1
T max(const T &lhs, const T &rhs)
Maximum.
viennacl::ocl::device const & current_device()
Convenience function for returning the active device in the current context.
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASasum(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASnrm2(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDswap(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
viennacl::vector< float > v1
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostiDamax(ViennaCLBackend backend, ViennaCLInt n, ViennaCLInt *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
vcl_size_t size(VectorType const &vec)
Generic routine for obtaining the size of a vector (ViennaCL, uBLAS, etc.)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASscal(ViennaCLBackend backend, ViennaCLInt n, float alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSrot(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy, float c, float s)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLBackendDestroy(ViennaCLBackend *backend)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASswap(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASaxpy(ViennaCLBackend backend, ViennaCLInt n, float alpha, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
bool double_support() const
ViennaCL convenience function: Returns true if the device supports double precision.
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASrot(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy, float c, float s)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADaxpy(ViennaCLBackend backend, ViennaCLInt n, double alpha, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADswap(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDASdot(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
viennacl::context context(T const &t)
Returns an ID for the currently active memory domain of an object.
The vector type with operator-overloads and proxy classes is defined here. Linear algebra operations ...
Represents a vector consisting of scalars 's' only, i.e. v[i] = s for all i. To be used as an initial...
void copy(std::vector< NumericT > &cpu_vec, circulant_matrix< NumericT, AlignmentV > &gpu_mat)
Copies a circulant matrix from the std::vector to the OpenCL device (either GPU or multi-core CPU) ...
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSasum(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADasum(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSaxpy(ViennaCLBackend backend, ViennaCLInt n, float alpha, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostSnrm2(ViennaCLBackend backend, ViennaCLInt n, float *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADrot(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy, double c, double s)
void check(T const &t, U const &u, EpsilonT eps)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDAiSamax(ViennaCLBackend backend, ViennaCLInt n, ViennaCLInt *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
NumericT * cuda_arg(scalar< NumericT > &obj)
Convenience helper function for extracting the CUDA handle from a ViennaCL scalar. Non-const version.
viennacl::ocl::context & get_context(long i)
Convenience function for returning the current context.
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostiSamax(ViennaCLBackend backend, ViennaCLInt n, ViennaCLInt *alpha, float *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDAScopy(ViennaCLBackend backend, ViennaCLInt n, float *x, ViennaCLInt offx, ViennaCLInt incx, float *y, ViennaCLInt offy, ViennaCLInt incy)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLHostDasum(ViennaCLBackend backend, ViennaCLInt n, double *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDAiDamax(ViennaCLBackend backend, ViennaCLInt n, ViennaCLInt *alpha, double *x, ViennaCLInt offx, ViennaCLInt incx)
VIENNACL_EXPORTED_FUNCTION ViennaCLStatus ViennaCLCUDADcopy(ViennaCLBackend backend, ViennaCLInt n, double *x, ViennaCLInt offx, ViennaCLInt incx, double *y, ViennaCLInt offy, ViennaCLInt incy)
ScalarType diff(ScalarType const &s1, ScalarType const &s2)