12#ifndef _CU_BASIC_ALGEBRA_CU_VECTOR_OPERATIONS_H_
13#define _CU_BASIC_ALGEBRA_CU_VECTOR_OPERATIONS_H_
19#include "../_definitions/types.h"
23 #pragma warning(push, 0)
24 #include <cublas_v2.h>
26#elif defined(__INTEL_LLVM_COMPILER) || defined(__INTEL_COMPILER)
27 #pragma warning(push, 0)
28 #include <cublas_v2.h>
30#elif defined(__GNUC__) || defined(__clang__)
31 #pragma GCC diagnostic push
32 #pragma GCC diagnostic ignored "-Wswitch-enum"
33 #include <cublas_v2.h>
34 #pragma GCC diagnostic pop
36 #include <cublas_v2.h>
41 #define RESTRICT __restrict
42#elif defined(__INTEL_COMPILER)
43 #define RESTRICT __restrict
44#elif defined(__CUDA__) || defined(__GNUC__) || defined(__clang__)
45 #define RESTRICT __restrict__
63template <
typename DataType>
70 cublasHandle_t cublas_handle,
71 const DataType*
RESTRICT input_vector,
77 cublasHandle_t cublas_handle,
78 const DataType*
RESTRICT input_vector,
85 cublasHandle_t cublas_handle,
86 const DataType*
RESTRICT input_vector,
93 cublasHandle_t cublas_handle,
100 cublasHandle_t cublas_handle,
106 cublasHandle_t cublas_handle,
112 cublasHandle_t cublas_handle,
A static class for vector operations, similar to level-1 operations of the BLAS library....
static DataType normalize_vector_in_place(cublasHandle_t cublas_handle, DataType *RESTRICT vector, const LongIndexType vector_size)
Normalizes a vector based on Euclidean 2-norm. The result is written in-place.
static void copy_scaled_vector(cublasHandle_t cublas_handle, const DataType *RESTRICT input_vector, const LongIndexType vector_size, const DataType scale, DataType *RESTRICT output_vector)
Scales a vector and stores to a new vector.
static void subtract_scaled_vector(cublasHandle_t cublas_handle, const DataType *RESTRICT input_vector, const LongIndexType vector_size, const DataType scale, DataType *RESTRICT output_vector)
Subtracts the scaled input vector from the output vector.
static DataType normalize_vector_and_copy(cublasHandle_t cublas_handle, const DataType *RESTRICT vector, const LongIndexType vector_size, DataType *RESTRICT output_vector)
Normalizes a vector based on Euclidean 2-norm. The result is written into another vector.
static void copy_vector(cublasHandle_t cublas_handle, const DataType *RESTRICT input_vector, const LongIndexType vector_size, DataType *RESTRICT output_vector)
Copies a vector to a new vector. Result is written in-place.
static DataType inner_product(cublasHandle_t cublas_handle, const DataType *RESTRICT vector1, const DataType *RESTRICT vector2, const LongIndexType vector_size)
Computes Euclidean inner product of two vectors.
static DataType euclidean_norm(cublasHandle_t cublas_handle, const DataType *RESTRICT vector, const LongIndexType vector_size)
Computes the Euclidean 2-norm of a 1D array.