|
Revision 76, 1.2 kB
(checked in by pernet, 3 months ago)
|
|
Add simple benchmarking examples
|
| Line | |
|---|
| 1 | #include <iostream> |
|---|
| 2 | |
|---|
| 3 | #include "fflas-ffpack/ffpack.h" |
|---|
| 4 | #include "fflas-ffpack/modular-balanced.h" |
|---|
| 5 | #include "timer.h" |
|---|
| 6 | #include "Matio.h" |
|---|
| 7 | |
|---|
| 8 | using namespace std; |
|---|
| 9 | |
|---|
| 10 | int main(int argc, char** argv) { |
|---|
| 11 | |
|---|
| 12 | // parameter: p, n, iteration, file |
|---|
| 13 | |
|---|
| 14 | float p = atof(argv[1]); |
|---|
| 15 | int n = atoi(argv[2]); |
|---|
| 16 | size_t iter = atoi(argv[3]); |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | typedef ModularBalanced<double> Field; |
|---|
| 20 | // typedef ModularBalanced<float> Field; |
|---|
| 21 | typedef Field::Element Element; |
|---|
| 22 | |
|---|
| 23 | Field F(p); |
|---|
| 24 | |
|---|
| 25 | Timer chrono; |
|---|
| 26 | double time=0.0; |
|---|
| 27 | int singular; |
|---|
| 28 | |
|---|
| 29 | Element *A; |
|---|
| 30 | |
|---|
| 31 | for (size_t i=0;i<iter;++i){ |
|---|
| 32 | |
|---|
| 33 | A = new Element[n*n]; |
|---|
| 34 | Field::RandIter G(F); |
|---|
| 35 | for (size_t i=0; i< n*n; ++i) |
|---|
| 36 | G.random(*(A+i)); |
|---|
| 37 | |
|---|
| 38 | size_t * P = new size_t[n]; |
|---|
| 39 | size_t * Q = new size_t[n]; |
|---|
| 40 | |
|---|
| 41 | chrono.clear(); |
|---|
| 42 | chrono.start(); |
|---|
| 43 | FFPACK::LUdivine (F, FFLAS::FflasNonUnit, FFLAS::FflasNoTrans, n, n, A, n, |
|---|
| 44 | P, Q); |
|---|
| 45 | chrono.stop(); |
|---|
| 46 | |
|---|
| 47 | time+=chrono.realtime(); |
|---|
| 48 | delete[] P; |
|---|
| 49 | delete[] Q; |
|---|
| 50 | delete[] A; |
|---|
| 51 | |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | cerr<<"n: "<<n<<" p: "<<p<<std::endl |
|---|
| 55 | <<" time: "<<time/iter<<std::endl |
|---|
| 56 | <<" speed: "<<2/3.0*n/1000.0*n/1000.0*n/1000.0/time*iter<<" Gffops"<<std::endl; |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | return 0; |
|---|
| 60 | } |
|---|