Skip to content

Commit 5cdf22e

Browse files
committed
Start on tuning flint_mpn_mulhigh_n
1 parent 9f502e4 commit 5cdf22e

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

src/tune/mpn_extras/mulhigh_0.c

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
Copyright (C) 2024 Albin Ahlbäck
3+
4+
This file is part of FLINT.
5+
6+
FLINT is free software: you can redistribute it and/or modify it under
7+
the terms of the GNU Lesser General Public License (LGPL) as published
8+
by the Free Software Foundation; either version 3 of the License, or
9+
(at your option) any later version. See <https://www.gnu.org/licenses/>.
10+
*/
11+
12+
#include "flint-mparam.h"
13+
#include "mpn_extras.h"
14+
#include "tune.h"
15+
16+
#undef FLINT_MPN_MULHIGH_K_TAB_SIZE
17+
#undef FLINT_MPN_MULHIGH_K_TAB
18+
#define TUNE_PROGRAM 1
19+
20+
#define FLINT_MPN_MULHIGH_K_TAB_SIZE FLINT_MPN_MULHIGH_K_TAB_MAX_SIZE
21+
#define flint_mpn_mulhigh_k_tab flint_mpn_mulhigh_k_tab_0
22+
#define _flint_mpn_mulhigh_n_mulders_recursive _flint_mpn_mulhigh_n_mulders_recursive_0
23+
#define _flint_mpn_mulhigh_n_mulders _flint_mpn_mulhigh_n_mulders_0
24+
25+
#include "mpn_extras/mulhigh.c"

src/tune/mpn_extras/tune_mulhigh_n.c

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
Copyright (C) 2024 Albin Ahlbäck
3+
4+
This file is part of FLINT.
5+
6+
FLINT is free software: you can redistribute it and/or modify it under
7+
the terms of the GNU Lesser General Public License (LGPL) as published
8+
by the Free Software Foundation; either version 3 of the License, or
9+
(at your option) any later version. See <https://www.gnu.org/licenses/>.
10+
*/
11+
12+
#include "mpn_extras.h"
13+
#include "tune.h"
14+
15+
#undef FLINT_MPN_MULHIGH_K_TAB_SIZE
16+
#define FLINT_MPN_MULHIGH_K_TAB_SIZE FLINT_MPN_MULHIGH_K_TAB_MAX_SIZE
17+
18+
#define flint_mpn_mulhigh_k_tab flint_mpn_mulhigh_k_tab_0
19+
#define _flint_mpn_mulhigh_n_mulders _flint_mpn_mulhigh_n_mulders_0
20+
21+
FLINT_DLL extern short flint_mpn_mulhigh_k_tab[FLINT_MPN_MULHIGH_K_TAB_SIZE];
22+
mp_limb_t _flint_mpn_mulhigh_n_mulders(mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);
23+
24+
/* IDEA:
25+
26+
1. Set all entries in flint_mpn_mulhigh_k_tab to zeroes.
27+
2. Skip any further altering of those entries having a corresponding
28+
hardcoded version.
29+
3. When reasonable, check if basecase is faster.
30+
4. The sequence of k should be weakly increasing. We only need to consider k
31+
between n / 2 and n.
32+
TODO: How can we prune the search with this information?
33+
5. Run some warmups and run some hotlaps for each k. Only use the fastest
34+
consistent time (see tune.c).
35+
6. Use the k that corresponds to the fastest k and push that to
36+
flint_mpn_mulhigh_k_tab so that it can be used in consecutive runs.
37+
*/

src/tune/tune.h

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ void n_param_clear(void *);
4242
double _tune_n_xgcd_0(void *);
4343
double _tune_n_xgcd_1(void *);
4444

45+
/* mpn_extras ****************************************************************/
46+
47+
#define FLINT_MPN_MULHIGH_K_TAB_MAX_SIZE 4096
48+
4549
/* n_mod_vec *****************************************************************/
4650
#if WANT_N_MOD
4751
struct n_mod_vec_param_0

0 commit comments

Comments
 (0)