mirror of
https://github.com/amd/blis.git
synced 2026-05-11 17:50:00 +00:00
Fixed build issue in cpp testsuite.
This issue was caused by incorrect merging of cpp and testcpp files. Change-Id: Idc40fbdaa55b6052a6a061d2d3e5cfae76b99916 AMD-Internal: [CPUPL-1067]
This commit is contained in:
@@ -27,7 +27,6 @@
|
||||
#define BLIS_HH
|
||||
|
||||
#include "cblas.hh"
|
||||
#include "blis_util.hh"
|
||||
|
||||
namespace blis {
|
||||
|
||||
@@ -406,10 +405,7 @@ TR dot(
|
||||
T const *x, int64_t incx,
|
||||
T const *y, int64_t incy )
|
||||
{
|
||||
if((std::is_same<T, float>::value)&(std::is_same<TR, double>::value))
|
||||
return cblas_dsdot( n, x, incx, y, incy );
|
||||
else
|
||||
return cblas_dot( n, x, incx, y, incy );
|
||||
return cblas_dot( n, x, incx, y, incy );
|
||||
}
|
||||
|
||||
/*! \brief Performs the dot product of two complex vectors
|
||||
|
||||
226
cpp/blis_util.hh
226
cpp/blis_util.hh
@@ -1,226 +0,0 @@
|
||||
#ifndef BLIS_UTIL_HH
|
||||
#define BLIS_UTIL_HH
|
||||
|
||||
#include <complex>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace blis {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Extend real, imag, conj to other datatypes.
|
||||
template< typename T >
|
||||
inline T real( T x ) { return x; }
|
||||
|
||||
template< typename T >
|
||||
inline T imag( T x ) { return 0; }
|
||||
|
||||
template< typename T >
|
||||
inline T conj( T x ) { return x; }
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// 1-norm absolute value, |Re(x)| + |Im(x)|
|
||||
template< typename T >
|
||||
T abs1( T x )
|
||||
{
|
||||
return std::abs( x );
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
T abs1( std::complex<T> x )
|
||||
{
|
||||
return std::abs( real(x) ) + std::abs( imag(x) );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// common_type_t is defined in C++14; here's a C++11 definition
|
||||
#if __cplusplus >= 201402L
|
||||
using std::common_type_t;
|
||||
using std::decay_t;
|
||||
#else
|
||||
template< typename... Ts >
|
||||
using common_type_t = typename std::common_type< Ts... >::type;
|
||||
|
||||
template< typename... Ts >
|
||||
using decay_t = typename std::decay< Ts... >::type;
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/// True if T is std::complex<T2> for some type T2.
|
||||
template <typename T>
|
||||
struct is_complex:
|
||||
std::integral_constant<bool, false>
|
||||
{};
|
||||
|
||||
// specialize for std::complex
|
||||
template <typename T>
|
||||
struct is_complex< std::complex<T> >:
|
||||
std::integral_constant<bool, true>
|
||||
{};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Based on C++14 common_type implementation from
|
||||
// http://www.cplusplus.com/reference/type_traits/common_type/
|
||||
// Adds promotion of complex types based on the common type of the associated
|
||||
// real types. This fixes various cases:
|
||||
//
|
||||
// std::common_type_t< double, complex<float> > is complex<float> (wrong)
|
||||
// scalar_type< double, complex<float> > is complex<double> (right)
|
||||
//
|
||||
// std::common_type_t< int, complex<long> > is not defined (compile error)
|
||||
// scalar_type< int, complex<long> > is complex<long> (right)
|
||||
|
||||
// for zero types
|
||||
template< typename... Types >
|
||||
struct scalar_type_traits;
|
||||
|
||||
// define scalar_type<> type alias
|
||||
template< typename... Types >
|
||||
using scalar_type = typename scalar_type_traits< Types... >::type;
|
||||
|
||||
// for one type
|
||||
template< typename T >
|
||||
struct scalar_type_traits< T >
|
||||
{
|
||||
using type = decay_t<T>;
|
||||
};
|
||||
|
||||
// for two types
|
||||
// relies on type of ?: operator being the common type of its two arguments
|
||||
template< typename T1, typename T2 >
|
||||
struct scalar_type_traits< T1, T2 >
|
||||
{
|
||||
using type = decay_t< decltype( true ? std::declval<T1>() : std::declval<T2>() ) >;
|
||||
};
|
||||
|
||||
// for either or both complex,
|
||||
// find common type of associated real types, then add complex
|
||||
template< typename T1, typename T2 >
|
||||
struct scalar_type_traits< std::complex<T1>, T2 >
|
||||
{
|
||||
using type = std::complex< common_type_t< T1, T2 > >;
|
||||
};
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
struct scalar_type_traits< T1, std::complex<T2> >
|
||||
{
|
||||
using type = std::complex< common_type_t< T1, T2 > >;
|
||||
};
|
||||
|
||||
template< typename T1, typename T2 >
|
||||
struct scalar_type_traits< std::complex<T1>, std::complex<T2> >
|
||||
{
|
||||
using type = std::complex< common_type_t< T1, T2 > >;
|
||||
};
|
||||
|
||||
// for three or more types
|
||||
template< typename T1, typename T2, typename... Types >
|
||||
struct scalar_type_traits< T1, T2, Types... >
|
||||
{
|
||||
using type = scalar_type< scalar_type< T1, T2 >, Types... >;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// for any combination of types, determine associated real, scalar,
|
||||
// and complex types.
|
||||
//
|
||||
// real_type< float > is float
|
||||
// real_type< float, double, complex<float> > is double
|
||||
//
|
||||
// scalar_type< float > is float
|
||||
// scalar_type< float, complex<float> > is complex<float>
|
||||
// scalar_type< float, double, complex<float> > is complex<double>
|
||||
//
|
||||
// complex_type< float > is complex<float>
|
||||
// complex_type< float, double > is complex<double>
|
||||
// complex_type< float, double, complex<float> > is complex<double>
|
||||
|
||||
// for zero types
|
||||
template< typename... Types >
|
||||
struct real_type_traits;
|
||||
|
||||
// define real_type<> type alias
|
||||
template< typename... Types >
|
||||
using real_type = typename real_type_traits< Types... >::real_t;
|
||||
|
||||
// define complex_type<> type alias
|
||||
template< typename... Types >
|
||||
using complex_type = std::complex< real_type< Types... > >;
|
||||
|
||||
// for one type
|
||||
template< typename T >
|
||||
struct real_type_traits<T>
|
||||
{
|
||||
using real_t = T;
|
||||
};
|
||||
|
||||
// for one complex type, strip complex
|
||||
template< typename T >
|
||||
struct real_type_traits< std::complex<T> >
|
||||
{
|
||||
using real_t = T;
|
||||
};
|
||||
|
||||
// for two or more types
|
||||
template< typename T1, typename... Types >
|
||||
struct real_type_traits< T1, Types... >
|
||||
{
|
||||
using real_t = scalar_type< real_type<T1>, real_type< Types... > >;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// max that works with different data types: int64_t = max( int, int64_t )
|
||||
// and any number of arguments: max( a, b, c, d )
|
||||
|
||||
// one argument
|
||||
template< typename T >
|
||||
T max( T x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
// two arguments
|
||||
template< typename T1, typename T2 >
|
||||
scalar_type< T1, T2 >
|
||||
max( T1 x, T2 y )
|
||||
{
|
||||
return (x >= y ? x : y);
|
||||
}
|
||||
|
||||
// three or more arguments
|
||||
template< typename T1, typename... Types >
|
||||
scalar_type< T1, Types... >
|
||||
max( T1 first, Types... args )
|
||||
{
|
||||
return max( first, max( args... ) );
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// min that works with different data types: int64_t = min( int, int64_t )
|
||||
// and any number of arguments: min( a, b, c, d )
|
||||
|
||||
// one argument
|
||||
template< typename T >
|
||||
T min( T x )
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
// two arguments
|
||||
template< typename T1, typename T2 >
|
||||
scalar_type< T1, T2 >
|
||||
min( T1 x, T2 y )
|
||||
{
|
||||
return (x <= y ? x : y);
|
||||
}
|
||||
|
||||
// three or more arguments
|
||||
template< typename T1, typename... Types >
|
||||
scalar_type< T1, Types... >
|
||||
min( T1 first, Types... args )
|
||||
{
|
||||
return min( first, min( args... ) );
|
||||
}
|
||||
|
||||
} // namespace blis
|
||||
|
||||
#endif // #ifndef BLIS_UTIL_HH
|
||||
@@ -33,14 +33,8 @@
|
||||
|
||||
#include <complex>
|
||||
#include <iostream>
|
||||
<<<<<<< HEAD
|
||||
#include "blis.hh"
|
||||
#include "test.hh"
|
||||
=======
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include "blis.hh"
|
||||
>>>>>>> Code Cleanup done; Test code updated to add performance measurement
|
||||
|
||||
using namespace blis;
|
||||
using namespace std;
|
||||
@@ -160,88 +154,10 @@ void test_gemm( )
|
||||
// -----------------------------------------------------------------------------
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
test_gemm<double>( );
|
||||
test_gemm<float>( );
|
||||
test_gemm<complex<float>>( );
|
||||
test_gemm<complex<double>>( );
|
||||
return 0;
|
||||
=======
|
||||
int M, N, K, lda, ldb, ldc;
|
||||
double a_d[DIM * DIM] = { 1.111, 2.222, 3.333, 4.444 };
|
||||
double b_d[DIM * DIM] = { 5.555, 6.666, 7.777, 8.888 };
|
||||
double c_d[DIM * DIM];
|
||||
double alpha_d, beta_d;
|
||||
float a_f[DIM * DIM] = { 1.1, 2.2, 3.3, 4.4 };
|
||||
float b_f[DIM * DIM] = { 5.5, 6.6, 7.7, 8.8 };
|
||||
float c_f[DIM * DIM];
|
||||
float alpha_f, beta_f;
|
||||
std::complex<float> a_c[DIM * DIM]={{1, 2},{3, 4},{5,6},{7,8}};
|
||||
std::complex<float> b_c[DIM * DIM]={{1, 2},{3, 4},{5,6},{7,8}};
|
||||
std::complex<float> c_c[DIM * DIM];
|
||||
std::complex<float> alpha_c, beta_c;
|
||||
std::complex<double> a_z[DIM * DIM]={{1.1, 2.2},{3.3, 4.4},{5.5,6.6},{7.7,8.8}};
|
||||
std::complex<double> b_z[DIM * DIM]={{1.1, 2.2},{3.3, 4.4},{5.5,6.6},{7.7,8.8}};
|
||||
std::complex<double> c_z[DIM * DIM];
|
||||
std::complex<double> alpha_z, beta_z;
|
||||
M = DIM;
|
||||
N = M;
|
||||
K = M;
|
||||
lda = M;
|
||||
ldb = K;
|
||||
ldc = M;
|
||||
alpha_d = 1.0;
|
||||
beta_d = 0.0;
|
||||
alpha_f = 1.0;
|
||||
beta_f = 0.0;
|
||||
alpha_c = {1.0,1.0};
|
||||
beta_c = {0.0,0.0};
|
||||
alpha_z = {1.0,1.0};
|
||||
beta_z = {0.0,0.0};
|
||||
|
||||
/*cblis_sgemm*/
|
||||
cout<<"a_f= \n";
|
||||
print_matrix<float>(a_f , M , K);
|
||||
cout<<"b_f= \n";
|
||||
print_matrix<float>(b_f , K , N);
|
||||
blis::gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha_f, a_f,
|
||||
lda, b_f, ldb, beta_f, c_f, ldc);
|
||||
cout<<"c_f= \n";
|
||||
print_matrix<float>(c_f , M , N);
|
||||
|
||||
|
||||
/*cblis_dgemm*/
|
||||
printf("a_d = \n");
|
||||
print_matrix<double>(a_d , M , K);
|
||||
printf("b_d = \n");
|
||||
print_matrix<double>(b_d , K , N);
|
||||
blis::gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha_d, a_d,
|
||||
lda, b_d, ldb, beta_d, c_d, ldc);
|
||||
printf("c_d = \n");
|
||||
print_matrix<double>(c_d , M , N);
|
||||
|
||||
|
||||
/*cblis_cgemm*/
|
||||
printf("a_c = \n");
|
||||
print_matrix<std::complex<float>>(a_c , M , K);
|
||||
printf("b_c = \n");
|
||||
print_matrix<std::complex<float>>(b_c , K , N);
|
||||
blis::gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha_c, a_c,
|
||||
lda, b_c, ldb, beta_c, c_c, ldc);
|
||||
printf("c_c = \n");
|
||||
print_matrix<std::complex<float>>(c_c , M , N);
|
||||
|
||||
|
||||
/*cblis_zgemm*/
|
||||
printf("a_z = \n");
|
||||
print_matrix<std::complex<double>>(a_z , M , K);
|
||||
printf("b_z = \n");
|
||||
print_matrix<std::complex<double>>(b_z , K , N);
|
||||
blis::gemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha_z, a_z,
|
||||
lda, b_z, ldb, beta_z, c_z, ldc);
|
||||
printf("c_z = \n");
|
||||
print_matrix<std::complex<double>>(c_z , M , N);
|
||||
return 0;
|
||||
>>>>>>> Code Cleanup done; Test code updated to add performance measurement
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user