-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support block matrices in several BLAS1 routines #226
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
90b6408
Update Hadamard, Dot, ColumnTwoNorms, ColumnMaxNorms, and HilbertSchm…
ndryden 4afe36a
Add check for whether the same block size is used in Hadamard and Hil…
ndryden be1c42a
Test Hadamard, Dot, ColumnTwoNorms, and ColumnMaxNorms at higher prec…
ndryden e9139f4
Remove unneeded macro checks and use a more rigorous bound in the Col…
ndryden File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
Copyright (c) 2009-2016, Jack Poulson | ||
All rights reserved. | ||
|
||
This file is part of Elemental and is under the BSD 2-Clause License, | ||
which can be found in the LICENSE file in the root directory, or at | ||
http://opensource.org/licenses/BSD-2-Clause | ||
*/ | ||
|
||
#include <El.hpp> | ||
using namespace El; | ||
|
||
template <typename T, DistWrap W> | ||
void TestColumnTwoNorms(Int m, Int n, const Grid& g, bool print) | ||
{ | ||
// Generate random matrix to test. | ||
DistMatrix<T, MC, MR, W> A(g); | ||
Uniform(A, m, n); | ||
if (print) | ||
Print(A, "A"); | ||
DistMatrix<T, MR, STAR, W> norms(g); | ||
ColumnTwoNorms(A, norms); | ||
if (print) | ||
Print(norms, "norms"); | ||
for (Int j = 0; j < A.LocalWidth(); ++j) | ||
{ | ||
T got = norms.GetLocal(j, 0); | ||
T expected = 0; | ||
for (Int i = 0; i < A.LocalHeight(); ++i) | ||
{ | ||
T val = A.GetLocal(i, j); | ||
expected += val * val; | ||
} | ||
expected = mpi::AllReduce(expected, g.ColComm()); | ||
expected = Sqrt(expected); | ||
// Compute max(expected, 1) to use relative bound. | ||
// (std::max and El::Max don't support BigFloat. | ||
T div = expected > 1 ? expected : 1; | ||
if (Abs(got - expected) / div > m * n * 10 * limits::Epsilon<El::Base<T>>()) | ||
{ | ||
Output("Results do not match, norms(", j, ")=", got, | ||
" instead of ", expected); | ||
RuntimeError("got != expected"); | ||
} | ||
} | ||
} | ||
|
||
template <typename T, DistWrap W> | ||
void TestColumnMaxNorms(Int m, Int n, const Grid& g, bool print) | ||
{ | ||
// Generate random matrix to test. | ||
DistMatrix<T, MC, MR, W> A(g); | ||
Uniform(A, m, n); | ||
if (print) | ||
Print(A, "A"); | ||
DistMatrix<T, MR, STAR, W> norms(g); | ||
ColumnMaxNorms(A, norms); | ||
if (print) | ||
Print(norms, "norms"); | ||
for (Int j = 0; j < A.LocalWidth(); ++j) | ||
{ | ||
T got = norms.GetLocal(j, 0); | ||
T expected = 0; | ||
for (Int i = 0; i < A.LocalHeight(); ++i) | ||
expected = Max(expected, Abs(A.GetLocal(i, j))); | ||
T r; | ||
mpi::AllReduce(&expected, &r, 1, mpi::MAX, g.ColComm()); | ||
expected = r; | ||
if (got != expected) | ||
{ | ||
Output("Results do not match, norms(", j, ")=", got, | ||
" instead of ", expected); | ||
RuntimeError("got != expected"); | ||
} | ||
} | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
Environment env(argc, argv); | ||
mpi::Comm comm = mpi::COMM_WORLD; | ||
try | ||
{ | ||
const Int m = Input("--m", "height", 100); | ||
const Int n = Input("--n", "width", 100); | ||
const bool print = Input("--print", "print matrices?", false); | ||
ProcessInput(); | ||
PrintInputReport(); | ||
|
||
const Grid g(comm); | ||
OutputFromRoot(comm, "Testing ColumnTwoNorms"); | ||
TestColumnTwoNorms<float, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<float, BLOCK>(m, n, g, print); | ||
TestColumnTwoNorms<double, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<double, BLOCK>(m, n, g, print); | ||
#if defined(EL_HAVE_QD) | ||
TestColumnTwoNorms<DoubleDouble, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<DoubleDouble, BLOCK>(m, n, g, print); | ||
TestColumnTwoNorms<QuadDouble, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<QuadDouble, BLOCK>(m, n, g, print); | ||
#endif | ||
#if defined(EL_HAVE_QUAD) | ||
TestColumnTwoNorms<Quad, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<Quad, BLOCK>(m, n, g, print); | ||
#endif | ||
#if defined(EL_HAVE_MPC) | ||
TestColumnTwoNorms<BigFloat, ELEMENT>(m, n, g, print); | ||
TestColumnTwoNorms<BigFloat, BLOCK>(m, n, g, print); | ||
#endif | ||
OutputFromRoot(comm, "Testing ColumnMaxNorms"); | ||
TestColumnMaxNorms<float, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<float, BLOCK>(m, n, g, print); | ||
TestColumnMaxNorms<double, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<double, BLOCK>(m, n, g, print); | ||
#if defined(EL_HAVE_QD) | ||
TestColumnMaxNorms<DoubleDouble, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<DoubleDouble, BLOCK>(m, n, g, print); | ||
TestColumnMaxNorms<QuadDouble, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<QuadDouble, BLOCK>(m, n, g, print); | ||
#endif | ||
#if defined(EL_HAVE_QUAD) | ||
TestColumnMaxNorms<Quad, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<Quad, BLOCK>(m, n, g, print); | ||
#endif | ||
#if defined(EL_HAVE_MPC) | ||
TestColumnMaxNorms<BigFloat, ELEMENT>(m, n, g, print); | ||
TestColumnMaxNorms<BigFloat, BLOCK>(m, n, g, print); | ||
#endif | ||
} | ||
catch (exception& e) | ||
{ | ||
ReportException(e); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you noticing this crucial portion of the extension!