Example #1
0
void bli_trmm_blk_var2f( obj_t*  a,
                         obj_t*  b,
                         obj_t*  c,
                         trmm_t* cntl )
{
    obj_t a_pack;
    obj_t b1, b1_pack;
    obj_t c1, c1_pack;

    dim_t i;
    dim_t b_alg;
    dim_t n_trans;

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

    // Query dimension in partitioning direction.
    n_trans = bli_obj_width_after_trans( *b );

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

    // Initialize object for packing A.
    bli_packm_init( a, &a_pack,
                    cntl_sub_packm_a( cntl ) );

    // Pack A (if instructed).
    bli_packm_int( a, &a_pack,
                   cntl_sub_packm_a( cntl ) );

    // Partition along the n dimension.
    for ( i = 0; i < n_trans; i += b_alg )
    {
        // Determine the current algorithmic blocksize.
        b_alg = bli_determine_blocksize_f( i, n_trans, b,
                                           cntl_blocksize( cntl ) );

        // Acquire partitions for B1 and C1.
        bli_acquire_mpart_l2r( BLIS_SUBPART1,
                               i, b_alg, b, &b1 );
        bli_acquire_mpart_l2r( BLIS_SUBPART1,
                               i, b_alg, c, &c1 );

        // Initialize objects for packing A1 and B1.
        bli_packm_init( &b1, &b1_pack,
                        cntl_sub_packm_b( cntl ) );
        bli_packm_init( &c1, &c1_pack,
                        cntl_sub_packm_c( cntl ) );

        // Pack B1 (if instructed).
        bli_packm_int( &b1, &b1_pack,
                       cntl_sub_packm_b( cntl ) );

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

        // Perform trmm subproblem.
        bli_trmm_int( &BLIS_ONE,
                      &a_pack,
                      &b1_pack,
                      &BLIS_ONE,
                      &c1_pack,
                      cntl_sub_trmm( 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( &a_pack );
    bli_obj_release_pack( &b1_pack );
    bli_obj_release_pack( &c1_pack );
}
Example #2
0
void bli_trmm_lu_blk_var1( 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 b_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 );

	// If A is [upper] triangular, use the diagonal offset of A to determine
	// the length of the non-zero region.
	if ( bli_obj_is_triangular( *a ) )
		mT_trans = bli_abs( bli_obj_diag_offset_after_trans( *a ) ) +
		           bli_obj_width_after_trans( *a );
	else // if ( bli_obj_is_general( *a )
		mT_trans = bli_obj_length_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 ) );

	// Pack B and scale by alpha (if instructed).
	bli_packm_int( alpha,
	               b, &b_pack,
	               cntl_sub_packm_b( cntl ) );

	// Partition along the m dimension.
	for ( i = 0; i < mT_trans; i += b_alg )
	{
		// Determine the current algorithmic blocksize.
		b_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, b_alg, a, &a1 );
		bli_acquire_mpart_t2b( BLIS_SUBPART1,
		                       i, b_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.
		bli_trmm_int( BLIS_LEFT,
		              alpha,
		              &a1_pack,
		              &b_pack,
		              beta,
		              &c1_pack,
		              cntl_sub_trmm( 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 );
}
Example #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 );
}
Example #4
0
void bli_trmm_blk_var1( 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 b_alg;
	dim_t m_trans;
	dim_t offA;

	// 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 );

	// Set the default length of and offset to the non-zero part of A.
	m_trans = bli_obj_length_after_trans( *a );
	offA    = 0;

	// If A is lower triangular, we have to adjust where the non-zero part of
	// A begins. If A is upper triangular, we have to adjust the length of
	// the non-zero part. If A is general/dense, then we keep the defaults.
	if      ( bli_obj_is_lower( *a ) )
		offA    = bli_abs( bli_obj_diag_offset_after_trans( *a ) );
	else if ( bli_obj_is_upper( *a ) )
		m_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 ) );

	// Pack B and scale by alpha (if instructed).
	bli_packm_int( alpha,
	               b, &b_pack,
	               cntl_sub_packm_b( cntl ) );

	// Partition along the m dimension.
	for ( i = offA; i < m_trans; i += b_alg )
	{
		// Determine the current algorithmic blocksize.
		b_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, b_alg, a, &a1 );
		bli_acquire_mpart_t2b( BLIS_SUBPART1,
		                       i, b_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.
		bli_trmm_int( alpha,
		              &a1_pack,
		              &b_pack,
		              beta,
		              &c1_pack,
		              cntl_sub_trmm( 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 );
}