void stressTest (Blackbox & A) { //Note that the rowdim/coldim of A must be 30000 typedef typename Blackbox::MatrixDomain Dom; typedef typename Dom::Block Block; Dom MD = A.domain(); size_t m = 30000; size_t n = 2000; LinBox::UserTimer timer; Block B(m,n), C(m,n); MD.random(B); cout << "Test: 30000x30000 matrix multiplied by 30000x2000 matrix\nblock size = 2048\n\n"; timer.clear(); timer.start(); A.unpackingApply(C,B,2048); timer.stop(); cout << "unpacking apply time: " << timer << endl; Block D(m,m); MD.random(D); timer.clear(); timer.start(); MD.mul(C,D,B); timer.stop(); cout << "domain mul time: " << timer << endl; cout << endl; } //end stressTest()
void blockSizeTimingTest(Blackbox & A, size_t size) { typedef typename Blackbox::MatrixDomain Dom; typedef typename Dom::Block Block; Dom MD = A.domain(); size_t m = A.rowdim(); LinBox::UserTimer timer; Block B(m,m), C(m,m), D(m,m); MD.random(B); MD.random(D); cout << size << " " << m << " "; timer.clear(); timer.start(); A.unpackingApply(C,B,size); timer.stop(); cout << timer << " "; timer.clear(); timer.start(); A.unpackingApplyTranspose(C,B,size); timer.stop(); cout << timer << " "; timer.clear(); timer.start(); MD.mul(C,D,B); timer.stop(); cout << timer << " "; cout << endl; } //blockSizeTimingTest()
void testTiming(Blackbox & A) { typedef typename Blackbox::MatrixDomain Dom; typedef typename Dom::Block Block; Dom MD = A.domain(); size_t m = A.rowdim(), n = A.coldim(); size_t k = (m + n)/2; LinBox::UserTimer timer; Block B(n,k), C(m,k), D(k,m), E(k,n), F(k,k); MD.random(B); MD.random(D); vector<typename Dom::Element> v1, v2(m); typename Dom::RandIter r(MD); typename Dom::Element x; for(size_t i = 0; i != n; ++i){ r.random(x); v1.push_back(x); } //Tests: cout << "Timing tests:" << endl << endl; timer.clear(); timer.start(); for(size_t j = 0; j != m; ++j) A.apply(v2,v1); timer.stop(); cout << "apply using vectors time: " << timer << endl; timer.clear(); timer.start(); A.applyTranspose(C,B); timer.stop(); cout << "apply using row addin time: " << timer << endl; timer.clear(); timer.start(); A.unpackingApplyTranspose(C,B); timer.stop(); cout << "apply using block axpy time: " << timer << endl; timer.clear(); timer.start(); MD.mul(F, D, C); timer.stop(); cout << "Matrix Domain mul time: " << timer << endl; cout << "End of timing tests" << endl << endl; } // testTiming
void largeTest (Blackbox & A) { //Use for large blackboxes typedef typename Blackbox::MatrixDomain Dom; typedef typename Dom::Block Block; Dom MD = A.domain(); size_t m = A.coldim(); size_t n = 2000; LinBox::UserTimer timer; Block B(m,n), C(m,n); MD.random(B); cout << "Test: " << A.rowdim() << "x" << m << "blackbox multiplied by " << m << "x" << n << "block\nblock size: 2048\n\n"; timer.clear(); timer.start(); A.unpackingApply(C,B,2048); timer.stop(); cout << "unpacking apply time: " << timer << endl; } //end largeTest
bool testAssociativity(Blackbox& A) { typedef typename Blackbox::MatrixDomain Dom; Dom MD = A.domain(); size_t m = A.rowdim(), n = A.coldim() - 100; size_t k = (m + n)/2; typename Dom::Block B(A.field(),k,m), C(A.field(),m,n); MD.random(B); MD.random(C); typename Dom::Block D(A.field(),m,n), E(A.field(),k,n); A.apply(D, C); // D = AC MD.mul(E,B,D); // E = B(AC) typename Dom::Block F(A.field(),k,m), G(A.field(),k,n); A.unpackingApplyTranspose(F,B); // F = BA MD.mul(G,F,C); // G = (BA)C return MD.areEqual(E,G); } // testAssociativity