Skip to content
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

Dense Matrix Unit Test Refactoring #170

Merged
merged 16 commits into from
Dec 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Enforcing specific vector type in implementation specific vector tests.
rcrutherford committed Dec 22, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 4060b720c8a4e85e9b4f2fad8711f16d927bee6c
32 changes: 25 additions & 7 deletions tests/LinAlg/vectorTestsPar.cpp
Original file line number Diff line number Diff line change
@@ -63,23 +63,41 @@ namespace hiop { namespace tests {
/// Returns const pointer to local vector data
const real_type* VectorTestsPar::getLocalDataConst(const hiop::hiopVector* x)
{
const hiop::hiopVectorPar* xvec = dynamic_cast<const hiop::hiopVectorPar*>(x);
return x->local_data_const();
if(auto* xvec = dynamic_cast<const hiop::hiopVectorPar*>(x))
{
return xvec->local_data_const();
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsPar::getLocalDataConst`!");
}
}

/// Method to set vector _x_ element _i_ to _value_.
void VectorTestsPar::setLocalElement(hiop::hiopVector* x, local_ordinal_type i, real_type val)
{
hiop::hiopVectorPar* xvec = dynamic_cast<hiop::hiopVectorPar*>(x);
real_type *xdat = xvec->local_data();
xdat[i] = val;
if(auto* xvec = dynamic_cast<hiop::hiopVectorPar*>(x))
{
real_type *xdat = xvec->local_data();
xdat[i] = val;
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsPar::setLocalElement`!");
}
}

/// Get communicator
MPI_Comm VectorTestsPar::getMPIComm(hiop::hiopVector* x)
{
const hiop::hiopVectorPar* xvec = dynamic_cast<const hiop::hiopVectorPar*>(x);
return xvec->get_mpi_comm();
if(auto* xvec = dynamic_cast<const hiop::hiopVectorPar*>(x))
{
return xvec->get_mpi_comm();
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsPar::getMPIComm`!");
}
}

/// Wrap new command
38 changes: 28 additions & 10 deletions tests/LinAlg/vectorTestsRajaPar.cpp
Original file line number Diff line number Diff line change
@@ -67,26 +67,44 @@ namespace hiop { namespace tests {
/// Returns const pointer to local vector data
const real_type* VectorTestsRajaPar::getLocalDataConst(const hiop::hiopVector* x_in)
{
const hiop::hiopVectorRajaPar* x = dynamic_cast<const hiop::hiopVectorRajaPar*>(x_in);
x->copyFromDev();
return x->local_data_host_const();
if(auto* x = dynamic_cast<const hiop::hiopVectorRajaPar*>(x_in))
{
x->copyFromDev();
return x->local_data_host_const();
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsRajaPar::getLocalDataConst`!");
}
}

/// Method to set vector _x_ element _i_ to _value_.
void VectorTestsRajaPar::setLocalElement(hiop::hiopVector* x_in, local_ordinal_type i, real_type val)
{
hiop::hiopVectorRajaPar* x = dynamic_cast<hiop::hiopVectorRajaPar*>(x_in);
x->copyFromDev();
real_type *xdat = x->local_data_host();
xdat[i] = val;
x->copyToDev();
if(auto* x = dynamic_cast<hiop::hiopVectorRajaPar*>(x_in))
{
x->copyFromDev();
real_type *xdat = x->local_data_host();
xdat[i] = val;
x->copyToDev();
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsRajaPar::setLocalElement`!");
}
}

/// Get communicator
MPI_Comm VectorTestsRajaPar::getMPIComm(hiop::hiopVector* x)
{
const hiop::hiopVectorRajaPar* xvec = dynamic_cast<const hiop::hiopVectorRajaPar*>(x);
return xvec->get_mpi_comm();
if(auto* xvec = dynamic_cast<const hiop::hiopVectorRajaPar*>(x))
{
return xvec->get_mpi_comm();
}
else
{
assert(false && "Wrong type of vector passed into `VectorTestsRajaPar::getMPIComm`!");
}
}

/// Wrap new command