pub struct API;
Expand description
Defines the cuBLAS API.
Implementations§
source§impl API
impl API
sourcepub fn asum(
context: &Context,
x: *mut f32,
result: *mut f32,
n: i32,
stride: Option<i32>
) -> Result<(), Error>
pub fn asum( context: &Context, x: *mut f32, result: *mut f32, n: i32, stride: Option<i32> ) -> Result<(), Error>
Compute the sum of magnitudes of the provided vector elements.
x
: pointer to input vector.
result
: pointer to output scalar.
n
: number of elements to compute sum over (should not be greater than x
).
stride
: offset from one input element to the next. Defaults to 1
.
sourcepub fn axpy(
context: &Context,
alpha: *mut f32,
x: *mut f32,
y: *mut f32,
n: i32,
stride_x: Option<i32>,
stride_y: Option<i32>
) -> Result<(), Error>
pub fn axpy( context: &Context, alpha: *mut f32, x: *mut f32, y: *mut f32, n: i32, stride_x: Option<i32>, stride_y: Option<i32> ) -> Result<(), Error>
Computes a vector-scalar product and adds the result to a vector.
alpha
: pointer to input scalar.
x
: pointer to input vector.
y
: pointer to output vector.
n
: number of elements to use for operation (should not be greater than number of elements in x
or y
).
stride_x
: offset from one element in x to the next. Defaults to 1
.
stride_y
: offset from one element in y to the next. Defaults to 1
.
sourcepub fn copy(
context: &Context,
x: *mut f32,
y: *mut f32,
n: i32,
stride_x: Option<i32>,
stride_y: Option<i32>
) -> Result<(), Error>
pub fn copy( context: &Context, x: *mut f32, y: *mut f32, n: i32, stride_x: Option<i32>, stride_y: Option<i32> ) -> Result<(), Error>
Copies a vector into another vector.
x
: pointer to input vector.
y
: pointer to output vector.
n
: number of elements to use for operation (should not be greater than number of elements in x
or y
).
stride_x
: offset from one element in x to the next. Defaults to 1
.
stride_y
: offset from one element in y to the next. Defaults to 1
.
sourcepub fn dot(
context: &Context,
x: *mut f32,
y: *mut f32,
result: *mut f32,
n: i32,
stride_x: Option<i32>,
stride_y: Option<i32>
) -> Result<(), Error>
pub fn dot( context: &Context, x: *mut f32, y: *mut f32, result: *mut f32, n: i32, stride_x: Option<i32>, stride_y: Option<i32> ) -> Result<(), Error>
TODO: DOC
sourcepub fn nrm2(
context: &Context,
x: *mut f32,
result: *mut f32,
n: i32,
stride_x: Option<i32>
) -> Result<(), Error>
pub fn nrm2( context: &Context, x: *mut f32, result: *mut f32, n: i32, stride_x: Option<i32> ) -> Result<(), Error>
TODO: DOC
source§impl API
impl API
sourcepub fn gemm(
context: &Context,
transa: Operation,
transb: Operation,
m: i32,
n: i32,
k: i32,
alpha: *mut f32,
a: *mut f32,
lda: i32,
b: *mut f32,
ldb: i32,
beta: *mut f32,
c: *mut f32,
ldc: i32
) -> Result<(), Error>
pub fn gemm( context: &Context, transa: Operation, transb: Operation, m: i32, n: i32, k: i32, alpha: *mut f32, a: *mut f32, lda: i32, b: *mut f32, ldb: i32, beta: *mut f32, c: *mut f32, ldc: i32 ) -> Result<(), Error>
Performs a general matrix-matrix multiplication.
Note: the matrices are expected to be ordered column-major (FORTRAN-style).
source§impl API
impl API
sourcepub fn create() -> Result<Context, Error>
pub fn create() -> Result<Context, Error>
Create a new cuBLAS context, allocating resources on the host and the GPU.
The returned Context must be provided to future cuBLAS calls. Creating contexts all the time can lead to performance problems. Generally one Context per GPU device and configuration is recommended.
sourcepub unsafe fn destroy(context: &mut Context) -> Result<(), Error>
pub unsafe fn destroy(context: &mut Context) -> Result<(), Error>
Destroys the cuBLAS context, freeing its resources.
Should generally not be called directly. Automatically called when dropping a Context.
§Safety
Instructs CUDA to remove the cuBLAS handle, causing any further instructions to fail. This should be called at the end of using cuBLAS and should ideally be handled by drop exclusively, and never called by the user.
sourcepub fn get_pointer_mode(context: &Context) -> Result<PointerMode, Error>
pub fn get_pointer_mode(context: &Context) -> Result<PointerMode, Error>
Retrieve the pointer mode for a given cuBLAS context.
sourcepub fn set_pointer_mode(
context: &mut Context,
pointer_mode: PointerMode
) -> Result<(), Error>
pub fn set_pointer_mode( context: &mut Context, pointer_mode: PointerMode ) -> Result<(), Error>
Set the pointer mode for a given cuBLAS context.