Skip to content

Commit

Permalink
testing jit and cuda properly
Browse files Browse the repository at this point in the history
  • Loading branch information
K20shores committed Sep 23, 2024
1 parent fec303e commit 65f06e6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
14 changes: 14 additions & 0 deletions test/unit/cuda/solver/test_cuda_linear_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,17 @@ TEST(CudaLinearSolver, RandomMatrixVectorOrderingForGPU)
{
verify_gpu_against_cpu();
}

TEST(CudaLinearSolver, AgnosticToInitialValue)
{
double initial_values[5] = { -INFINITY, -1.0, 0.0, 1.0, INFINITY };
for(auto initial_value : initial_values)
{
testExtremeInitialValue<Group1CudaDenseMatrix, Group1CudaSparseMatrix, micm::CudaLinearSolver<Group1CudaSparseMatrix>>(1, initial_value);
testExtremeInitialValue<Group20CudaDenseMatrix, Group20CudaSparseMatrix, micm::CudaLinearSolver<Group20CudaSparseMatrix>>(20, initial_value);
testExtremeInitialValue<Group300CudaDenseMatrix, Group300CudaSparseMatrix, micm::CudaLinearSolver<Group300CudaSparseMatrix>>(
300, initial_value);
testExtremeInitialValue<Group4000CudaDenseMatrix, Group4000CudaSparseMatrix, micm::CudaLinearSolver<Group4000CudaSparseMatrix>>(
4000, initial_value);
}
}
8 changes: 8 additions & 0 deletions test/unit/jit/solver/test_jit_linear_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,12 @@ TEST(JitLinearSolver, DiagonalMatrixVectorOrdering)
testDiagonalMatrix<Group2VectorMatrix, Group2SparseVectorMatrix, micm::JitLinearSolver<2, Group2SparseVectorMatrix>>(2);
testDiagonalMatrix<Group3VectorMatrix, Group3SparseVectorMatrix, micm::JitLinearSolver<3, Group3SparseVectorMatrix>>(3);
testDiagonalMatrix<Group4VectorMatrix, Group4SparseVectorMatrix, micm::JitLinearSolver<4, Group4SparseVectorMatrix>>(4);
}

TEST(JitLinearSolver, AgnosticToInitialValue)
{
double initial_values[5] = { -INFINITY, INFINITY };
for(auto initial_value : initial_values) {
testExtremeInitialValue<Group1VectorMatrix, Group1SparseVectorMatrix, micm::JitLinearSolver<1, Group1SparseVectorMatrix>>(1, initial_value);
}
}
4 changes: 2 additions & 2 deletions test/unit/solver/test_linear_solver_policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void testRandomMatrix(std::size_t number_of_blocks)
CopyToHostDense<MatrixPolicy>(x);

check_results<FloatingPointType, MatrixPolicy, SparseMatrixPolicy>(
A, b, x, [&](const FloatingPointType a, const FloatingPointType b) -> void { EXPECT_NEAR(a, b, 1.0e-5); });
A, b, x, [&](const FloatingPointType a, const FloatingPointType b) -> void { EXPECT_NEAR(a, b, 1.0e-8); });
}

template<class MatrixPolicy, class SparseMatrixPolicy, class LinearSolverPolicy>
Expand Down Expand Up @@ -259,7 +259,7 @@ void testExtremeInitialValue(std::size_t number_of_blocks, double initial_value)
CopyToHostDense<MatrixPolicy>(x);

check_results<FloatingPointType, MatrixPolicy, SparseMatrixPolicy>(
A, b, x, [&](const FloatingPointType a, const FloatingPointType b) -> void { EXPECT_NEAR(a, b, 1.0e-8); });
A, b, x, [&](const FloatingPointType a, const FloatingPointType b) -> void { EXPECT_NEAR(a, b, 1.0e-7); });
}

template<class MatrixPolicy, class SparseMatrixPolicy, class LinearSolverPolicy>
Expand Down

0 comments on commit 65f06e6

Please sign in to comment.