Skip to content

Commit 507c8ff

Browse files
authored
Add float copy function in blas connector (#6625)
1 parent 9b2ee21 commit 507c8ff

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

source/source_base/module_external/blas_connector.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ extern "C"
2424
void caxpy_(const int *N, const std::complex<float> *alpha, const std::complex<float> *X, const int *incX, std::complex<float> *Y, const int *incY);
2525
void zaxpy_(const int *N, const std::complex<double> *alpha, const std::complex<double> *X, const int *incX, std::complex<double> *Y, const int *incY);
2626

27+
void scopy_(long const *n, const float *a, int const *incx, float *b, int const *incy);
2728
void dcopy_(long const *n, const double *a, int const *incx, double *b, int const *incy);
29+
void ccopy_(long const *n, const std::complex<float> *a, int const *incx, std::complex<float> *b, int const *incy);
2830
void zcopy_(long const *n, const std::complex<double> *a, int const *incx, std::complex<double> *b, int const *incy);
2931

3032
//reason for passing results as argument instead of returning it:
@@ -340,6 +342,12 @@ class BlasConnector
340342
static
341343
void copy(const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
342344

345+
static
346+
void copy(const long n, const float *a, const int incx, float *b, const int incy, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
347+
348+
static
349+
void copy(const long n, const std::complex<float> *a, const int incx, std::complex<float> *b, const int incy, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
350+
343351
static
344352
void copy(const long n, const std::complex<double> *a, const int incx, std::complex<double> *b, const int incy, base_device::AbacusDevice_t device_type = base_device::AbacusDevice_t::CpuDevice);
345353

source/source_base/module_external/blas_connector_vector.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,16 @@ double BlasConnector::nrm2( const int n, const std::complex<double> *X, const in
322322
}
323323

324324
// copies a into b
325+
void BlasConnector::copy(const long n, const float *a, const int incx, float *b, const int incy, base_device::AbacusDevice_t device_type)
326+
{
327+
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
328+
scopy_(&n, a, &incx, b, &incy);
329+
}
330+
else {
331+
throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__));
332+
}
333+
}
334+
325335
void BlasConnector::copy(const long n, const double *a, const int incx, double *b, const int incy, base_device::AbacusDevice_t device_type)
326336
{
327337
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
@@ -332,6 +342,16 @@ void BlasConnector::copy(const long n, const double *a, const int incx, double *
332342
}
333343
}
334344

345+
void BlasConnector::copy(const long n, const std::complex<float> *a, const int incx, std::complex<float> *b, const int incy, base_device::AbacusDevice_t device_type)
346+
{
347+
if (device_type == base_device::AbacusDevice_t::CpuDevice) {
348+
ccopy_(&n, a, &incx, b, &incy);
349+
}
350+
else {
351+
throw std::invalid_argument("device_type = " + std::to_string(device_type) + " in " + std::string(__FILE__) + " line " + std::to_string(__LINE__));
352+
}
353+
}
354+
335355
void BlasConnector::copy(const long n, const std::complex<double> *a, const int incx, std::complex<double> *b, const int incy, base_device::AbacusDevice_t device_type)
336356
{
337357
if (device_type == base_device::AbacusDevice_t::CpuDevice) {

0 commit comments

Comments
 (0)