mirror of
https://github.com/amd/blis.git
synced 2026-05-13 18:52:14 +00:00
Fixed obscure bug in bli_acquire_mpart_[mn]dim().
Details: - Fixed a bug in bli_acquire_mpart_mdim(), bli_acquire_mpart_ndim(), and bli_acquire_mpart_mndim() that allowed the use of a blocksize b that is too large given the current row/column index (i.e., the i/j argument) and the size of the dimension being partitioned (i.e., the m/n argument). This bug only affected backwards partitioning/motion through the dimension and was the result of a misplaced conditional check-and-redirect to the backwards code path. It should be noted that this bug was discovered not because it manifested the way it could (thanks to the callers in BLIS making sure to always pass in the "correct" blocksize b), but could have manifested if the functions were used by 3rd party callers. Thanks to Minh Quan Ho for reporting the bug via issue #363.
This commit is contained in:
@@ -126,22 +126,11 @@ void bli_acquire_mpart_mdim
|
||||
doff_t diag_off_inc;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate i.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Query the dimension in the partitioning direction.
|
||||
dim_t m = bli_obj_length_after_trans( obj );
|
||||
|
||||
// Modify i to account for the fact that we are moving backwards.
|
||||
i = m - i - b;
|
||||
}
|
||||
|
||||
|
||||
// Call a special function for partitioning packed objects. (By only
|
||||
// catching those objects packed to panels, we omit cases where the
|
||||
// object is packed to row or column storage, as such objects can be
|
||||
// partitioned through normally.)
|
||||
// partitioned through normally.) Note that the function called below
|
||||
// assumes forward partitioning.
|
||||
if ( bli_obj_is_panel_packed( obj ) )
|
||||
{
|
||||
bli_packm_acquire_mpart_t2b( req_part, i, b, obj, sub_obj );
|
||||
@@ -173,6 +162,15 @@ void bli_acquire_mpart_mdim
|
||||
if ( b > m - i ) b = m - i;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate i.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Modify i to account for the fact that we are moving backwards.
|
||||
i = m - i - b;
|
||||
}
|
||||
|
||||
|
||||
// Support SUBPART1B (behind SUBPART1) and SUBPART1A (ahead of SUBPART1),
|
||||
// to refer to subpartitions 0 and 2 when moving forward, and 2 and 0 when
|
||||
// moving backward.
|
||||
@@ -352,22 +350,11 @@ void bli_acquire_mpart_ndim
|
||||
doff_t diag_off_inc;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate j.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Query the dimension in the partitioning direction.
|
||||
dim_t n = bli_obj_width_after_trans( obj );
|
||||
|
||||
// Modify i to account for the fact that we are moving backwards.
|
||||
j = n - j - b;
|
||||
}
|
||||
|
||||
|
||||
// Call a special function for partitioning packed objects. (By only
|
||||
// catching those objects packed to panels, we omit cases where the
|
||||
// object is packed to row or column storage, as such objects can be
|
||||
// partitioned through normally.)
|
||||
// partitioned through normally.) Note that the function called below
|
||||
// assumes forward partitioning.
|
||||
if ( bli_obj_is_panel_packed( obj ) )
|
||||
{
|
||||
bli_packm_acquire_mpart_l2r( req_part, j, b, obj, sub_obj );
|
||||
@@ -399,6 +386,15 @@ void bli_acquire_mpart_ndim
|
||||
if ( b > n - j ) b = n - j;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate j.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Modify j to account for the fact that we are moving backwards.
|
||||
j = n - j - b;
|
||||
}
|
||||
|
||||
|
||||
// Support SUBPART1B (behind SUBPART1) and SUBPART1A (ahead of SUBPART1),
|
||||
// to refer to subpartitions 0 and 2 when moving forward, and 2 and 0 when
|
||||
// moving backward.
|
||||
@@ -578,22 +574,11 @@ void bli_acquire_mpart_mndim
|
||||
doff_t diag_off_inc;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate ij.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Query the dimension of the object.
|
||||
dim_t mn = bli_obj_length( obj );
|
||||
|
||||
// Modify ij to account for the fact that we are moving backwards.
|
||||
ij = mn - ij - b;
|
||||
}
|
||||
|
||||
|
||||
// Call a special function for partitioning packed objects. (By only
|
||||
// catching those objects packed to panels, we omit cases where the
|
||||
// object is packed to row or column storage, as such objects can be
|
||||
// partitioned through normally.)
|
||||
// partitioned through normally.) Note that the function called below
|
||||
// assumes forward partitioning.
|
||||
if ( bli_obj_is_panel_packed( obj ) )
|
||||
{
|
||||
bli_packm_acquire_mpart_tl2br( req_part, ij, b, obj, sub_obj );
|
||||
@@ -626,6 +611,15 @@ void bli_acquire_mpart_mndim
|
||||
if ( b > min_m_n - ij ) b = min_m_n - ij;
|
||||
|
||||
|
||||
// NOTE: Most of this function implicitly assumes moving forward.
|
||||
// When moving backward, we have to relocate ij.
|
||||
if ( direct == BLIS_BWD )
|
||||
{
|
||||
// Modify ij to account for the fact that we are moving backwards.
|
||||
ij = min_m_n - ij - b;
|
||||
}
|
||||
|
||||
|
||||
// Compute offset increments and dimensions based on which
|
||||
// subpartition is being requested, assuming no transposition.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user