Commit a7614e72 authored by Jö Fahlke's avatar Jö Fahlke

Explicit instantiation for multirhstest

Closes: #14
parent 36c9cd4f
Pipeline #18564 passed with stage
in 7 minutes and 55 seconds
......@@ -13,6 +13,11 @@ set(AVX512_COMPILE_FLAGS
-mavx -mavx2 -mfma
-mavx512f -mavx512cd -mavx512bw -mavx512dq -mavx512vl)
######################################################################
#
# vectorclasstest
#
dune_instance_begin(FILES vectorclasstest.hh vectorclasstest.cc)
foreach(VECTOR_SIZE IN ITEMS 128 256 512)
......@@ -56,9 +61,38 @@ foreach(iset IN ITEMS sse2 avx avx2 avx512)
COMPILE_FLAGS ${${ISET}_COMPILE_FLAGS}
LINK_LIBRARIES dunecommon
)
endforeach(iset)
######################################################################
#
# multirhstest
#
dune_instance_begin(FILES multirhstest.hh multirhstest.cc)
foreach(VECTOR_SIZE IN ITEMS 128 256 512)
# float and associated types
math(EXPR LANES "${VECTOR_SIZE} / 32")
set(TYPE f)
dune_instance_add(ID "${LANES}${TYPE}"
FILES multirhstest_vector.cc)
# double and associated types
math(EXPR LANES "${VECTOR_SIZE} / 64")
set(TYPE d)
dune_instance_add(ID "${LANES}${TYPE}"
FILES multirhstest_vector.cc)
endforeach(VECTOR_SIZE)
dune_instance_end()
dune_list_filter(DUNE_INSTANCE_GENERATED INCLUDE REGEX [[\.cc$]])
foreach(iset IN ITEMS sse2 avx avx2 avx512)
string(TOUPPER "${iset}" ISET)
dune_add_test(NAME multirhstest-${iset}
SOURCES multirhstest.cc
SOURCES ${DUNE_INSTANCE_GENERATED}
COMPILE_DEFINITIONS -DMAX_VECTOR_SIZE=${MAX_VECTOR_SIZE}
COMPILE_FLAGS ${${ISET}_COMPILE_FLAGS}
LINK_LIBRARIES dunecommon
......@@ -66,6 +100,11 @@ foreach(iset IN ITEMS sse2 avx avx2 avx512)
)
endforeach(iset)
######################################################################
#
# further tests
#
set(RUNS 10)
dune_add_test(NAME multirhsperftest-jacobi-scalar
......
#include "config.h"
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <dune/common/classname.hh>
#include <dune/common/simd/loop.hh>
#include <dune/common/simd/simd.hh>
#include <dune/common/timer.hh>
#include <dune/istl/test/multirhstest.hh>
#include <dune/vectorclass/vectorclass.hh>
struct runInformation {
double vectorTime;
double scalarTime;
double loopTime;
std::string vectorName;
std::string scalarName;
std::string loopName;
int lanes;
};
template<class T>
runInformation performTest(){
runInformation result;
const int size = Dune::Simd::lanes<T>();
typedef Dune::Simd::Scalar<T> scalarType;
typedef Dune::LoopSIMD<scalarType,size> loopType;
result.vectorName = Dune::className<T>();
result.scalarName = Dune::className<scalarType>();
result.loopName = Dune::className<loopType>();
result.lanes = size;
Dune::Timer t;
test_all<T>();
result.vectorTime = t.stop();
t.reset();
t.start();
test_all<scalarType>();
result.scalarTime = t.stop();
t.reset();
t.start();
test_all<loopType>();
result.loopTime = t.stop();
return result;
}
// includes vectorclass.hh
#include "multirhstest.hh"
int main(int argc, char ** argv)
{
std::vector<runInformation> times;
#if MAX_VECTOR_SIZE >= 128
times.push_back(performTest<Vec4f>());
times.push_back(performTest<Vec2d>());
#endif
#if MAX_VECTOR_SIZE >= 256
times.push_back(performTest<Vec8f>());
times.push_back(performTest<Vec4d>());
#endif
#if MAX_VECTOR_SIZE >= 512
times.push_back(performTest<Vec16f>());
times.push_back(performTest<Vec8d>());
#endif
#cmake @template@
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
times.push_back(performTest<Vec@LANES@@TYPE@>());
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
#cmake @endtemplate@
for(auto el : times) {
double totalScalarTime = el.lanes * el.scalarTime;
......
#ifndef DUNE_VECTORCLASS_TEST_MULTIRHSTEST_HH
#define DUNE_VECTORCLASS_TEST_MULTIRHSTEST_HH
#include <string>
#include <dune/common/classname.hh>
#include <dune/common/simd/loop.hh>
#include <dune/common/simd/simd.hh>
#include <dune/common/timer.hh>
#include <dune/istl/test/multirhstest.hh>
#include <dune/vectorclass/vectorclass.hh>
struct runInformation {
double vectorTime;
double scalarTime;
double loopTime;
std::string vectorName;
std::string scalarName;
std::string loopName;
int lanes;
};
template<class T>
runInformation performTest(){
runInformation result;
const int size = Dune::Simd::lanes<T>();
typedef Dune::Simd::Scalar<T> scalarType;
typedef Dune::LoopSIMD<scalarType,size> loopType;
result.vectorName = Dune::className<T>();
result.scalarName = Dune::className<scalarType>();
result.loopName = Dune::className<loopType>();
result.lanes = size;
Dune::Timer t;
test_all<T>();
result.vectorTime = t.stop();
t.reset();
t.start();
test_all<scalarType>();
result.scalarTime = t.stop();
t.reset();
t.start();
test_all<loopType>();
result.loopTime = t.stop();
return result;
}
#cmake @template@
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
extern template runInformation performTest<Vec@LANES@@TYPE@>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
#cmake @endtemplate@
#endif // DUNE_VECTORCLASS_TEST_MULTIRHSTEST_HH
#include "config.h"
// includes vectorclass.hh
#include "multirhstest.hh"
#if MAX_VECTOR_SIZE >= @VECTOR_SIZE@
template runInformation performTest<Vec@LANES@@TYPE@>();
#endif // MAX_VECTOR_SIZE >= @VECTOR_SIZE@
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment