<commit_before>/*
    Copyright (C) 2021 <NAME>

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "flint.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "fmpz_mat.h"
#include "ulong_extras.h"

int main(void)
{
    fmpz_mat_t A, B, C, D;
    slong i;
    FLINT_TEST_INIT(state);

    flint_printf("mul_blas....");
    fflush(stdout);

    for (i = 0; i < 100 * flint_test_multiplier(); i++)
    {
        slong m, n, k;

        m = 1 + n_randint(state, 50);
        n = 1 + n_randint(state, 50);
        k = 1 + n_randint(state, 50);

        fmpz_mat_init(A, m, n);
        fmpz_mat_init(B, n, k);
        fmpz_mat_init(C, m, k);
        fmpz_mat_init(D, m, k);

        fmpz_mat_randtest(A, state, n_randint(state, 200) + 1);
        fmpz_mat_randtest(B, state, n_randint(state, 200) + 1);

        /* Make sure noise in the output is ok */
        fmpz_mat_randtest(C, state, n_randint(state, 200) + 1);

        fmpz_mat_mul_classical_inline(C, A, B);
        if (fmpz_mat_mul_blas(D, A, B))
        {
            if (!fmpz_mat_equal(C, D))
            {
                flint_printf("FAIL: results not equal\n");
                flint_abort();
            }
        }
#if FLINT_USES_BLAS && FLINT_BITS == 64
        else
        {
            flint_printf("FAIL: blas should have worked\n");
            flint_abort();
        }
#endif

        fmpz_mat_clear(A);
        fmpz_mat_clear(B);
        fmpz_mat_clear(C);
        fmpz_mat_clear(D);
    }

    for (i = 0; i < 100 * flint_test_multiplier(); i++)
    {
        slong m, n, k;

        m = 1 + n_randint(state, 3);
        n = 1 + n_randint(state, 3);
        k = 1 + n_randint(state, 3);

        fmpz_mat_init(A, m, n);
        fmpz_mat_init(B, n, k);
        fmpz_mat_init(C, m, k);
        fmpz_mat_init(D, m, k);

        fmpz_mat_randtest(A, state, n_randint(state, 25000) + 1);
        fmpz_mat_randtest(B, state, n_randint(state, 25000) + 1);

        /* Make sure noise in the output is ok */
        fmpz_mat_randtest(C, state, n_randint(state, 200) + 1);
        fmpz_mat_randtest(D, state, n_randint(state, 200) + 1);

        fmpz_mat_mul_classical_inline(C, A, B);
        if (fmpz_mat_mul_blas(D, A, B))
        {
            if (!fmpz_mat_equal(C, D))
            {
                flint_printf("FAIL: results not equal\n");
                flint_abort();
            }
        }
#if FLINT_USES_BLAS && FLINT_BITS == 64
        else
        {
            flint_printf("FAIL: blas should have worked\n");
            flint_abort();
        }
#endif

        fmpz_mat_clear(A);
        fmpz_mat_clear(B);
        fmpz_mat_clear(C);
        fmpz_mat_clear(D);
    }

    FLINT_TEST_CLEANUP(state);

    flint_printf("PASS\n");
    return 0;
}
<commit_msg>test threads<commit_after>/*
    Copyright (C) 2021 <NAME>

    This file is part of FLINT.

    FLINT is free software: you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License (LGPL) as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.  See <https://www.gnu.org/licenses/>.
*/

#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
#include "flint.h"
#include "fmpz.h"
#include "fmpz_vec.h"
#include "fmpz_mat.h"
#include "ulong_extras.h"

int main(void)
{
    slong i;
    slong max_num_threads = 5;
    FLINT_TEST_INIT(state);

    flint_printf("mul_blas....");
    fflush(stdout);

    for (i = 0; i < 100 * flint_test_multiplier(); i++)
    {
        slong m, n, k;
        fmpz_mat_t A, B, C, D;

        m = 1 + n_randint(state, 50);
        n = 1 + n_randint(state, 50);
        k = 1 + n_randint(state, 50);

        fmpz_mat_init(A, m, n);
        fmpz_mat_init(B, n, k);
        fmpz_mat_init(C, m, k);
        fmpz_mat_init(D, m, k);

        fmpz_mat_randtest(A, state, n_randint(state, 200) + 1);
        fmpz_mat_randtest(B, state, n_randint(state, 200) + 1);

        /* Make sure noise in the output is ok */
        fmpz_mat_randtest(C, state, n_randint(state, 200) + 1);

        fmpz_mat_mul_classical_inline(C, A, B);
        if (fmpz_mat_mul_blas(D, A, B))
        {
            if (!fmpz_mat_equal(C, D))
            {
                flint_printf("FAIL: results not equal\n");
                flint_abort();
            }
        }
#if FLINT_USES_BLAS && FLINT_BITS == 64
        else
        {
            flint_printf("FAIL: blas should have worked\n");
            flint_abort();
        }
#endif

        flint_set_num_threads(1 + n_randint(state, max_num_threads));

        fmpz_mat_clear(A);
        fmpz_mat_clear(B);
        fmpz_mat_clear(C);
        fmpz_mat_clear(D);
    }

    for (i = 0; i < 20 * flint_test_multiplier(); i++)
    {
        slong m, n, k;
        fmpz_mat_t A, B, C, D;

        m = 1 + n_randint(state, 3);
        n = 1 + n_randint(state, 3);
        k = 1 + n_randint(state, 3);

        fmpz_mat_init(A, m, n);
        fmpz_mat_init(B, n, k);
        fmpz_mat_init(C, m, k);
        fmpz_mat_init(D, m, k);

        fmpz_mat_randtest(A, state, n_randint(state, 20000) + 1);
        fmpz_mat_randtest(B, state, n_randint(state, 20000) + 1);

        /* Make sure noise in the output is ok */
        fmpz_mat_randtest(C, state, n_randint(state, 200) + 1);
        fmpz_mat_randtest(D, state, n_randint(state, 200) + 1);

        fmpz_mat_mul_classical_inline(C, A, B);
        if (fmpz_mat_mul_blas(D, A, B))
        {
            if (!fmpz_mat_equal(C, D))
            {
                flint_printf("FAIL: results not equal\n");
                flint_abort();
            }
        }
#if FLINT_USES_BLAS && FLINT_BITS == 64
        else
        {
            flint_printf("FAIL: blas should have worked\n");
            flint_abort();
        }
#endif

        flint_set_num_threads(1 + n_randint(state, max_num_threads));

        fmpz_mat_clear(A);
        fmpz_mat_clear(B);
        fmpz_mat_clear(C);
        fmpz_mat_clear(D);
    }

    FLINT_TEST_CLEANUP(state);

    flint_printf("PASS\n");
    return 0;
}

{'fraction_non_alphanumeric': 0.12797246558197747, 'fraction_numerical': 0.020963704630788487, 'mean_word_length': 2.060315940641455, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3595799', 'n_tokens_mistral': 2625, 'n_tokens_neox': 2454, 'n_words': 555}