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

bigint-syrk-blas: Unit tests fail if FLINT library compiled without BLAS #202

Closed
vasdommes opened this issue Feb 28, 2024 · 0 comments
Closed
Assignees
Milestone

Comments

@vasdommes
Copy link
Collaborator

In unit_tests for #142, we are using fmpz_mat_mul_blas as one of the matrix multiplication methods (mathematically equivalent to our new matrix multiplication algorithm).

If FLINT is built without BLAS, then the condition #if FLINT_USES_BLAS && FLINT_BITS == 64 does not hold, and fmpz_mat_mul_blas simply returns 0.

We do not use fmpz_mat_mul_blas in production code, only in tests:

fmpz_mat_mul_blas(Q.fmpz_matrix, PT_bigint.fmpz_matrix,

Thus we don't actually need to have FLINT with BLAS. We should fallback e.g. to fmpz_mat_mul_multi_mod (it also uses CRT), if fmpz_mat_mul_blas doesn't work.

P.S. We also do not check the return code of fmpz_mat_mul_blas, so the error message is not obvious (in fact, it means that Q_result_fmpz_mat_mul_blas is filled with zeros):

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
unit_tests is a Catch2 v3.4.0 host application.
Run with -? for options

-------------------------------------------------------------------------------
calculate_Block_Matrix_square
  P_width=1
  P_height=1 num_blocks=1
  use_dist_blocks=0
-------------------------------------------------------------------------------
../test/src/unit_tests/cases/calculate_matrix_square.test.cxx:117
...............................................................................

../test/src/test_util/diff.hxx:73: FAILED:
  REQUIRE( Abs(a - b) < eps * (Abs(a) + Abs(b)) )
with expansion:
  0.37514 < 9.52083e-117
with messages:
  input: dense tall NxK matrix P, splitted horizontally into blocks
  output: NxN matrix Q := P^T P
  We calculate Q with different methods, including our bigint_syrk_blas,, and
  compare the results.
  El::mpi::Rank() := 0
  El::mpi::Rank(comm) := 0
  bits = El::gmp::Precision() := 768 (0x300)
  diff_precision = bits / 2 := 384 (0x180)
  Initialize P_matrix and calculate local Q with builtin Elemental and FLINT
  methods
  DIFF(Q_result_El_Syrk, Q_result_fmpz_mat_mul_blas)
  diff El::Matrix
  row := 0
  col := 0
  DIFF(a.Get(row, col), b.Get(row, col))
  a := 0.37514
  b := 0
  a - b := 0.37514
  diff_precision := 384 (0x180)
  eps := 2.53794e-116
@vasdommes vasdommes added this to the 2.8.0 milestone Feb 28, 2024
@vasdommes vasdommes self-assigned this Feb 28, 2024
vasdommes added a commit that referenced this issue Mar 21, 2024
… WARN

WARN is written multiple times, polluting the output

See also #202 bigint-syrk-blas: Unit tests fail if FLINT library compiled without BLAS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant