23 #include <tbb/scalable_allocator.h> 27 #define SERIAL_CUTOFF 16 40 #if BLAS==0 // undefined BLAS 44 int NumThreads = mkl_get_max_threads();
45 MKL_Set_Num_Threads(1);
46 #elif BLAS==2 //OpenBLAS 47 int NumThreads = openblas_get_num_threads();
48 openblas_set_num_threads(1);
56 #if BLAS==1 // MKL does not support option CblasConjNoTrans so the conjugation of the matrices are done in prior. 101 g.run_and_wait([&A, &B, &C, &g]() {
110 #if BLAS==0 // undefined BLAS 113 MKL_Set_Num_Threads(NumThreads);
114 #elif BLAS==2 //OpenBLAS 115 openblas_set_num_threads(NumThreads);
136 std::stringstream sstream;
146 sstream <<
"pic::dot:: Cols of matrix A does not match rows of matrix B!" << std::endl;
148 output.
print(sstream,verbose_level);
153 sstream <<
"pic::dot:: Cols of matrix A.transpose does not match rows of matrix B!" << std::endl;
155 output.
print(sstream,verbose_level);
161 sstream <<
"pic::dot:: Cols of matrix A.transpose does not match rows of matrix B.transpose!" << std::endl;
163 output. print(sstream,verbose_level);
169 sstream <<
"pic::dot:: Cols of matrix A does not match rows of matrix B.transpose!" << std::endl;
171 output.
print(sstream,verbose_level);
179 sstream <<
"pic::dot:: No preallocated data in matrix A!" << std::endl;
181 output.
print(sstream,verbose_level);
185 sstream <<
"pic::dot:: No preallocated data in matrix B!" << std::endl;
187 output.
print(sstream,verbose_level);
206 std::stringstream sstream;
218 sstream <<
"CblasConjNoTrans NOT IMPLEMENTED in GSL!!!!!!!!!!!!!!!" << std::endl;
220 output.
print(sstream,verbose_level);
314 int m,n,
k,lda,ldb,ldc;
350 cblas_zgemm(
CblasRowMajor, Atranspose, Btranspose, m, n, k, (
double*)&alpha, (
double*)A_zgemm_data, lda, (
double*)B_zgemm_data, ldb, (
double*)&beta, (
double*)C_zgemm_data, ldc);
396 int rows_mid = (rows_end+rows_start)/2;
405 calc_task->
rows.
Arows = rows_end-rows_mid;
407 calc_task->
rows.
Crows = rows_end-rows_mid;
409 g.run([calc_task, &g](){
431 int cols_mid = (cols_end+cols_start)/2;
440 calc_task->
cols.
Acols = cols_end-cols_mid;
443 calc_task->
rows.
Crows = cols_end-cols_mid;
446 g.run([calc_task, &g](){
469 int cols_mid = (cols_end+cols_start)/2;
478 calc_task->
cols.
Bcols = cols_end-cols_mid;
480 calc_task->
cols.
Ccols = cols_end-cols_mid;
483 g.run([calc_task, &g](){
504 int rows_mid = (rows_end+rows_start)/2;
512 calc_task->
rows.
Brows = rows_end-rows_mid;
515 calc_task->
cols.
Ccols = rows_end-rows_mid;
518 g.run([calc_task, &g](){
Matrix dot(Matrix &A, Matrix &B)
Call to calculate the product of two complex matrices by calling method zgemm3m from the CBLAS librar...
CBLAS_ORDER order
CBLAS storage order.
void print(const std::stringstream &sstream, int verbose_level=1) const
Call to print output messages in the function of the verbosity level.
void cblas_zgemm(const enum CBLAS_ORDER Order, const enum CBLAS_TRANSPOSE TransA, const enum CBLAS_TRANSPOSE TransB, const int M, const int N, const int K, const void *alpha, const void *A, const int lda, const void *B, const int ldb, const void *beta, void *C, const int ldc)
Definition of the zgemm function from CBLAS.
void execute(tbb::task_group &g)
This function is called when a task is spawned.
Class to calculate a matrix product C=A*B in serial.
int Ccols
The number of cols in matrix C participating in the multiplication sub-problem.
int stride
The column stride of the array. (The array elements in one row are a_0, a_1, ... a_{cols-1}, 0, 0, 0, 0. The number of zeros is stride-cols)
row_indices rows
Structure containing row limits for the partitioning of the matrix product calculations.
void get_cblas_transpose(Matrix &A, CBLAS_TRANSPOSE &transpose)
Call to get the transpose properties of the input matrix for CBLAS calculations.
int Arows_end
The last row in matrix A participating in the multiplication sub-problem. (The rows are picked from a...
int Arows
The number of rows in matrix A participating in the multiplication sub-problem.
int Crows_start
The firs row in matrix C participating in the multiplication sub-problem.
Class to calculate a matrix product C=A*B in parallel.
int Acols_start
The firs col in matrix A participating in the multiplication sub-problem.
Structure containing row limits for the partitioning of the matrix product calculations.
int Brows_start
The firs row in matrix B participating in the multiplication sub-problem.
Structure containing column limits for the partitioning of the matrix product calculations.
scalar * get_data() const
Call to get the pointer to the stored data.
bool check_matrices(Matrix &A, Matrix &B)
Call to check the shape of the matrices for method dot.
bool is_conjugated()
Call to get whether the matrix should be conjugated in CBLAS functions or not.
int Crows
The number of rows in matrix C participating in the multiplication sub-problem.
A class containing basic methods for setting up the verbosity level.
int rows
The number of rows.
int cols
The number of columns.
zgemm_Task(Matrix &A_in, Matrix &B_in, Matrix &C_in)
Constructor of the class.
int Bcols_start
The firs col in matrix B participating in the multiplication sub-problem.
zgemm_Task_serial(Matrix &A_in, Matrix &B_in, Matrix &C_in)
Constructor of the class.
Structure type representing complex numbers in the SQUANDER package.
int Acols
The number of cols in matrix A participating in the multiplication sub-problem.
void zgemm_chunk()
Call to calculate the product of matrix chunks defined by attributes rows, cols.
int Acols_end
The last col in matrix A participating in the multiplication sub-problem. (The cols are picked from a...
int Crows_end
The last row in matrix C participating in the multiplication sub-problem. (The rows are picked from a...
Class to store data of complex arrays and its properties.
void omp_set_num_threads(int num_threads)
Set the number of threads on runtime in MKL.
col_indices cols
Structure containing column limits for the partitioning of the matrix product calculations.
int Brows
The number of rows in matrix B participating in the multiplication sub-problem.
int Bcols
The number of cols in matrix B participating in the multiplication sub-problem.
int Ccols_start
The firs col in matrix C participating in the multiplication sub-problem.
Header file for commonly used functions and wrappers to CBLAS functions.
double real
the real part of a complex number
int Arows_start
The firs row in matrix A participating in the multiplication sub-problem.
int Ccols_end
The last col in matrix C participating in the multiplication sub-problem. (The col are picked from a ...
int Brows_end
The last row in matrix B participating in the multiplication sub-problem. (The rows are picked from a...
int Bcols_end
The last col in matrix B participating in the multiplication sub-problem. (The cols are picked from a...
double imag
the imaginary part of a complex number
bool is_transposed()
Call to get whether the matrix should be conjugated in CBLAS functions or not.
int omp_get_max_threads()
get the number of threads in MKL