LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
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
27
static
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
48
int
main
(
void
) {
49
setvbuf(stdout, NULL, _IONBF, 0);
50
lmmp_global_init
();
51
puts(
"[lmmpn/div_3_2]"
);
52
report(
"div_3_2"
,
bench_div_3_2
(&bench_default), 0);
53
lmmp_global_deinit
();
54
return
0;
55
}
bench_div_3_2
static double bench_div_3_2(const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
div_3_2.c:27
LIMB_B_2
#define LIMB_B_2
定义
mparam.h:40
main
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
main.c:26
mp_ptr
mp_limb_t * mp_ptr
定义
lmmp.h:96
lmmp_free
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
定义
memory.c:437
lmmp_global_init
void lmmp_global_init(void)
全局初始化函数(线程局部的)
定义
global.c:58
mp_limb_t
uint64_t mp_limb_t
定义
lmmp.h:92
lmmp_global_deinit
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
定义
global.c:65
lmmpn.h
lmmp_div_3_2_
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]
lmmp_inv_2_1_
mp_limb_t lmmp_inv_2_1_(mp_limb_t xh, mp_limb_t xl)
2-1阶逆元计算 (inv21)
定义
inv.c:27
perf.h
BENCH_MEASURE
#define BENCH_MEASURE(result, options,...)
定义
perf.h:93
bench_options
定义
perf.h:44
src
lmmp
lmmpn
perf
div_3_2.c
生成于
, 为 LMMP使用
1.18.0