Fixed bug in release of mem_t buffer.

Details:
- Fixed a bug that affects all level-2 and level-3 blocked variants. The
  bug only manifested, however, if the packing of operands (A and B in
  gemm, for example) spanned multiple nodes in the control tree. Until
  recently, the main consumers of packm were level-3 operations, all of
  which packed both input operands from blocked variant 1 (B outside of
  the loop, and A within the loop). This particular usage masked a flaw
  in the code whereby bli_obj_release_pack() would always release the
  underlying mem_t buffer (provided it was allocated), even if the buffer
  was not allocated in the current variant. This has been fixed by
  replacing all calls to bli_obj_release_pack() with calls to a new
  function, bli_packm_release(), which takes the same control tree node
  argument passed into the object's corresponding call to packm_init()
  or packv_init(). bli_packm_release() then proceeds to invoke
  bli_obj_release_pack() only if the control tree node indicates that
  packing was requested. Thanks to Devangi Parikh for identifying this
  bug.
This commit is contained in:
Field G. Van Zee
2015-03-18 11:38:08 -05:00
parent c0acca0f51
commit 8d5169ccda
44 changed files with 123 additions and 101 deletions

View File

@@ -199,6 +199,13 @@ void bli_packv_init_pack( pack_t pack_schema,
}
}
void bli_packv_release( obj_t* p,
packv_t* cntl )
{
if ( !cntl_is_noop( cntl ) )
bli_obj_release_pack( p );
}
/*
void bli_packv_init_cast( obj_t* a,

View File

@@ -41,6 +41,9 @@ void bli_packv_init_pack( pack_t pack_schema,
obj_t* c,
obj_t* p );
void bli_packv_release( obj_t* p,
packv_t* cntl );
/*
void bli_packv_init_cast( obj_t* a,
obj_t* p,

View File

@@ -558,6 +558,13 @@ void bli_packm_init_pack( invdiag_t invert_diag,
}
void bli_packm_release( obj_t* p,
packm_t* cntl )
{
if ( !cntl_is_noop( cntl ) )
bli_obj_release_pack( p );
}
/*
void bli_packm_init_cast( obj_t* a,

View File

@@ -51,3 +51,7 @@ void bli_packm_init_cast( obj_t* a,
obj_t* p,
obj_t* c );
*/
void bli_packm_release( obj_t* p,
packm_t* cntl );

View File

@@ -98,7 +98,7 @@ void bli_gemv_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a1_pack, cntl_sub_packm_a( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y( cntl ) );
}

View File

@@ -99,7 +99,7 @@ void bli_gemv_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a1_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a1_pack, cntl_sub_packm_a( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x( cntl ) );
}

View File

@@ -97,7 +97,7 @@ void bli_ger_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a1_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a1_pack, cntl_sub_packm_a( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x( cntl ) );
}

View File

@@ -97,7 +97,7 @@ void bli_ger_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a1_pack, cntl_sub_packm_a( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y( cntl ) );
}

View File

@@ -149,8 +149,8 @@ void bli_hemv_blk_var1( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -152,8 +152,8 @@ void bli_hemv_blk_var2( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -149,8 +149,8 @@ void bli_hemv_blk_var3( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -152,8 +152,8 @@ void bli_hemv_blk_var4( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -119,7 +119,7 @@ void bli_her_blk_var1( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -119,7 +119,7 @@ void bli_her_blk_var2( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -143,8 +143,8 @@ void bli_her2_blk_var1( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -146,8 +146,8 @@ void bli_her2_blk_var2( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -146,8 +146,8 @@ void bli_her2_blk_var3( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -143,8 +143,8 @@ void bli_her2_blk_var4( conj_t conjh,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &c11_pack );
bli_obj_release_pack( &x1_pack );
bli_obj_release_pack( &y1_pack );
bli_packm_release( &c11_pack, cntl_sub_packm_c11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
bli_packv_release( &y1_pack, cntl_sub_packv_y1( cntl ) );
}

View File

@@ -108,7 +108,7 @@ void bli_trmv_l_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -108,7 +108,7 @@ void bli_trmv_l_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -108,7 +108,7 @@ void bli_trmv_u_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -108,7 +108,7 @@ void bli_trmv_u_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -113,7 +113,7 @@ void bli_trsv_l_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -113,7 +113,7 @@ void bli_trsv_l_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -113,7 +113,7 @@ void bli_trsv_u_blk_var1( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -113,7 +113,7 @@ void bli_trsv_u_blk_var2( obj_t* alpha,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
bli_obj_release_pack( &a11_pack );
bli_obj_release_pack( &x1_pack );
bli_packm_release( &a11_pack, cntl_sub_packm_a11( cntl ) );
bli_packv_release( &x1_pack, cntl_sub_packv_x1( cntl ) );
}

View File

@@ -144,10 +144,10 @@ void bli_gemm_blk_var1f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( b_pack );
bli_packm_release( b_pack, cntl_sub_packm_b( cntl ) );
if( thread_am_ichief( thread ) ){
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -143,10 +143,10 @@ void bli_gemm_blk_var2f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( b1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -146,10 +146,10 @@ void bli_gemm_blk_var3f( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) )
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
if( thread_am_ichief( thread ) ){
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( b1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -139,10 +139,10 @@ void bli_herk_blk_var1f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( ah_pack );
bli_packm_release( ah_pack, cntl_sub_packm_b( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -154,10 +154,10 @@ void bli_herk_blk_var2f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( ah1_pack );
bli_obj_release_pack( c1S_pack );
bli_packm_release( ah1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1S_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -143,11 +143,11 @@ void bli_herk_blk_var3f( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) ) {
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
}
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( ah1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( ah1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -150,10 +150,10 @@ void bli_trmm_blk_var1f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( b_pack );
bli_packm_release( b_pack, cntl_sub_packm_b( cntl ) );
if( thread_am_ichief( thread ) ){
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -138,10 +138,10 @@ void bli_trmm_blk_var2b( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( b1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -138,10 +138,10 @@ void bli_trmm_blk_var2f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( b1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -137,11 +137,11 @@ void bli_trmm_blk_var3b( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) ){
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
}
if( thread_am_ichief( thread ) ){
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( b1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -137,11 +137,11 @@ void bli_trmm_blk_var3f( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) ){
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
}
if( thread_am_ichief( thread ) ){
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( b1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -128,8 +128,8 @@ void bli_trsm_blk_var1b( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( b_pack );
bli_packm_release( b_pack, cntl_sub_packm_b( cntl ) );
if( thread_am_ichief( thread ) )
bli_obj_release_pack( a1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
}

View File

@@ -127,8 +127,8 @@ void bli_trsm_blk_var1f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( b_pack );
bli_packm_release( b_pack, cntl_sub_packm_b( cntl ) );
if( thread_am_ichief( thread ) )
bli_obj_release_pack( a1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
}

View File

@@ -140,10 +140,10 @@ void bli_trsm_blk_var2b( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( b1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -140,10 +140,10 @@ void bli_trsm_blk_var2f( obj_t* a,
// to the memory manager.
thread_obarrier( thread );
if( thread_am_ochief( thread ) )
bli_obj_release_pack( a_pack );
bli_packm_release( a_pack, cntl_sub_packm_a( cntl ) );
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( b1_pack );
bli_obj_release_pack( c1_pack );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
bli_packm_release( c1_pack, cntl_sub_packm_c( cntl ) );
}
}

View File

@@ -147,11 +147,11 @@ void bli_trsm_blk_var3b( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) ) {
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
}
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( b1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -147,11 +147,11 @@ void bli_trsm_blk_var3f( obj_t* a,
// If any packing buffers were acquired within packm, release them back
// to the memory manager.
if( thread_am_ochief( thread ) ) {
bli_obj_release_pack( c_pack );
bli_packm_release( c_pack, cntl_sub_packm_c( cntl ) );
}
if( thread_am_ichief( thread ) ) {
bli_obj_release_pack( a1_pack );
bli_obj_release_pack( b1_pack );
bli_packm_release( a1_pack, cntl_sub_packm_a( cntl ) );
bli_packm_release( b1_pack, cntl_sub_packm_b( cntl ) );
}
}

View File

@@ -946,6 +946,7 @@ bli_obj_width_stored( obj )
#define bli_obj_release_pack( obj_p ) \
{ \
mem_t* pack_mem = bli_obj_pack_mem( *(obj_p) ); \
\
if ( bli_mem_is_alloc( pack_mem ) ) \
bli_mem_release( pack_mem ); \
}