libflame
revision_anchor
|
Functions | |
void | bli_sher2k (uplo_t uplo, trans_t trans, int m, int k, float *alpha, float *a, int a_rs, int a_cs, float *b, int b_rs, int b_cs, float *beta, float *c, int c_rs, int c_cs) |
void | bli_dher2k (uplo_t uplo, trans_t trans, int m, int k, double *alpha, double *a, int a_rs, int a_cs, double *b, int b_rs, int b_cs, double *beta, double *c, int c_rs, int c_cs) |
void | bli_cher2k (uplo_t uplo, trans_t trans, int m, int k, scomplex *alpha, scomplex *a, int a_rs, int a_cs, scomplex *b, int b_rs, int b_cs, float *beta, scomplex *c, int c_rs, int c_cs) |
void | bli_zher2k (uplo_t uplo, trans_t trans, int m, int k, dcomplex *alpha, dcomplex *a, int a_rs, int a_cs, dcomplex *b, int b_rs, int b_cs, double *beta, dcomplex *c, int c_rs, int c_cs) |
void | bli_cher2k_blas (uplo_t uplo, trans_t trans, int m, int k, scomplex *alpha, scomplex *a, int lda, scomplex *b, int ldb, float *beta, scomplex *c, int ldc) |
void | bli_zher2k_blas (uplo_t uplo, trans_t trans, int m, int k, dcomplex *alpha, dcomplex *a, int lda, dcomplex *b, int ldb, double *beta, dcomplex *c, int ldc) |
void bli_cher2k | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
scomplex * | alpha, | ||
scomplex * | a, | ||
int | a_rs, | ||
int | a_cs, | ||
scomplex * | b, | ||
int | b_rs, | ||
int | b_cs, | ||
float * | beta, | ||
scomplex * | c, | ||
int | c_rs, | ||
int | c_cs | ||
) |
References bli_c1(), bli_callocm(), bli_caxpymrt(), bli_ccopymt(), bli_ccreate_contigmr(), bli_ccreate_contigmt(), bli_cfree(), bli_cfree_contigm(), bli_cfree_saved_contigmr(), bli_cher2k_blas(), bli_csscalmr(), bli_is_col_storage(), bli_s0(), bli_set_dims_with_trans(), bli_zero_dim2(), BLIS_CONJ_NO_TRANSPOSE, and BLIS_NO_TRANSPOSE.
Referenced by FLA_Her2k_external().
{ uplo_t uplo_save = uplo; int m_save = m; scomplex* a_save = a; scomplex* b_save = b; scomplex* c_save = c; int a_rs_save = a_rs; int a_cs_save = a_cs; int b_rs_save = b_rs; int b_cs_save = b_cs; int c_rs_save = c_rs; int c_cs_save = c_cs; float zero_r = bli_s0(); scomplex one = bli_c1(); scomplex alpha_copy; scomplex* a_copy; scomplex* b_copy; scomplex* c_conj; int lda, inca; int ldb, incb; int ldc, incc; int lda_copy, inca_copy; int ldb_copy, incb_copy; int ldc_conj, incc_conj; int her2k_needs_copya = FALSE; int her2k_needs_copyb = FALSE; int her2k_needs_conj = FALSE; int her2k_needs_alpha_conj = FALSE; // Return early if possible. if ( bli_zero_dim2( m, k ) ) return; // If necessary, allocate, initialize, and use a temporary contiguous // copy of each matrix rather than the original matrices. bli_ccreate_contigmt( trans, m, k, a_save, a_rs_save, a_cs_save, &a, &a_rs, &a_cs ); bli_ccreate_contigmt( trans, m, k, b_save, b_rs_save, b_cs_save, &b, &b_rs, &b_cs ); bli_ccreate_contigmr( uplo, m, m, c_save, c_rs_save, c_cs_save, &c, &c_rs, &c_cs ); // Initialize with values assuming column-major storage. lda = a_cs; inca = a_rs; ldb = b_cs; incb = b_rs; ldc = c_cs; incc = c_rs; // Adjust the parameters based on the storage of each matrix. if ( bli_is_col_storage( c_rs, c_cs ) ) { if ( bli_is_col_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_c * B_r' + B_r * A_c' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' her2k_needs_copyb = TRUE; } } else // if ( bli_is_row_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_r * B_c' + B_c * A_r' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' her2k_needs_copya = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_r * B_r' + B_r * A_r' // requested operation: uplo( C_c ) += conj( A_c' * B_c + B_c' * A_c ) bli_swap_ints( lda, inca ); bli_swap_ints( ldb, incb ); bli_toggle_conjtrans( trans ); her2k_needs_conj = TRUE; her2k_needs_alpha_conj = TRUE; } } } else // if ( bli_is_row_storage( c_rs, c_cs ) ) { if ( bli_is_col_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_c * B_c' + B_c * A_c' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_c * B_r' + B_r * A_c' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) her2k_needs_copyb = TRUE; bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } } else // if ( bli_is_row_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_r * B_c' + B_c * A_r' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) her2k_needs_copya = TRUE; bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_r * B_r' + B_r * A_r' // requested operation: ~uplo( C_c ) += A_c' * B_c + B_c' * A_c bli_swap_ints( ldc, incc ); bli_swap_ints( lda, inca ); bli_swap_ints( ldb, incb ); bli_toggle_uplo( uplo ); bli_toggle_conjtrans( trans ); her2k_needs_alpha_conj = TRUE; } } } // Make a copy of alpha and conjugate if necessary. alpha_copy = *alpha; if ( her2k_needs_alpha_conj ) { bli_zconjs( &alpha_copy ); } a_copy = a; lda_copy = lda; inca_copy = inca; // There are two cases where we need to copy A column-major storage. // We handle those two cases here. if ( her2k_needs_copya ) { int m_a; int n_a; // Determine the dimensions of A according to the value of trans. We // need this in order to set the leading dimension of the copy of A. bli_set_dims_with_trans( trans, m, k, &m_a, &n_a ); // We need a temporary matrix to hold a column-major copy of A. a_copy = bli_callocm( m, k ); lda_copy = m_a; inca_copy = 1; // Copy the contents of A into A_copy. bli_ccopymt( BLIS_NO_TRANSPOSE, m_a, n_a, a, inca, lda, a_copy, inca_copy, lda_copy ); } b_copy = b; ldb_copy = ldb; incb_copy = incb; // There are two cases where we need to copy B column-major storage. // We handle those two cases here. if ( her2k_needs_copyb ) { int m_b; int n_b; // Determine the dimensions of B according to the value of trans. We // need this in order to set the leading dimension of the copy of B. bli_set_dims_with_trans( trans, m, k, &m_b, &n_b ); // We need a temporary matrix to hold a column-major copy of B. b_copy = bli_callocm( m, k ); ldb_copy = m_b; incb_copy = 1; // Copy the contents of B into B_copy. bli_ccopymt( BLIS_NO_TRANSPOSE, m_b, n_b, b, incb, ldb, b_copy, incb_copy, ldb_copy ); } // There are two cases where we need to perform the rank-2k product and // then axpy the result into C with a conjugation. We handle those two // cases here. if ( her2k_needs_conj ) { // We need a temporary matrix for holding the rank-k product. c_conj = bli_callocm( m, m ); ldc_conj = m; incc_conj = 1; // Compute the rank-2k product. bli_cher2k_blas( uplo, trans, m, k, &alpha_copy, a_copy, lda_copy, b_copy, ldb_copy, &zero_r, c_conj, ldc_conj ); // Scale C by beta. bli_csscalmr( uplo, m, m, beta, c, incc, ldc ); // And finally, accumulate the rank-2k product in C_conj into C // with a conjugation. bli_caxpymrt( uplo, BLIS_CONJ_NO_TRANSPOSE, m, m, &one, c_conj, incc_conj, ldc_conj, c, incc, ldc ); // Free the temporary matrix for C. bli_cfree( c_conj ); } else { bli_cher2k_blas( uplo, trans, m, k, &alpha_copy, a_copy, lda_copy, b_copy, ldb_copy, beta, c, ldc ); } if ( her2k_needs_copya ) bli_cfree( a_copy ); if ( her2k_needs_copyb ) bli_cfree( b_copy ); // Free any temporary contiguous matrices, copying the result back to // the original matrix. bli_cfree_contigm( a_save, a_rs_save, a_cs_save, &a, &a_rs, &a_cs ); bli_cfree_contigm( b_save, b_rs_save, b_cs_save, &b, &b_rs, &b_cs ); bli_cfree_saved_contigmr( uplo_save, m_save, m_save, c_save, c_rs_save, c_cs_save, &c, &c_rs, &c_cs ); }
void bli_cher2k_blas | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
scomplex * | alpha, | ||
scomplex * | a, | ||
int | lda, | ||
scomplex * | b, | ||
int | ldb, | ||
float * | beta, | ||
scomplex * | c, | ||
int | ldc | ||
) |
References bli_param_map_to_netlib_trans(), bli_param_map_to_netlib_uplo(), cblas_cher2k(), CblasColMajor, and F77_cher2k().
Referenced by bli_cher2k().
{ #ifdef BLIS_ENABLE_CBLAS_INTERFACES enum CBLAS_ORDER cblas_order = CblasColMajor; enum CBLAS_UPLO cblas_uplo; enum CBLAS_TRANSPOSE cblas_trans; bli_param_map_to_netlib_uplo( uplo, &cblas_uplo ); bli_param_map_to_netlib_trans( trans, &cblas_trans ); cblas_cher2k( cblas_order, cblas_uplo, cblas_trans, m, k, alpha, a, lda, b, ldb, *beta, c, ldc ); #else char blas_uplo; char blas_trans; bli_param_map_to_netlib_uplo( uplo, &blas_uplo ); bli_param_map_to_netlib_trans( trans, &blas_trans ); F77_cher2k( &blas_uplo, &blas_trans, &m, &k, alpha, a, &lda, b, &ldb, beta, c, &ldc ); #endif }
void bli_dher2k | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
double * | alpha, | ||
double * | a, | ||
int | a_rs, | ||
int | a_cs, | ||
double * | b, | ||
int | b_rs, | ||
int | b_cs, | ||
double * | beta, | ||
double * | c, | ||
int | c_rs, | ||
int | c_cs | ||
) |
References bli_dsyr2k().
{ bli_dsyr2k( uplo, trans, m, k, alpha, a, a_rs, a_cs, b, b_rs, b_cs, beta, c, c_rs, c_cs ); }
void bli_sher2k | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
float * | alpha, | ||
float * | a, | ||
int | a_rs, | ||
int | a_cs, | ||
float * | b, | ||
int | b_rs, | ||
int | b_cs, | ||
float * | beta, | ||
float * | c, | ||
int | c_rs, | ||
int | c_cs | ||
) |
References bli_ssyr2k().
{ bli_ssyr2k( uplo, trans, m, k, alpha, a, a_rs, a_cs, b, b_rs, b_cs, beta, c, c_rs, c_cs ); }
void bli_zher2k | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
dcomplex * | alpha, | ||
dcomplex * | a, | ||
int | a_rs, | ||
int | a_cs, | ||
dcomplex * | b, | ||
int | b_rs, | ||
int | b_cs, | ||
double * | beta, | ||
dcomplex * | c, | ||
int | c_rs, | ||
int | c_cs | ||
) |
References bli_d0(), bli_is_col_storage(), bli_set_dims_with_trans(), bli_z1(), bli_zallocm(), bli_zaxpymrt(), bli_zcopymt(), bli_zcreate_contigmr(), bli_zcreate_contigmt(), bli_zdscalmr(), bli_zero_dim2(), bli_zfree(), bli_zfree_contigm(), bli_zfree_saved_contigmr(), bli_zher2k_blas(), BLIS_CONJ_NO_TRANSPOSE, and BLIS_NO_TRANSPOSE.
Referenced by FLA_Her2k_external().
{ uplo_t uplo_save = uplo; int m_save = m; dcomplex* a_save = a; dcomplex* b_save = b; dcomplex* c_save = c; int a_rs_save = a_rs; int a_cs_save = a_cs; int b_rs_save = b_rs; int b_cs_save = b_cs; int c_rs_save = c_rs; int c_cs_save = c_cs; double zero_r = bli_d0(); dcomplex one = bli_z1(); dcomplex alpha_copy; dcomplex* a_copy; dcomplex* b_copy; dcomplex* c_conj; int lda, inca; int ldb, incb; int ldc, incc; int lda_copy, inca_copy; int ldb_copy, incb_copy; int ldc_conj, incc_conj; int her2k_needs_copya = FALSE; int her2k_needs_copyb = FALSE; int her2k_needs_conj = FALSE; int her2k_needs_alpha_conj = FALSE; // Return early if possible. if ( bli_zero_dim2( m, k ) ) return; // If necessary, allocate, initialize, and use a temporary contiguous // copy of each matrix rather than the original matrices. bli_zcreate_contigmt( trans, m, k, a_save, a_rs_save, a_cs_save, &a, &a_rs, &a_cs ); bli_zcreate_contigmt( trans, m, k, b_save, b_rs_save, b_cs_save, &b, &b_rs, &b_cs ); bli_zcreate_contigmr( uplo, m, m, c_save, c_rs_save, c_cs_save, &c, &c_rs, &c_cs ); // Initialize with values assuming column-major storage. lda = a_cs; inca = a_rs; ldb = b_cs; incb = b_rs; ldc = c_cs; incc = c_rs; // Adjust the parameters based on the storage of each matrix. if ( bli_is_col_storage( c_rs, c_cs ) ) { if ( bli_is_col_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_c * B_r' + B_r * A_c' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' her2k_needs_copyb = TRUE; } } else // if ( bli_is_row_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_r * B_c' + B_c * A_r' // requested operation: uplo( C_c ) += A_c * B_c' + B_c * A_c' her2k_needs_copya = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_c ) += A_r * B_r' + B_r * A_r' // requested operation: uplo( C_c ) += conj( A_c' * B_c + B_c' * A_c ) bli_swap_ints( lda, inca ); bli_swap_ints( ldb, incb ); bli_toggle_conjtrans( trans ); her2k_needs_conj = TRUE; her2k_needs_alpha_conj = TRUE; } } } else // if ( bli_is_row_storage( c_rs, c_cs ) ) { if ( bli_is_col_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_c * B_c' + B_c * A_c' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_c * B_r' + B_r * A_c' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) her2k_needs_copyb = TRUE; bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } } else // if ( bli_is_row_storage( a_rs, a_cs ) ) { if ( bli_is_col_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_r * B_c' + B_c * A_r' // requested operation: ~uplo( C_c ) += conj( A_c * B_c' + B_c * A_c' ) her2k_needs_copya = TRUE; bli_swap_ints( ldc, incc ); bli_toggle_uplo( uplo ); her2k_needs_conj = TRUE; } else // if ( bli_is_row_storage( b_rs, b_cs ) ) { // requested operation: uplo( C_r ) += A_r * B_r' + B_r * A_r' // requested operation: ~uplo( C_c ) += A_c' * B_c + B_c' * A_c bli_swap_ints( ldc, incc ); bli_swap_ints( lda, inca ); bli_swap_ints( ldb, incb ); bli_toggle_uplo( uplo ); bli_toggle_conjtrans( trans ); her2k_needs_alpha_conj = TRUE; } } } // Make a copy of alpha and conjugate if necessary. alpha_copy = *alpha; if ( her2k_needs_alpha_conj ) { bli_zconjs( &alpha_copy ); } a_copy = a; lda_copy = lda; inca_copy = inca; // There are two cases where we need to copy A column-major storage. // We handle those two cases here. if ( her2k_needs_copya ) { int m_a; int n_a; // Determine the dimensions of A according to the value of trans. We // need this in order to set the leading dimension of the copy of A. bli_set_dims_with_trans( trans, m, k, &m_a, &n_a ); // We need a temporary matrix to hold a column-major copy of A. a_copy = bli_zallocm( m, k ); lda_copy = m_a; inca_copy = 1; // Copy the contents of A into A_copy. bli_zcopymt( BLIS_NO_TRANSPOSE, m_a, n_a, a, inca, lda, a_copy, inca_copy, lda_copy ); } b_copy = b; ldb_copy = ldb; incb_copy = incb; // There are two cases where we need to copy B column-major storage. // We handle those two cases here. if ( her2k_needs_copyb ) { int m_b; int n_b; // Determine the dimensions of B according to the value of trans. We // need this in order to set the leading dimension of the copy of B. bli_set_dims_with_trans( trans, m, k, &m_b, &n_b ); // We need a temporary matrix to hold a column-major copy of B. b_copy = bli_zallocm( m, k ); ldb_copy = m_b; incb_copy = 1; // Copy the contents of B into B_copy. bli_zcopymt( BLIS_NO_TRANSPOSE, m_b, n_b, b, incb, ldb, b_copy, incb_copy, ldb_copy ); } // There are two cases where we need to perform the rank-2k product and // then axpy the result into C with a conjugation. We handle those two // cases here. if ( her2k_needs_conj ) { // We need a temporary matrix for holding the rank-k product. c_conj = bli_zallocm( m, m ); ldc_conj = m; incc_conj = 1; // Compute the rank-2k product. bli_zher2k_blas( uplo, trans, m, k, &alpha_copy, a_copy, lda_copy, b_copy, ldb_copy, &zero_r, c_conj, ldc_conj ); // Scale C by beta. bli_zdscalmr( uplo, m, m, beta, c, incc, ldc ); // And finally, accumulate the rank-2k product in C_conj into C // with a conjugation. bli_zaxpymrt( uplo, BLIS_CONJ_NO_TRANSPOSE, m, m, &one, c_conj, incc_conj, ldc_conj, c, incc, ldc ); // Free the temporary matrix for C. bli_zfree( c_conj ); } else { bli_zher2k_blas( uplo, trans, m, k, &alpha_copy, a_copy, lda_copy, b_copy, ldb_copy, beta, c, ldc ); } if ( her2k_needs_copya ) bli_zfree( a_copy ); if ( her2k_needs_copyb ) bli_zfree( b_copy ); // Free any temporary contiguous matrices, copying the result back to // the original matrix. bli_zfree_contigm( a_save, a_rs_save, a_cs_save, &a, &a_rs, &a_cs ); bli_zfree_contigm( b_save, b_rs_save, b_cs_save, &b, &b_rs, &b_cs ); bli_zfree_saved_contigmr( uplo_save, m_save, m_save, c_save, c_rs_save, c_cs_save, &c, &c_rs, &c_cs ); }
void bli_zher2k_blas | ( | uplo_t | uplo, |
trans_t | trans, | ||
int | m, | ||
int | k, | ||
dcomplex * | alpha, | ||
dcomplex * | a, | ||
int | lda, | ||
dcomplex * | b, | ||
int | ldb, | ||
double * | beta, | ||
dcomplex * | c, | ||
int | ldc | ||
) |
References bli_param_map_to_netlib_trans(), bli_param_map_to_netlib_uplo(), cblas_zher2k(), CblasColMajor, and F77_zher2k().
Referenced by bli_zher2k().
{ #ifdef BLIS_ENABLE_CBLAS_INTERFACES enum CBLAS_ORDER cblas_order = CblasColMajor; enum CBLAS_UPLO cblas_uplo; enum CBLAS_TRANSPOSE cblas_trans; bli_param_map_to_netlib_uplo( uplo, &cblas_uplo ); bli_param_map_to_netlib_trans( trans, &cblas_trans ); cblas_zher2k( cblas_order, cblas_uplo, cblas_trans, m, k, alpha, a, lda, b, ldb, *beta, c, ldc ); #else char blas_uplo; char blas_trans; bli_param_map_to_netlib_uplo( uplo, &blas_uplo ); bli_param_map_to_netlib_trans( trans, &blas_trans ); F77_zher2k( &blas_uplo, &blas_trans, &m, &k, alpha, a, &lda, b, &ldb, beta, c, &ldc ); #endif }