LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
div_3_2.c
浏览该文件的文档.
1/**
2 * Copyright (C) 2026 HJimmyK (Jericho Knox)
3 *
4 * This file is part of LMMP.
5 *
6 * LMMP is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <https://www.gnu.org/licenses/>.
19 *
20 * SPDX-License-Identifier: LGPL-3.0-or-later
21 */
22
23#include "support/perf.h"
24#include "lmmp/lmmpn.h"
25#include "mparam.h"
26
27static double bench_div_3_2(const bench_options *o) {
28 mp_ptr np = alloc_limbs(3), npw = alloc_limbs(3), dp = alloc_limbs(2);
29 np[0] = 0x1111111122222222ull;
30 np[1] = 0x3333333344444444ull;
31 np[2] = 0x5555555566666666ull;
32 dp[0] = 0x7777777788888888ull;
33 dp[1] = 0x99999999aaaaaaaall | LIMB_B_2;
34 mp_limb_t inv21 = lmmp_inv_2_1_(dp[1], dp[0]);
35 double us;
36 BENCH_MEASURE(us, o,
37 npw[0] = np[0];
38 npw[1] = np[1];
39 npw[2] = np[2];
40 bench_sink += lmmp_div_3_2_(npw, dp, inv21);
41 );
42 lmmp_free(np);
43 lmmp_free(npw);
44 lmmp_free(dp);
45 return us;
46}
47
48int main(void) {
49 setvbuf(stdout, NULL, _IONBF, 0);
51 puts("[lmmpn/div_3_2]");
52 report("div_3_2", bench_div_3_2(&bench_default), 0);
54 return 0;
55}
static double bench_div_3_2(const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define LIMB_B_2
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 main.c:26
mp_limb_t * mp_ptr
定义 lmmp.h:96
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
void lmmp_global_init(void)
全局初始化函数(线程局部的)
uint64_t mp_limb_t
定义 lmmp.h:92
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
mp_limb_t lmmp_div_3_2_(mp_ptr numa, mp_srcptr numb, mp_limb_t inv21)
3/2位除法运算 [numa,2]=[numa,3] mod [numb,2]
mp_limb_t lmmp_inv_2_1_(mp_limb_t xh, mp_limb_t xl)
2-1阶逆元计算 (inv21)
定义 inv.c:27
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93