5 #include <tbb/scalable_allocator.h> 9 #define SERIAL_CUTOFF 16 23 int NumThreads = mkl_get_max_threads();
24 MKL_Set_Num_Threads(1);
26 int NumThreads = openblas_get_num_threads();
27 openblas_set_num_threads(1);
35 #if BLAS==1 // MKL does not support option CblasConjNoTrans so the conjugation of the matrices are done in prior. 80 tbb::task::spawn_root_and_wait(calc_task);
84 MKL_Set_Num_Threads(NumThreads);
85 #elif BLAS==2 //OpenBLAS 86 openblas_set_num_threads(NumThreads);
108 std::cout <<
"pic::dot:: Cols of matrix A does not match rows of matrix B!" << std::endl;
114 std::cout <<
"pic::dot:: Cols of matrix A.transpose does not match rows of matrix B!" << std::endl;
120 std::cout <<
"pic::dot:: Cols of matrix A.transpose does not match rows of matrix B.transpose!" << std::endl;
126 std::cout <<
"pic::dot:: Cols of matrix A does not match rows of matrix B.transpose!" << std::endl;
134 std::cout <<
"pic::dot:: No preallocated data in matrix A!" << std::endl;
138 std::cout <<
"pic::dot:: No preallocated data in matrix B!" << std::endl;
156 transpose = CblasConjTrans;
162 transpose = CblasTrans;
165 transpose = CblasNoTrans;
208 order = CblasRowMajor;
261 CBLAS_TRANSPOSE Atranspose, Btranspose;
271 int m,n,k,lda,ldb,ldc;
307 cblas_zgemm3m(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);
333 size_t rows_mid = (rows_end+rows_start)/2;
337 rows_child2.
Arows = rows_end-rows_mid;
339 rows_child2.
Crows = rows_end-rows_mid;
344 recycle_as_child_of(cont);
351 cont.set_ref_count(2);
352 tbb::task::spawn(calc_task);;
363 size_t cols_mid = (cols_end+cols_start)/2;
367 cols_child2.
Acols = cols_end-cols_mid;
371 rows_child2.
Crows = cols_end-cols_mid;
380 recycle_as_child_of(cont);
389 cont.set_ref_count(2);
390 tbb::task::spawn(calc_task);
401 size_t cols_mid = (cols_end+cols_start)/2;
405 cols_child2.
Bcols = cols_end-cols_mid;
407 cols_child2.
Ccols = cols_end-cols_mid;
416 recycle_as_child_of(cont);
424 cont.set_ref_count(2);
425 tbb::task::spawn(calc_task);
436 size_t rows_mid = (rows_end+rows_start)/2;
440 rows_child2.
Brows = rows_end-rows_mid;
444 cols_child2.
Ccols = rows_end-rows_mid;
449 recycle_as_child_of(cont);
457 cont.set_ref_count(2);
458 tbb::task::spawn(calc_task);;
Matrix dot(Matrix &A, Matrix &B)
Call to calculate the product of two complex matrices by calling method zgemm3m from the CBLAS librar...
tbb::task * execute()
This function is called when a task is spawned.
size_t Ccols_start
The firs col in matrix C participating in the multiplication sub-problem.
size_t rows
The number of rows.
size_t Crows
The number of rows in matrix C participating in the multiplication sub-problem.
size_t Ccols
The number of cols in matrix C participating in the multiplication sub-problem.
void get_cblas_transpose(Matrix &A, CBLAS_TRANSPOSE &transpose)
Call to get the transpose properties of the input matrix for CBLAS calculations.
scalar * get_data()
Call to get the pointer to the stored data.
Structure containing row limits for the partitioning of the matrix product calculations.
Structure containing column limits for the partitioning of the matrix product calculations.
tbb::task * execute()
Overriden execute function of class tbb::task.
zgemm3m_Task_serial(Matrix &A_in, Matrix &B_in, Matrix &C_in)
Constructor of the class.
size_t Brows_end
The last row in matrix B participating in the multiplication sub-problem. (The rows are picked from a...
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.
size_t Acols_start
The firs col in matrix A participating in the multiplication sub-problem.
size_t Bcols_end
The last col in matrix B participating in the multiplication sub-problem. (The cols are picked from a...
size_t Arows_start
The firs row in matrix A participating in the multiplication sub-problem.
size_t cols
The number of columns.
size_t Bcols_start
The firs col in matrix B participating in the multiplication sub-problem.
size_t Arows_end
The last row in matrix A participating in the multiplication sub-problem. (The rows are picked from a...
size_t Acols_end
The last col in matrix A participating in the multiplication sub-problem. (The cols are picked from a...
size_t Crows_start
The firs row in matrix C participating in the multiplication sub-problem.
size_t Crows_end
The last row in matrix C participating in the multiplication sub-problem. (The rows are picked from a...
size_t Bcols
The number of cols in matrix B participating in the multiplication sub-problem.
size_t Brows
The number of rows in matrix B participating in the multiplication sub-problem.
Structure type representing complex numbers in the QGD package.
Empty task class to utilize task continuation for saving stack space.
Cont_Task_rowsA()
Default constructor of the class.
Class to store data of complex arrays and its properties.
size_t Ccols_end
The last col in matrix C participating in the multiplication sub-problem. (The col are picked from a ...
size_t Arows
The number of rows in matrix A participating in the multiplication sub-problem.
row_indices rows
Structure containing row limits for the partitioning of the matrix product calculations.
col_indices cols
Structure containing column limits for the partitioning of the matrix product calculations.
double real
the real part of a complex number
Class to calculate a matrix product C=A*B in serial.
size_t Brows_start
The firs row in matrix B participating in the multiplication sub-problem.
Class to calculate a matrix product C=A*B in parallel.
CBLAS_ORDER order
CBLAS storage order.
size_t Acols
The number of cols in matrix A participating in the multiplication sub-problem.
void zgemm3m_chunk()
Call to calculate the product of matrix chunks defined by attributes rows, cols.
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.