Implemented castm, castv operations.

Details:
- Implemented castm and castv operations, which behave like copym and
  copyv except where the obj_t operands can be of different datatypes.
  These new operations, however, unlike copym/copyv, do not build upon
  existing level-1v kernels.
- Reorganized projm, projv into a 'proj' subdirectory of frame/base (to
  match the newly added frame/base/cast directory).
- Added new macros to bli_gentfunc_macro_defs.h, _gentprot_macro_defs.h
  that insert GENTFUNC2/GENTPROT2 macros for all non-homogeneous datatype
  combinations. Previously, one had to invoke two additional macros--one
  which mixed domains only and another that included all remaining
  cases--in order to get full type combination coverage.
- Defined a new static function, bli_set_dims_incs_2m(), to aid in the
  setting of various variables in the implementations of bli_??castm().
  This static function joins others like it in bli_param_macro_defs.h.
- Comment update to bli_copysc.h.
This commit is contained in:
Field G. Van Zee
2018-06-18 15:56:26 -05:00
parent ed20392c50
commit e88a5b8da8
17 changed files with 1122 additions and 44 deletions

View File

@@ -49,7 +49,7 @@ GENFRONT( copysc )
//
// Define BLAS-like interfaces with heterogeneous-typed operands.
// Prototype BLAS-like interfaces with heterogeneous-typed operands.
//
#undef GENTPROT2

267
frame/base/cast/bli_castm.c Normal file
View File

@@ -0,0 +1,267 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blis.h"
// NOTE: This is one of the few functions in BLIS that is defined
// with heterogeneous type support. This is done so that we have
// an operation that can be used to typecast (copy-cast) a matrix
// of one datatype to a scalar of another datatype.
typedef void (*FUNCPTR_T)
(
trans_t transa,
dim_t m,
dim_t n,
void* restrict a, inc_t rs_a, inc_t cs_a,
void* restrict b, inc_t rs_b, inc_t cs_b
);
static FUNCPTR_T GENARRAY2_ALL(ftypes,castm);
//
// Define object-based interface.
//
void bli_castm
(
obj_t* a,
obj_t* b
)
{
num_t dt_a = bli_obj_dt( a );
num_t dt_b = bli_obj_dt( b );
trans_t transa = bli_obj_conjtrans_status( a );
dim_t m = bli_obj_length( b );
dim_t n = bli_obj_width( b );
void* buf_a = bli_obj_buffer_at_off( a );
inc_t rs_a = bli_obj_row_stride( a );
inc_t cs_a = bli_obj_col_stride( a );
void* buf_b = bli_obj_buffer_at_off( b );
inc_t rs_b = bli_obj_row_stride( b );
inc_t cs_b = bli_obj_col_stride( b );
FUNCPTR_T f;
// Check parameters.
if ( bli_error_checking_is_enabled() )
bli_castm_check( a, b );
#if 0
if ( bli_obj_dt( a ) == bli_obj_dt( b ) )
{
// If a and b share the same datatype, we can simply use copym.
bli_copym( a, b );
return;
}
#endif
// Index into the type combination array to extract the correct
// function pointer.
f = ftypes[dt_a][dt_b];
// Invoke the void pointer-based function.
f
(
transa,
m,
n,
buf_a, rs_a, cs_a,
buf_b, rs_b, cs_b
);
}
// -----------------------------------------------------------------------------
//
// Define BLAS-like interfaces with typed operands.
//
#undef GENTFUNC2
#define GENTFUNC2( ctype_a, ctype_b, cha, chb, opname ) \
\
void PASTEMAC2(cha,chb,opname) \
( \
trans_t transa, \
dim_t m, \
dim_t n, \
void* restrict a, inc_t rs_a, inc_t cs_a, \
void* restrict b, inc_t rs_b, inc_t cs_b \
) \
{ \
ctype_a* restrict a_cast = a; \
ctype_b* restrict b_cast = b; \
conj_t conja; \
dim_t n_iter; \
dim_t n_elem; \
inc_t lda, inca; \
inc_t ldb, incb; \
dim_t j, i; \
\
/* Set various loop parameters. */ \
bli_set_dims_incs_2m \
( \
transa, \
m, n, rs_a, cs_a, rs_b, cs_b, \
&n_elem, &n_iter, &inca, &lda, &incb, &ldb \
); \
\
/* Extract the conjugation component from the transa parameter. */ \
conja = bli_extract_conj( transa ); \
\
if ( bli_is_conj( conja ) ) \
{ \
if ( inca == 1 && incb == 1 ) \
{ \
for ( j = 0; j < n_iter; ++j ) \
{ \
ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \
ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \
\
for ( i = 0; i < n_elem; ++i ) \
{ \
PASTEMAC2(cha,chb,copyjs)( a1[i], b1[i] ); \
} \
} \
} \
else \
{ \
for ( j = 0; j < n_iter; ++j ) \
{ \
ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \
ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \
\
for ( i = 0; i < n_elem; ++i ) \
{ \
PASTEMAC2(cha,chb,copyjs)( *a1, *b1 ); \
\
a1 += inca; \
b1 += incb; \
} \
} \
} \
} \
else \
{ \
if ( inca == 1 && incb == 1 ) \
{ \
for ( j = 0; j < n_iter; ++j ) \
{ \
ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \
ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \
\
for ( i = 0; i < n_elem; ++i ) \
{ \
PASTEMAC2(cha,chb,copys)( a1[i], b1[i] ); \
} \
} \
} \
else \
{ \
for ( j = 0; j < n_iter; ++j ) \
{ \
ctype_a* restrict a1 = a_cast + (j )*lda + (0 )*inca; \
ctype_b* restrict b1 = b_cast + (j )*ldb + (0 )*incb; \
\
for ( i = 0; i < n_elem; ++i ) \
{ \
PASTEMAC2(cha,chb,copys)( *a1, *b1 ); \
\
a1 += inca; \
b1 += incb; \
} \
} \
} \
} \
}
INSERT_GENTFUNC2_BASIC0( castm )
INSERT_GENTFUNC2_MIXDP0( castm )
// -----------------------------------------------------------------------------
//
// Define object-based _check() function.
//
void bli_castm_check
(
obj_t* a,
obj_t* b
)
{
err_t e_val;
// Check object datatypes.
e_val = bli_check_floating_object( a );
bli_check_error_code( e_val );
e_val = bli_check_floating_object( b );
bli_check_error_code( e_val );
// Check structure.
// NOTE: We enforce general structure for now in order to simplify the
// implementation.
bli_check_general_object( a );
bli_check_error_code( e_val );
bli_check_general_object( b );
bli_check_error_code( e_val );
// Check object dimensions.
e_val = bli_check_matrix_object( a );
bli_check_error_code( e_val );
e_val = bli_check_matrix_object( b );
bli_check_error_code( e_val );
e_val = bli_check_conformal_dims( a, b );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( a );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( b );
bli_check_error_code( e_val );
}

View File

@@ -0,0 +1,73 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// Prototype object-based interface.
//
void bli_castm
(
obj_t* a,
obj_t* b
);
//
// Prototype BLAS-like interfaces with heterogeneous-typed operands.
//
#undef GENTPROT2
#define GENTPROT2( ctype_a, ctype_b, cha, chb, opname ) \
\
void PASTEMAC2(cha,chb,opname) \
( \
trans_t transa, \
dim_t m, \
dim_t n, \
void* a, inc_t rs_a, inc_t cs_a, \
void* b, inc_t rs_b, inc_t cs_b \
);
INSERT_GENTPROT2_BASIC0( castm )
INSERT_GENTPROT2_MIXDP0( castm )
//
// Prototype object-based _check() function.
//
void bli_castm_check
(
obj_t* a,
obj_t* b
);

211
frame/base/cast/bli_castv.c Normal file
View File

@@ -0,0 +1,211 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blis.h"
// NOTE: This is one of the few functions in BLIS that is defined
// with heterogeneous type support. This is done so that we have
// an operation that can be used to typecast (copy-cast) a matrix
// of one datatype to a scalar of another datatype.
typedef void (*FUNCPTR_T)
(
conj_t conjx,
dim_t n,
void* restrict x, inc_t inc_x,
void* restrict y, inc_t inc_y
);
static FUNCPTR_T GENARRAY2_ALL(ftypes,castv);
//
// Define object-based interface.
//
void bli_castv
(
obj_t* x,
obj_t* y
)
{
num_t dt_x = bli_obj_dt( x );
num_t dt_y = bli_obj_dt( y );
conj_t conjx = bli_obj_conj_status( x );
dim_t n = bli_obj_vector_dim( x );
void* buf_x = bli_obj_buffer_at_off( x );
inc_t inc_x = bli_obj_vector_inc( x );
void* buf_y = bli_obj_buffer_at_off( y );
inc_t inc_y = bli_obj_vector_inc( y );
FUNCPTR_T f;
// Check parameters.
if ( bli_error_checking_is_enabled() )
bli_castv_check( x, y );
#if 0
if ( bli_obj_dt( x ) == bli_obj_dt( y ) )
{
// If x and y share the same datatype, we can simply use copyv.
bli_copyv( x, y );
return;
}
#endif
// Index into the type combination array to extract the correct
// function pointer.
f = ftypes[dt_x][dt_y];
// Invoke the void pointer-based function.
f
(
conjx,
n,
buf_x, inc_x,
buf_y, inc_y
);
}
// -----------------------------------------------------------------------------
//
// Define BLAS-like interfaces with typed operands.
//
#undef GENTFUNC2
#define GENTFUNC2( ctype_x, ctype_y, chx, chy, opname ) \
\
void PASTEMAC2(chx,chy,opname) \
( \
conj_t conjx, \
dim_t n, \
void* restrict x, inc_t incx, \
void* restrict y, inc_t incy \
) \
{ \
ctype_x* restrict x1 = x; \
ctype_y* restrict y1 = y; \
dim_t i; \
\
if ( bli_is_conj( conjx ) ) \
{ \
if ( incx == 1 && incy == 1 ) \
{ \
for ( i = 0; i < n; ++i ) \
{ \
PASTEMAC2(chx,chy,copyjs)( x1[i], y1[i] ); \
} \
} \
else \
{ \
for ( i = 0; i < n; ++i ) \
{ \
PASTEMAC2(chx,chy,copyjs)( *x1, *y1 ); \
\
x1 += incx; \
y1 += incy; \
} \
} \
} \
else \
{ \
if ( incx == 1 && incy == 1 ) \
{ \
for ( i = 0; i < n; ++i ) \
{ \
PASTEMAC2(chx,chy,copys)( x1[i], y1[i] ); \
} \
} \
else \
{ \
for ( i = 0; i < n; ++i ) \
{ \
PASTEMAC2(chx,chy,copys)( *x1, *y1 ); \
\
x1 += incx; \
y1 += incy; \
} \
} \
} \
}
INSERT_GENTFUNC2_BASIC0( castv )
INSERT_GENTFUNC2_MIXDP0( castv )
// -----------------------------------------------------------------------------
//
// Define object-based _check() function.
//
void bli_castv_check
(
obj_t* x,
obj_t* y
)
{
err_t e_val;
// Check object datatypes.
e_val = bli_check_floating_object( x );
bli_check_error_code( e_val );
e_val = bli_check_floating_object( y );
bli_check_error_code( e_val );
// Check object dimensions.
e_val = bli_check_vector_object( x );
bli_check_error_code( e_val );
e_val = bli_check_vector_object( y );
bli_check_error_code( e_val );
e_val = bli_check_equal_vector_lengths( x, y );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( x );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( y );
bli_check_error_code( e_val );
}

View File

@@ -0,0 +1,72 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
//
// Prototype object-based interface.
//
void bli_castv
(
obj_t* x,
obj_t* y
);
//
// Prototype BLAS-like interfaces with heterogeneous-typed operands.
//
#undef GENTPROT2
#define GENTPROT2( ctype_x, ctype_y, chx, chy, opname ) \
\
void PASTEMAC2(chx,chy,opname) \
( \
conj_t conjx, \
dim_t n, \
void* x, inc_t incx, \
void* y, inc_t incy \
);
INSERT_GENTPROT2_BASIC0( castv )
INSERT_GENTPROT2_MIXDP0( castv )
//
// Prototype object-based _check() function.
//
void bli_castv_check
(
obj_t* x,
obj_t* y
);

View File

@@ -0,0 +1,118 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blis.h"
void bli_castm_check
(
obj_t* a,
obj_t* b
)
{
err_t e_val;
// Check object datatypes.
e_val = bli_check_floating_object( a );
bli_check_error_code( e_val );
e_val = bli_check_floating_object( b );
bli_check_error_code( e_val );
// Check structure.
// NOTE: We enforce general structure for now in order to simplify the
// implementation.
bli_check_general_object( a );
bli_check_error_code( e_val );
bli_check_general_object( b );
bli_check_error_code( e_val );
// Check object dimensions.
e_val = bli_check_matrix_object( a );
bli_check_error_code( e_val );
e_val = bli_check_matrix_object( b );
bli_check_error_code( e_val );
e_val = bli_check_conformal_dims( a, b );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( a );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( b );
bli_check_error_code( e_val );
}
void bli_castv_check
(
obj_t* x,
obj_t* y
)
{
err_t e_val;
// Check object datatypes.
e_val = bli_check_floating_object( x );
bli_check_error_code( e_val );
e_val = bli_check_floating_object( y );
bli_check_error_code( e_val );
// Check object dimensions.
e_val = bli_check_vector_object( x );
bli_check_error_code( e_val );
e_val = bli_check_vector_object( y );
bli_check_error_code( e_val );
e_val = bli_check_equal_vector_lengths( x, y );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( x );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( y );
bli_check_error_code( e_val );
}

View File

@@ -32,15 +32,13 @@
*/
#include "bli_proj_check.h"
void bli_projm
void bli_castm_check
(
obj_t* a,
obj_t* b
);
void bli_projv
void bli_castv_check
(
obj_t* x,
obj_t* y

View File

@@ -84,52 +84,44 @@ void bli_projm
}
}
void bli_projv
// -----------------------------------------------------------------------------
void bli_projm_check
(
obj_t* x,
obj_t* y
obj_t* a,
obj_t* b
)
{
// Check parameters.
if ( bli_error_checking_is_enabled() )
bli_projv_check( x, y );
err_t e_val;
if ( ( bli_obj_is_real( x ) && bli_obj_is_real( y ) ) ||
( bli_obj_is_complex( x ) && bli_obj_is_complex( y ) ) )
{
// If x and y are both real or both complex, we can simply use
// copyv.
bli_copyv( x, y );
}
else
{
// This branch handles the case where one operand is real and
// the other is complex.
// Check object datatypes.
if ( bli_obj_is_real( x ) /* && bli_obj_is_complex( y ) */ )
{
// If x is real and y is complex, we must obtain the real part
// of y so that we can copy x into the real part (after
// initializing all of y, including imaginary components, to
// zero).
e_val = bli_check_floating_object( a );
bli_check_error_code( e_val );
obj_t yr;
e_val = bli_check_floating_object( b );
bli_check_error_code( e_val );
bli_obj_real_part( y, &yr );
e_val = bli_check_consistent_object_precisions( a, b );
bli_check_error_code( e_val );
bli_setv( &BLIS_ZERO, y );
bli_copyv( x, &yr );
}
else // bli_obj_is_complex( x ) && bli_obj_is_real( y )
{
// If x is complex and y is real, we can simply copy the
// real part of x into y.
// Check object dimensions.
obj_t xr;
e_val = bli_check_matrix_object( a );
bli_check_error_code( e_val );
bli_obj_real_part( x, &xr );
e_val = bli_check_matrix_object( b );
bli_check_error_code( e_val );
bli_copyv( &xr, y );
}
}
e_val = bli_check_conformal_dims( a, b );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( a );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( b );
bli_check_error_code( e_val );
}

View File

@@ -0,0 +1,46 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void bli_projm
(
obj_t* a,
obj_t* b
);
void bli_projm_check
(
obj_t* a,
obj_t* b
);

127
frame/base/proj/bli_projv.c Normal file
View File

@@ -0,0 +1,127 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "blis.h"
void bli_projv
(
obj_t* x,
obj_t* y
)
{
// Check parameters.
if ( bli_error_checking_is_enabled() )
bli_projv_check( x, y );
if ( ( bli_obj_is_real( x ) && bli_obj_is_real( y ) ) ||
( bli_obj_is_complex( x ) && bli_obj_is_complex( y ) ) )
{
// If x and y are both real or both complex, we can simply use
// copyv.
bli_copyv( x, y );
}
else
{
// This branch handles the case where one operand is real and
// the other is complex.
if ( bli_obj_is_real( x ) /* && bli_obj_is_complex( y ) */ )
{
// If x is real and y is complex, we must obtain the real part
// of y so that we can copy x into the real part (after
// initializing all of y, including imaginary components, to
// zero).
obj_t yr;
bli_obj_real_part( y, &yr );
bli_setv( &BLIS_ZERO, y );
bli_copyv( x, &yr );
}
else // bli_obj_is_complex( x ) && bli_obj_is_real( y )
{
// If x is complex and y is real, we can simply copy the
// real part of x into y.
obj_t xr;
bli_obj_real_part( x, &xr );
bli_copyv( &xr, y );
}
}
}
// -----------------------------------------------------------------------------
void bli_projv_check
(
obj_t* x,
obj_t* y
)
{
err_t e_val;
// Check object datatypes.
e_val = bli_check_floating_object( x );
bli_check_error_code( e_val );
e_val = bli_check_floating_object( y );
bli_check_error_code( e_val );
e_val = bli_check_consistent_object_precisions( x, y );
bli_check_error_code( e_val );
// Check object dimensions.
e_val = bli_check_vector_object( x );
bli_check_error_code( e_val );
e_val = bli_check_vector_object( y );
bli_check_error_code( e_val );
e_val = bli_check_equal_vector_lengths( x, y );
bli_check_error_code( e_val );
// Check object buffers (for non-NULLness).
e_val = bli_check_object_buffer( x );
bli_check_error_code( e_val );
e_val = bli_check_object_buffer( y );
bli_check_error_code( e_val );
}

View File

@@ -0,0 +1,46 @@
/*
BLIS
An object-based framework for developing high-performance BLAS-like
libraries.
Copyright (C) 2014, The University of Texas at Austin
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of The University of Texas at Austin nor the names
of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void bli_projv
(
obj_t* x,
obj_t* y
);
void bli_projv_check
(
obj_t* x,
obj_t* y
);

View File

@@ -402,6 +402,51 @@ GENTFUNC2( dcomplex, scomplex, z, c, tfuncname, varname ) \
// -- Mixed domain/precision (all) two-operand macro --
// -- (no auxiliary arguments) --
#define INSERT_GENTFUNC2_MIXDP0( tfuncname ) \
\
GENTFUNC2( float, double, s, d, tfuncname ) \
GENTFUNC2( float, scomplex, s, c, tfuncname ) \
GENTFUNC2( float, dcomplex, s, z, tfuncname ) \
\
GENTFUNC2( double, float, d, s, tfuncname ) \
GENTFUNC2( double, scomplex, d, c, tfuncname ) \
GENTFUNC2( double, dcomplex, d, z, tfuncname ) \
\
GENTFUNC2( scomplex, float, c, s, tfuncname ) \
GENTFUNC2( scomplex, double, c, d, tfuncname ) \
GENTFUNC2( scomplex, dcomplex, c, z, tfuncname ) \
\
GENTFUNC2( dcomplex, float, z, s, tfuncname ) \
GENTFUNC2( dcomplex, double, z, d, tfuncname ) \
GENTFUNC2( dcomplex, scomplex, z, c, tfuncname )
// -- (one auxiliary argument) --
#define INSERT_GENTFUNC2_MIX_DP( tfuncname, varname ) \
\
GENTFUNC2( float, double, s, d, tfuncname, varname ) \
GENTFUNC2( float, scomplex, s, c, tfuncname, varname ) \
GENTFUNC2( float, dcomplex, s, z, tfuncname, varname ) \
\
GENTFUNC2( double, float, d, s, tfuncname, varname ) \
GENTFUNC2( double, scomplex, d, c, tfuncname, varname ) \
GENTFUNC2( double, dcomplex, d, z, tfuncname, varname ) \
\
GENTFUNC2( scomplex, float, c, s, tfuncname, varname ) \
GENTFUNC2( scomplex, double, c, d, tfuncname, varname ) \
GENTFUNC2( scomplex, dcomplex, c, z, tfuncname, varname ) \
\
GENTFUNC2( dcomplex, float, z, s, tfuncname, varname ) \
GENTFUNC2( dcomplex, double, z, d, tfuncname, varname ) \
GENTFUNC2( dcomplex, scomplex, z, c, tfuncname, varname )
// -- Basic two-operand with real projection of first operand --
// -- (no auxiliary arguments) --

View File

@@ -395,6 +395,50 @@ GENTPROT2( dcomplex, scomplex, z, c, tfuncname, varname ) \
// -- Mixed domain/precision (all) two-operand macro --
// -- (no auxiliary arguments) --
#define INSERT_GENTPROT2_MIXDP0( funcname ) \
\
GENTPROT2( float, double, s, d, funcname ) \
GENTPROT2( float, scomplex, s, c, funcname ) \
GENTPROT2( float, dcomplex, s, z, funcname ) \
\
GENTPROT2( double, float, d, s, funcname ) \
GENTPROT2( double, scomplex, d, c, funcname ) \
GENTPROT2( double, dcomplex, d, z, funcname ) \
\
GENTPROT2( scomplex, float, c, s, funcname ) \
GENTPROT2( scomplex, double, c, d, funcname ) \
GENTPROT2( scomplex, dcomplex, c, z, funcname ) \
\
GENTPROT2( dcomplex, float, z, s, funcname ) \
GENTPROT2( dcomplex, double, z, d, funcname ) \
GENTPROT2( dcomplex, scomplex, z, c, funcname )
// -- (one auxiliary argument) --
#define INSERT_GENTPROT2_MIX_DP( tfuncname, varname ) \
\
GENTPROT2( float, double, s, d, tfuncname, varname ) \
GENTPROT2( float, scomplex, s, c, tfuncname, varname ) \
GENTPROT2( float, dcomplex, s, z, tfuncname, varname ) \
\
GENTPROT2( double, float, d, s, tfuncname, varname ) \
GENTPROT2( double, scomplex, d, c, tfuncname, varname ) \
GENTPROT2( double, dcomplex, d, z, tfuncname, varname ) \
\
GENTPROT2( scomplex, float, c, s, tfuncname, varname ) \
GENTPROT2( scomplex, double, c, d, tfuncname, varname ) \
GENTPROT2( scomplex, dcomplex, c, z, tfuncname, varname ) \
\
GENTPROT2( dcomplex, float, z, s, tfuncname, varname ) \
GENTPROT2( dcomplex, double, z, d, tfuncname, varname ) \
GENTPROT2( dcomplex, scomplex, z, c, tfuncname, varname )
// -- Basic two-operand with real projection of first operand --
// -- (no auxiliary arguments) --

View File

@@ -990,6 +990,41 @@ void bli_set_dims_incs_uplo_1m_noswap
}
}
// Set dimensions and increments for TWO matrix arguments.
static
void bli_set_dims_incs_2m
(
trans_t transa,
dim_t m, dim_t n, inc_t rs_a, inc_t cs_a,
inc_t rs_b, inc_t cs_b,
dim_t* n_elem, dim_t* n_iter, inc_t* inca, inc_t* lda,
inc_t* incb, inc_t* ldb
)
{
{
*n_iter = n;
*n_elem = m;
*inca = rs_a;
*lda = cs_a;
*incb = rs_b;
*ldb = cs_b;
if ( bli_does_trans( transa ) )
{
bli_swap_incs( inca, lda );
}
if ( bli_is_row_tilted( *n_elem, *n_iter, *incb, *ldb ) &&
bli_is_row_tilted( *n_elem, *n_iter, *inca, *lda ) )
{
bli_swap_dims( n_iter, n_elem );
bli_swap_incs( inca, lda );
bli_swap_incs( incb, ldb );
}
}
}
// Set dimensions, increments, effective uplo/diagoff, etc for TWO matrix
// arguments.
@@ -1033,7 +1068,7 @@ void bli_set_dims_incs_uplo_2m
if ( bli_is_stored_subpart( diagoffa_use_, transa, uploa, m, n ) )
uploa = BLIS_DENSE;
n_iter_max_ = n;
n_iter_max_ = n;
*n_elem_max = m;
*inca = rs_a;
*lda = cs_a;

View File

@@ -122,9 +122,13 @@ extern "C" {
#include "bli_cpuid.h"
#include "bli_string.h"
#include "bli_setgetij.h"
#include "bli_proj.h"
#include "bli_setri.h"
#include "bli_castm.h"
#include "bli_castv.h"
#include "bli_projm.h"
#include "bli_projv.h"
// -- Level-0 operations --