Beispiel #1
0
siz_t bli_thread_get_range_weighted_b2t
     (
       thrinfo_t* thr,
       obj_t*     a,
       blksz_t*   bmult,
       dim_t*     start,
       dim_t*     end
     )
{
	siz_t area;

	// This function assigns area-weighted ranges in the m dimension
	// where the total range spans 0 to m-1 with 0 at the bottom end and
	// m-1 at the top end.

	if ( bli_obj_intersects_diag( *a ) &&
	     bli_obj_is_upper_or_lower( *a ) )
	{
		doff_t diagoff = bli_obj_diag_offset( *a );
		uplo_t uplo    = bli_obj_uplo( *a );
		dim_t  m       = bli_obj_length( *a );
		dim_t  n       = bli_obj_width( *a );
		dim_t  bf      = bli_blksz_get_def_for_obj( a, bmult );

		// Support implicit transposition.
		if ( bli_obj_has_trans( *a ) )
		{
			bli_reflect_about_diag( diagoff, uplo, m, n );
		}

		bli_reflect_about_diag( diagoff, uplo, m, n );

		bli_rotate180_trapezoid( diagoff, uplo );

		area = bli_thread_get_range_weighted_sub
		(
		  thr, diagoff, uplo, m, n, bf,
		  TRUE, start, end
		);
	}
	else // if dense or zeros
	{
		area = bli_thread_get_range_b2t
		(
		  thr, a, bmult,
		  start, end
		);
	}

	return area;
}
Beispiel #2
0
void bli_trsm_l_blk_var4( obj_t*  alpha,
                          obj_t*  a,
                          obj_t*  b,
                          obj_t*  beta,
                          obj_t*  c,
                          trsm_t* cntl )
{
    obj_t a1, a1_pack;
    obj_t b_pack;
    obj_t c1;

    dim_t i;
    dim_t bm_alg;
    dim_t m_trans;
    dim_t offB;

    // Initialize all pack objects that are passed into packm_init().
    bli_obj_init_pack( &a1_pack );
    bli_obj_init_pack( &b_pack );

    // Query dimension in partitioning direction.
    m_trans = bli_obj_length_after_trans( *a );

    // Use the diagonal offset of A to skip over the zero region.
    offB = bli_abs( bli_obj_diag_offset_after_trans( *a ) );

    // Initialize object for packing B.
    bli_packm_init( b, &b_pack,
                    cntl_sub_packm_b( cntl ) );

    // Fuse the first iteration with incremental packing and computation.
    {
        obj_t b_inc, b_pack_inc;
        obj_t c1_inc;

        dim_t j;
        dim_t bn_inc;
        dim_t n_trans;

        // Query dimension in partitioning direction.
        n_trans = bli_obj_width( b_pack );

        // Determine the current algorithmic blocksize.
        bm_alg = bli_determine_blocksize_f( offB, m_trans, a,
                                            cntl_blocksize( cntl ) );

        // Acquire partitions for A1 and C1.
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               offB, bm_alg, a, &a1 );
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               offB, bm_alg, c, &c1 );

        // Initialize objects for packing A1 and C1.
        bli_packm_init( &a1, &a1_pack, cntl_sub_packm_a( cntl ) );

        // Pack A1 and scale by alpha (if instructed).
        bli_packm_int( alpha, &a1, &a1_pack, cntl_sub_packm_a( cntl ) );

        // Partition along the n dimension.
        for ( j = 0; j < n_trans; j += bn_inc )
        {
            // Determine the current incremental packing blocksize.
            bn_inc = bli_determine_blocksize_f( j, n_trans, b,
                                                cntl_blocksize_aux( cntl ) );

            // Acquire partitions.
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, b, &b_inc );
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, &b_pack, &b_pack_inc );
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, &c1, &c1_inc );

            // Pack B1 and scale by alpha (if instructed).
            bli_packm_int( alpha, &b_inc, &b_pack_inc, cntl_sub_packm_b( cntl ) );

            // Perform trsm subproblem.
            bli_trsm_int( BLIS_LEFT,
                          alpha,
                          &a1_pack,
                          &b_pack_inc,
                          beta,
                          &c1_inc,
                          cntl_sub_trsm( cntl ) );
        }

        // Unpack B to the corresponding region of C. (Note that B and C1 are
        // conformal since A1 is square.)
        //bli_unpackm_int( &b_pack, &c1,
        //                 cntl_sub_unpackm_c( cntl ) );
    }

    // Partition along the remaining portion of the m dimension.
    for ( i = offB + bm_alg; i < m_trans; i += bm_alg )
    {
        // Determine the current algorithmic blocksize.
        bm_alg = bli_determine_blocksize_f( i, m_trans, a,
                                            cntl_blocksize( cntl ) );

        // Acquire partitions for A1 and C1.
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               i, bm_alg, a, &a1 );
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               i, bm_alg, c, &c1 );

        // Initialize object for packing A1.
        bli_packm_init( &a1, &a1_pack,
                        cntl_sub_packm_a( cntl ) );

        // Pack A1 and scale by alpha (if instructed).
        bli_packm_int( alpha,
                       &a1, &a1_pack,
                       cntl_sub_packm_a( cntl ) );

        // Perform trsm subproblem.
        if ( bli_obj_intersects_diag( a1_pack ) )
            bli_trsm_int( BLIS_LEFT,
                          alpha,
                          &a1_pack,
                          &b_pack,
                          beta,
                          &c1,
                          cntl_sub_trsm( cntl ) );
        else
            bli_gemm_int( &BLIS_MINUS_ONE,
                          &a1_pack,
                          &b_pack,
                          &BLIS_ONE,
                          &c1,
                          cntl_sub_gemm( cntl ) );
    }

    // 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( &b_pack );
}
Beispiel #3
0
void bli_trmm_lu_blk_var4( obj_t*  alpha,
                           obj_t*  a,
                           obj_t*  b,
                           obj_t*  beta,
                           obj_t*  c,
                           trmm_t* cntl )
{
    obj_t a1, a1_pack;
    obj_t b_pack;
    obj_t c1, c1_pack;

    dim_t i;
    dim_t bm_alg;
    dim_t mT_trans;

    // Initialize all pack objects that are passed into packm_init().
    bli_obj_init_pack( &a1_pack );
    bli_obj_init_pack( &b_pack );
    bli_obj_init_pack( &c1_pack );

    // Query dimension in partitioning direction. Use the diagonal offset
    // to stop short of the zero region.
    mT_trans = bli_abs( bli_obj_diag_offset_after_trans( *a ) ) +
               bli_obj_width_after_trans( *a );

    // Scale C by beta (if instructed).
    bli_scalm_int( beta,
                   c,
                   cntl_sub_scalm( cntl ) );

    // Initialize object for packing B.
    bli_packm_init( b, &b_pack,
                    cntl_sub_packm_b( cntl ) );

    // Fuse the first iteration with incremental packing and computation.
    {
        obj_t b_inc, b_pack_inc;
        obj_t c1_pack_inc;

        dim_t j;
        dim_t bn_inc;
        dim_t n_trans;

        // Query dimension in partitioning direction.
        n_trans = bli_obj_width( b_pack );

        // Determine the current algorithmic blocksize.
        bm_alg = bli_determine_blocksize_f( 0, mT_trans, a,
                                            cntl_blocksize( cntl ) );

        // Acquire partitions for A1 and C1.
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               0, bm_alg, a, &a1 );
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               0, bm_alg, c, &c1 );

        // Initialize objects for packing A1 and C1.
        bli_packm_init( &a1, &a1_pack, cntl_sub_packm_a( cntl ) );
        bli_packm_init( &c1, &c1_pack, cntl_sub_packm_c( cntl ) );

        // Pack A1 and scale by alpha (if instructed).
        bli_packm_int( alpha, &a1, &a1_pack, cntl_sub_packm_a( cntl ) );

        // Pack C1 and scale by beta (if instructed).
        bli_packm_int( beta,  &c1, &c1_pack, cntl_sub_packm_c( cntl ) );

        // Partition along the n dimension.
        for ( j = 0; j < n_trans; j += bn_inc )
        {
            // Determine the current incremental packing blocksize.
            bn_inc = bli_determine_blocksize_f( j, n_trans, b,
                                                cntl_blocksize_aux( cntl ) );

            // Acquire partitions.
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, b, &b_inc );
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, &b_pack, &b_pack_inc );
            bli_acquire_mpart_l2r( BLIS_SUBPART1,
                                   j, bn_inc, &c1_pack, &c1_pack_inc );

            // Pack B1 and scale by alpha (if instructed).
            bli_packm_int( alpha, &b_inc, &b_pack_inc, cntl_sub_packm_b( cntl ) );

            // Perform trmm subproblem.
            bli_trmm_int( BLIS_LEFT,
                          alpha,
                          &a1_pack,
                          &b_pack_inc,
                          beta,
                          &c1_pack_inc,
                          cntl_sub_trmm( cntl ) );
        }

        // Unpack C1 (if C1 was packed).
        bli_unpackm_int( &c1_pack, &c1, cntl_sub_unpackm_c( cntl ) );
    }


    // Partition along the remaining portion of the m dimension.
    for ( i = bm_alg; i < mT_trans; i += bm_alg )
    {
        // Determine the current algorithmic blocksize.
        bm_alg = bli_determine_blocksize_f( i, mT_trans, a,
                                            cntl_blocksize( cntl ) );

        // Acquire partitions for A1 and C1.
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               i, bm_alg, a, &a1 );
        bli_acquire_mpart_t2b( BLIS_SUBPART1,
                               i, bm_alg, c, &c1 );

        // Initialize objects for packing A1 and C1.
        bli_packm_init( &a1, &a1_pack,
                        cntl_sub_packm_a( cntl ) );
        bli_packm_init( &c1, &c1_pack,
                        cntl_sub_packm_c( cntl ) );

        // Pack A1 and scale by alpha (if instructed).
        bli_packm_int( alpha,
                       &a1, &a1_pack,
                       cntl_sub_packm_a( cntl ) );

        // Pack C1 and scale by beta (if instructed).
        bli_packm_int( beta,
                       &c1, &c1_pack,
                       cntl_sub_packm_c( cntl ) );

        // Perform trmm subproblem.
        if ( bli_obj_intersects_diag( a1_pack ) )
            bli_trmm_int( BLIS_LEFT,
                          alpha,
                          &a1_pack,
                          &b_pack,
                          beta,
                          &c1_pack,
                          cntl_sub_trmm( cntl ) );
        else
            bli_gemm_int( alpha,
                          &a1_pack,
                          &b_pack,
                          &BLIS_ONE,
                          &c1_pack,
                          cntl_sub_gemm( cntl ) );

        // Unpack C1 (if C1 was packed).
        bli_unpackm_int( &c1_pack, &c1,
                         cntl_sub_unpackm_c( cntl ) );
    }

    // 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( &b_pack );
    bli_obj_release_pack( &c1_pack );
}
void bli_trsm_u_blk_var4( obj_t*  alpha,
                          obj_t*  a,
                          obj_t*  b,
                          obj_t*  beta,
                          obj_t*  c,
                          trsm_t* cntl )
{
	obj_t a1, a1_pack;
	obj_t b_pack;
	obj_t c1;

	dim_t i;
	dim_t bm_alg;
	dim_t m_trans;

	// Initialize all pack objects that are passed into packm_init().
	bli_obj_init_pack( &a1_pack );
	bli_obj_init_pack( &b_pack );

	// Query dimension in partitioning direction.
	m_trans = bli_obj_length_after_trans( *a );

	// Initialize object for packing B.
	bli_packm_init( b, &b_pack,
	                cntl_sub_packm_b( cntl ) );

	// Find the offset to the first non-zero block of A.
	for ( i = 0; i < m_trans; i += bm_alg )
	{
		// Determine the current algorithmic blocksize.
		bm_alg = bli_determine_blocksize_b( i, m_trans, a,
		                                    cntl_blocksize( cntl ) );

		// Acquire partitions for A1 and C1.
		bli_acquire_mpart_b2t( BLIS_SUBPART1,
		                       i, bm_alg, a, &a1 );

		if ( !bli_obj_is_zeros( a1 ) ) break;
	}

	// Fuse the first iteration with incremental packing and computation.
	{
		obj_t b_inc, b_pack_inc;
		obj_t c1_inc;

		dim_t j;
		dim_t bn_inc;
		dim_t n_trans;

		// Query dimension in partitioning direction.
		n_trans = bli_obj_width( b_pack );

		// Determine the current algorithmic blocksize.
		bm_alg = bli_determine_blocksize_b( i, m_trans, a,
		                                    cntl_blocksize( cntl ) );

		// Acquire partitions for A1 and C1.
		bli_acquire_mpart_b2t( BLIS_SUBPART1,
		                       i, bm_alg, a, &a1 );
		bli_acquire_mpart_b2t( BLIS_SUBPART1,
		                       i, bm_alg, c, &c1 );

		// Initialize objects for packing A1 and C1.
		bli_packm_init( &a1, &a1_pack, cntl_sub_packm_a( cntl ) );

		// Pack A1 and scale by alpha (if instructed).
		bli_packm_int( alpha, &a1, &a1_pack, cntl_sub_packm_a( cntl ) );

		// Partition along the n dimension.
		for ( j = 0; j < n_trans; j += bn_inc )
		{
			// Determine the current incremental packing blocksize.
			bn_inc = bli_determine_blocksize_f( j, n_trans, b,
			                                    cntl_blocksize_aux( cntl ) );

			// Acquire partitions.
			bli_acquire_mpart_l2r( BLIS_SUBPART1,
			                       j, bn_inc, b, &b_inc );
			bli_acquire_mpart_l2r( BLIS_SUBPART1,
			                       j, bn_inc, &b_pack, &b_pack_inc );
			bli_acquire_mpart_l2r( BLIS_SUBPART1,
			                       j, bn_inc, &c1, &c1_inc );

			// Pack B1 and scale by alpha (if instructed).
			bli_packm_int( alpha, &b_inc, &b_pack_inc, cntl_sub_packm_b( cntl ) );

			// Perform trsm subproblem.
			bli_trsm_int( BLIS_LEFT,
			              alpha,
			              &a1_pack,
			              &b_pack_inc,
			              beta,
			              &c1_inc,
			              cntl_sub_trsm( cntl ) );
		}
	}

	// Partition along the remaining portion of the m dimension.
	for ( i = i + bm_alg; i < m_trans; i += bm_alg )
	{
		// Determine the current algorithmic blocksize.
		bm_alg = bli_determine_blocksize_b( i, m_trans, a,
		                                    cntl_blocksize( cntl ) );

		// Acquire partitions for A1 and C1.
		bli_acquire_mpart_b2t( BLIS_SUBPART1,
		                       i, bm_alg, a, &a1 );
		bli_acquire_mpart_b2t( BLIS_SUBPART1,
		                       i, bm_alg, c, &c1 );

		// Initialize object for packing A1.
		bli_packm_init( &a1, &a1_pack,
		                cntl_sub_packm_a( cntl ) );

		// Pack A1 and scale by alpha (if instructed).
		bli_packm_int( alpha,
		               &a1, &a1_pack,
		               cntl_sub_packm_a( cntl ) );

		if ( bli_obj_intersects_diag( a1_pack ) )
			bli_trsm_int( BLIS_LEFT,
			              alpha,
			              &a1_pack,
			              &b_pack,
			              beta,
			              &c1,
			              cntl_sub_trsm( cntl ) );
		else
			bli_gemm_int( &BLIS_MINUS_ONE,
			              &a1_pack,
			              &b_pack,
			              &BLIS_ONE,
			              &c1,
			              cntl_sub_gemm( cntl ) );
	}

	// 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( &b_pack );
}