This example showcases the usage of rocBLAS' Level 1 AXPY function. The Level 1 API defines operations between vector and vector. AXPY is the operation
- Read in command-line parameters.
- Allocate and initialize host vectors.
- Compute CPU reference result.
- Create a rocBLAS handle.
- Allocate and initialize device vectors.
- Use the rocBLAS handle to enable passing the
$a$ parameter via a pointer to host memory. - Call rocBLAS' AXPY function.
- Copy the result from device to host.
- Destroy the rocBLAS handle, release device memory.
- Validate the output by comparing it to the CPU reference result.
The application provides the following optional command line arguments:
-
-a
or--alpha
. The scalar value$a$ used in the AXPY operation. Its default value is 1. -
-x
or--incx
. The stride between consecutive values in the data array that makes up vector$x$ , must be greater than zero. Its default value is 1. -
-y
or--incy
. The stride between consecutive values in the data array that makes up vector$y$ , must be greater than zero. Its default value is 1. -
-n
or--n
. The number of elements in vectors$x$ and$y$ , must be greater than zero. Its default value is 5.
- rocBLAS is initialized by calling
rocblas_create_handle(rocblas_handle*)
and it is terminated by callingrocblas_destroy_handle(rocblas_handle)
. - The pointer mode controls whether scalar parameters must be allocated on the host (
rocblas_pointer_mode_host
) or on the device (rocblas_pointer_mode_device
). It is controlled byrocblas_set_pointer_mode
. rocblas_Xaxpy
computes the AXPY operation as defined above.X
is one ofs
(single-precision:rocblas_float
),d
(double-precision:rocblas_double
),h
(half-precision:rocblas_half
),c
(single-precision complex:rocblas_complex
), orz
(double-precision complex:rocblas_double_complex
).
rocblas_create_handle
rocblas_destroy_handle
rocblas_float
rocblas_handle
rocblas_int
rocblas_saxpy
rocblas_set_pointer_mode
rocblas_status
rocblas_status_success
rocblas_status_to_string
hipFree
hipMalloc
hipMemcpy
hipMemcpyDeviceToHost
hipMemcpyHostToDevice