@@ -374,133 +374,4 @@ double BlasConnector::nrm2( const int n, const std::complex<double> *X, const in
374374 else {
375375 throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
376376 }
377- }
378-
379- template <typename T>
380- void vector_mul_vector (const int & dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){
381- using Real = typename GetTypeReal<T>::type;
382- if (device_type == base_device::AbacusDevice_t::CpuDevice) {
383- #ifdef _OPENMP
384- #pragma omp parallel for schedule(static, 4096 / sizeof(Real))
385- #endif
386- for (int i = 0 ; i < dim; i++)
387- {
388- result[i] = vector1[i] * vector2[i];
389- }
390- }
391- #ifdef __CUDA
392- else if (device_type == base_device::AbacusDevice_t::GpuDevice) {
393- ModuleBase::vector_mul_vector_op<T, base_device::DEVICE_GPU>()(dim, result, vector1, vector2);
394- }
395- #endif
396- else {
397- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
398- }
399- }
400-
401-
402- template <typename T>
403- void vector_div_vector (const int & dim, T* result, const T* vector1, const T* vector2, base_device::AbacusDevice_t device_type){
404- using Real = typename GetTypeReal<T>::type;
405- if (device_type == base_device::AbacusDevice_t::CpuDevice) {
406- #ifdef _OPENMP
407- #pragma omp parallel for schedule(static, 4096 / sizeof(Real))
408- #endif
409- for (int i = 0 ; i < dim; i++)
410- {
411- result[i] = vector1[i] / vector2[i];
412- }
413- }
414- #ifdef __CUDA
415- else if (device_type == base_device::AbacusDevice_t::GpuDevice) {
416- ModuleBase::vector_div_vector_op<T, base_device::DEVICE_GPU>()(dim, result, vector1, vector2);
417- }
418- #endif
419- else {
420- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
421- }
422- }
423-
424- void vector_add_vector (const int & dim, float *result, const float *vector1, const float constant1, const float *vector2, const float constant2, base_device::AbacusDevice_t device_type)
425- {
426- if (device_type == base_device::CpuDevice){
427- #ifdef _OPENMP
428- #pragma omp parallel for schedule(static, 8192 / sizeof(float))
429- #endif
430- for (int i = 0 ; i < dim; i++)
431- {
432- result[i] = vector1[i] * constant1 + vector2[i] * constant2;
433- }
434- }
435- #ifdef __CUDA
436- else if (device_type == base_device::GpuDevice) {
437- ModuleBase::vector_add_vector_op<float , base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2);
438- }
439- #endif
440- else {
441- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
442- }
443- }
444-
445- void vector_add_vector (const int & dim, double *result, const double *vector1, const double constant1, const double *vector2, const double constant2, base_device::AbacusDevice_t device_type)
446- {
447- if (device_type == base_device::CpuDevice){
448- #ifdef _OPENMP
449- #pragma omp parallel for schedule(static, 8192 / sizeof(double))
450- #endif
451- for (int i = 0 ; i < dim; i++)
452- {
453- result[i] = vector1[i] * constant1 + vector2[i] * constant2;
454- }
455- }
456- #ifdef __CUDA
457- else if (device_type == base_device::GpuDevice) {
458- ModuleBase::vector_add_vector_op<double , base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2);
459- }
460- #endif
461- else {
462- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
463- }
464- }
465-
466- void vector_add_vector (const int & dim, std::complex <float > *result, const std::complex <float > *vector1, const float constant1, const std::complex <float > *vector2, const float constant2, base_device::AbacusDevice_t device_type)
467- {
468- if (device_type == base_device::CpuDevice){
469- #ifdef _OPENMP
470- #pragma omp parallel for schedule(static, 8192 / sizeof(std::complex<float>))
471- #endif
472- for (int i = 0 ; i < dim; i++)
473- {
474- result[i] = vector1[i] * constant1 + vector2[i] * constant2;
475- }
476- }
477- #ifdef __CUDA
478- else if (device_type == base_device::GpuDevice) {
479- ModuleBase::vector_add_vector_op<std::complex <float >, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2);
480- }
481- #endif
482- else {
483- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
484- }
485- }
486-
487- void vector_add_vector (const int & dim, std::complex <double > *result, const std::complex <double > *vector1, const double constant1, const std::complex <double > *vector2, const double constant2, base_device::AbacusDevice_t device_type)
488- {
489- if (device_type == base_device::CpuDevice){
490- #ifdef _OPENMP
491- #pragma omp parallel for schedule(static, 8192 / sizeof(std::complex<double>))
492- #endif
493- for (int i = 0 ; i < dim; i++)
494- {
495- result[i] = vector1[i] * constant1 + vector2[i] * constant2;
496- }
497- }
498- #ifdef __CUDA
499- else if (device_type == base_device::GpuDevice) {
500- ModuleBase::vector_add_vector_op<std::complex <double >, base_device::DEVICE_GPU>()(dim, result, vector1, constant1, vector2, constant2);
501- }
502- #endif
503- else {
504- throw std::invalid_argument (" device_type = " + std::to_string (device_type) + " in " + std::string (__FILE__) + " line " + std::to_string (__LINE__));
505- }
506377}
0 commit comments