From 7904e20f2e6908571ee5008da2a08084198eefae Mon Sep 17 00:00:00 2001 From: "Field G. Van Zee" Date: Tue, 16 Apr 2013 17:37:16 -0500 Subject: [PATCH] Fixed "root" object bug in bli_her[2]k/syr[2]k. Details: - Fixed an obscure bug in the front-ends for herk, her2k, syrk, and syr2k, that manifested as the incorrect triangle being updated. It occurred when the user would pass in a matrix object that was correctly marked as symmetric/Hermitian and lower-stored, but whose root object was never marked as lower (or upper). We now alias and re-assign root status for matrix C within the front-ends. Note that trmm and trsm were already doing this, albeit for a slightly different reason (to allow the internal back-end to choose which algorithm to run--lower or upper--based on the uplo of the root object for both left and right side cases). Thanks to Bryan Marker for leading me to this bug. --- frame/3/her2k/bli_her2k.c | 12 +++++++++--- frame/3/herk/bli_herk.c | 8 +++++++- frame/3/syr2k/bli_syr2k.c | 12 +++++++++--- frame/3/syrk/bli_syrk.c | 8 +++++++- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/frame/3/her2k/bli_her2k.c b/frame/3/her2k/bli_her2k.c index fcb2c884b..81e861d04 100644 --- a/frame/3/her2k/bli_her2k.c +++ b/frame/3/her2k/bli_her2k.c @@ -50,6 +50,7 @@ void bli_her2k( obj_t* alpha, obj_t alpha_local; obj_t alpha_conj_local; obj_t beta_local; + obj_t c_local; obj_t ah; obj_t bh; num_t dt_targ_a; @@ -71,6 +72,11 @@ void bli_her2k( obj_t* alpha, return; } + // Alias C so we can reset it as the root object (in case it is not + // already a root object). + bli_obj_alias_to( *c, c_local ); + bli_obj_set_as_root( c_local ); + // Create objects to track A' and B' (for the second rank-k update). bli_obj_alias_with_trans( BLIS_CONJ_TRANSPOSE, *a, ah ); bli_obj_alias_with_trans( BLIS_CONJ_TRANSPOSE, *b, bh ); @@ -145,7 +151,7 @@ void bli_her2k( obj_t* alpha, b, &ah, &beta_local, - c, + &c_local, cntl ); /* @@ -153,13 +159,13 @@ void bli_her2k( obj_t* alpha, a, &bh, &beta_local, - c, + &c_local, herk_cntl ); bli_herk_int( &alpha_conj_local, b, &ah, &BLIS_ONE, - c, + &c_local, herk_cntl ); */ } diff --git a/frame/3/herk/bli_herk.c b/frame/3/herk/bli_herk.c index 511f31af2..af6f5ef63 100644 --- a/frame/3/herk/bli_herk.c +++ b/frame/3/herk/bli_herk.c @@ -47,6 +47,7 @@ void bli_herk( obj_t* alpha, herk_t* cntl; obj_t alpha_local; obj_t beta_local; + obj_t c_local; obj_t ah; num_t dt_targ_a; num_t dt_targ_ah; @@ -67,6 +68,11 @@ void bli_herk( obj_t* alpha, return; } + // Alias C so we can reset it as the root object (in case it is not + // already a root object). + bli_obj_alias_to( *c, c_local ); + bli_obj_set_as_root( c_local ); + // For herk, the right-hand "B" operand is simply A'. bli_obj_alias_with_trans( BLIS_CONJ_TRANSPOSE, *a, ah ); @@ -141,7 +147,7 @@ void bli_herk( obj_t* alpha, a, &ah, &beta_local, - c, + &c_local, cntl ); } diff --git a/frame/3/syr2k/bli_syr2k.c b/frame/3/syr2k/bli_syr2k.c index 27378878c..22df3491c 100644 --- a/frame/3/syr2k/bli_syr2k.c +++ b/frame/3/syr2k/bli_syr2k.c @@ -49,6 +49,7 @@ void bli_syr2k( obj_t* alpha, her2k_t* cntl; obj_t alpha_local; obj_t beta_local; + obj_t c_local; obj_t at; obj_t bt; num_t dt_targ_a; @@ -70,6 +71,11 @@ void bli_syr2k( obj_t* alpha, return; } + // Alias C so we can reset it as the root object (in case it is not + // already a root object). + bli_obj_alias_to( *c, c_local ); + bli_obj_set_as_root( c_local ); + // Create objects to track A^T and B^T (for the second rank-k update). bli_obj_alias_with_trans( BLIS_TRANSPOSE, *a, at ); bli_obj_alias_with_trans( BLIS_TRANSPOSE, *b, bt ); @@ -141,20 +147,20 @@ void bli_syr2k( obj_t* alpha, b, &at, &beta_local, - c, + &c_local, cntl ); /* bli_herk_int( &alpha_local, a, &bt, &beta_local, - c, + &c_local, herk_cntl ); bli_herk_int( &alpha_local, b, &at, &BLIS_ONE, - c, + &c_local, herk_cntl ); */ } diff --git a/frame/3/syrk/bli_syrk.c b/frame/3/syrk/bli_syrk.c index 43cf6afe7..6b8680f2b 100644 --- a/frame/3/syrk/bli_syrk.c +++ b/frame/3/syrk/bli_syrk.c @@ -47,6 +47,7 @@ void bli_syrk( obj_t* alpha, herk_t* cntl; obj_t alpha_local; obj_t beta_local; + obj_t c_local; obj_t at; num_t dt_targ_a; num_t dt_targ_at; @@ -67,6 +68,11 @@ void bli_syrk( obj_t* alpha, return; } + // Alias C so we can reset it as the root object (in case it is not + // already a root object). + bli_obj_alias_to( *c, c_local ); + bli_obj_set_as_root( c_local ); + // For syrk, the right-hand "B" operand is simply A^T. bli_obj_alias_with_trans( BLIS_TRANSPOSE, *a, at ); @@ -144,7 +150,7 @@ void bli_syrk( obj_t* alpha, a, &at, &beta_local, - c, + &c_local, cntl ); }