This example showcases the usage of hipBLAS' Level 1 SCAL function. The Level 1 API defines operations between vector and vector. SCAL is a scaling operator for an
- Read in and parse command line parameters.
- Allocate and initialize host vector.
- Compute CPU reference result.
- Create a hipBLAS handle.
- Allocate and initialize device vector.
- Use the hipBLAS handle to enable passing the
$a$ scaling parameter via a pointer to host memory. - Call hipBLAS' SCAL function.
- Copy the result from device to host.
- Destroy the hipBLAS 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 SCAL operation. Its default value is 3. -
-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. -
-n
or--n
. The number of elements in vector$x$ , must be greater than zero. Its default value is 5.
- hipBLAS is initialized by calling
hipblasCreate(hipblasHandle_t *handle)
and it is terminated by callinghipblasDestroy(hipblasHandle_t handle)
. - The pointer mode controls whether scalar parameters must be allocated on the host (
HIPBLAS_POINTER_MODE_HOST
) or on the device (HIPBLAS_POINTER_MODE_DEVICE
). It is controlled byhipblasSetPointerMode
. hipblas[SDCZ]scal
multiplies each element of the vector by a scalar. Depending on the character matched in[SDCZ]
, the scaling can be obtained with different precisions:S
(single-precision:float
)D
(double-precision:double
)C
(single-precision complex:hipblasComplex
)Z
(double-precision complex:hipblasDoubleComplex
).
hipblasCreate
hipblasDestroy
hipblasHandle_t
hipblasSetPointerMode
HIPBLAS_POINTER_MODE_HOST
hipblasSscal
hipFree
hipMalloc
hipMemcpy
hipMemcpyDeviceToHost
hipMemcpyHostToDevice