Skip to content

Commit

Permalink
test: check blas_int; include in run_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mgates3 committed Sep 22, 2024
1 parent 3f81267 commit 5108f75
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/get_type_name.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// -----------------------------------------------------------------------------
// see https://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c
#include <type_traits>
#include <typeinfo>
#include <memory>
#include <string>
#include <cstdlib>

// for demangling on non-Microsoft platforms
#ifndef _MSC_VER
#include <cxxabi.h>
#endif

template <typename T>
std::string get_type_name()
{
using T_noref = typename std::remove_reference<T>::type;

std::unique_ptr< char, void(*)(void*) > own(
#ifndef _MSC_VER
abi::__cxa_demangle( typeid( T_noref ).name(), nullptr, nullptr, nullptr ),
#else
nullptr,
#endif
std::free
);

std::string r = own != nullptr ? own.get() : typeid( T_noref ).name();
if (std::is_const<T_noref>::value)
r += " const";
if (std::is_volatile<T_noref>::value)
r += " volatile";
if (std::is_lvalue_reference<T>::value)
r += "&";
else if (std::is_rvalue_reference<T>::value)
r += "&&";
return r;
}
2 changes: 2 additions & 0 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,8 @@ def filter_csv( values, csv ):

if (opts.aux):
cmds += [
[ 'util', '' ],

[ 'memcpy', dtype + n ],
[ 'copy_vector', dtype + n + incx_pos + incy_pos ],
[ 'set_vector', dtype + n + incx_pos + incy_pos ],
Expand Down
11 changes: 11 additions & 0 deletions test/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,21 @@

#include "test.hh"
#include "../src/device_internal.hh"
#include "get_type_name.hh"
#include "blas/config.h"

#include <string>

using testsweeper::get_wtime;

// -----------------------------------------------------------------------------
void test_types()
{
printf( "%s\n", __func__ );
printf( "\tblas_int is %s\n", get_type_name<blas_int>().c_str() );
printf( "\tsizeof( blas_int ) = %lld\n", llong( sizeof( blas_int ) ) );
}

// -----------------------------------------------------------------------------
void test_enums()
{
Expand Down Expand Up @@ -884,6 +894,7 @@ void test_util( Params& params, bool run )
if (first) {
first = false;

test_types();
test_enums();
test_exceptions();
test_abs1();
Expand Down

0 comments on commit 5108f75

Please sign in to comment.