LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
addsub_shift.c 文件参考
#include "limb_sizes.h"
addsub_shift.c 的引用(Include)关系图:

浏览该文件的源代码.

函数

static double bench_addshl1_n (mp_size_t n, const bench_options *o)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
static double bench_shr1add_n (mp_size_t n, const bench_options *o)
static double bench_shr1sub_n (mp_size_t n, const bench_options *o)
static double bench_subshl1_n (mp_size_t n, const bench_options *o)
int main (void)

函数说明

◆ bench_addshl1_n()

double bench_addshl1_n ( mp_size_t n,
const bench_options * o )
static

Copyright (C) 2026 HJimmyK (Jericho Knox)

This file is part of LMMP.

LMMP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library. If not, see https://www.gnu.org/licenses/.

SPDX-License-Identifier: LGPL-3.0-or-later

在文件 addsub_shift.c 第 25 行定义.

25 {
26 mp_ptr a = alloc_limbs(n), b = alloc_limbs(n), d = alloc_limbs(n + 1);
27 fill_random(a, n, 0x5152535455565758ull + n);
28 fill_random(b, n, 0x6162636465666768ull + n);
29 double us;
30 BENCH_MEASURE(us, o, bench_sink += lmmp_addshl1_n_(d, a, b, n););
31 lmmp_free(a);
32 lmmp_free(b);
33 lmmp_free(d);
34 return us;
35}
mp_limb_t * mp_ptr
定义 lmmp.h:96
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
mp_limb_t lmmp_addshl1_n_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n)
加法结合左移1位操作 [dst,n] = [numa,n] + ([numb,n] << 1)
定义 shl.c:53
#define n
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93

引用了 bench_addshl1_n(), BENCH_MEASURE, lmmp_addshl1_n_(), lmmp_free() , 以及 n.

被这些函数引用 bench_addshl1_n() , 以及 main().

函数调用图:
这是这个函数的调用关系图:

◆ bench_shr1add_n()

double bench_shr1add_n ( mp_size_t n,
const bench_options * o )
static

在文件 addsub_shift.c 第 49 行定义.

49 {
50 mp_ptr a = alloc_limbs(n), b = alloc_limbs(n), d = alloc_limbs(n);
51 fill_random(a, n, 0xd1d2d3d4d5d6d7d8ull + n);
52 fill_random(b, n, 0xe1e2e3e4e5e6e7e8ull + n);
53 double us;
54 BENCH_MEASURE(us, o, bench_sink += lmmp_shr1add_n_(d, a, b, n););
55 lmmp_free(a);
56 lmmp_free(b);
57 lmmp_free(d);
58 return us;
59}
mp_limb_t lmmp_shr1add_n_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n)
加法后右移1位 [dst,n] = ([numa,n] + [numb,n]) >> 1
定义 shr.c:65

引用了 BENCH_MEASURE, bench_shr1add_n(), lmmp_free(), lmmp_shr1add_n_() , 以及 n.

被这些函数引用 bench_shr1add_n() , 以及 main().

函数调用图:
这是这个函数的调用关系图:

◆ bench_shr1sub_n()

double bench_shr1sub_n ( mp_size_t n,
const bench_options * o )
static

在文件 addsub_shift.c 第 61 行定义.

61 {
62 mp_ptr a = alloc_limbs(n), b = alloc_limbs(n), d = alloc_limbs(n);
63 fill_random(a, n, 0xf1f2f3f4f5f6f7f8ull + n);
64 fill_random(b, n, 0x1112131415162718ull + n);
65 double us;
66 BENCH_MEASURE(us, o, bench_sink += lmmp_shr1sub_n_(d, a, b, n););
67 lmmp_free(a);
68 lmmp_free(b);
69 lmmp_free(d);
70 return us;
71}
mp_limb_t lmmp_shr1sub_n_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n)
减法后右移1位 [dst,n] = ([numa,n] - [numb,n]) >> 1
定义 shr.c:87

引用了 BENCH_MEASURE, bench_shr1sub_n(), lmmp_free(), lmmp_shr1sub_n_() , 以及 n.

被这些函数引用 bench_shr1sub_n() , 以及 main().

函数调用图:
这是这个函数的调用关系图:

◆ bench_subshl1_n()

double bench_subshl1_n ( mp_size_t n,
const bench_options * o )
static

在文件 addsub_shift.c 第 37 行定义.

37 {
38 mp_ptr a = alloc_limbs(n), b = alloc_limbs(n), d = alloc_limbs(n + 1);
39 fill_random(a, n, 0x7172737475767778ull + n);
40 fill_random(b, n, 0x8182838485868788ull + n);
41 double us;
42 BENCH_MEASURE(us, o, bench_sink += lmmp_subshl1_n_(d, a, b, n););
43 lmmp_free(a);
44 lmmp_free(b);
45 lmmp_free(d);
46 return us;
47}
mp_limb_t lmmp_subshl1_n_(mp_ptr dst, mp_srcptr numa, mp_srcptr numb, mp_size_t n)
减法结合左移1位操作 [dst,n] = [numa,n] - ([numb,n] << 1)
定义 shl.c:80

引用了 BENCH_MEASURE, bench_subshl1_n(), lmmp_free(), lmmp_subshl1_n_() , 以及 n.

被这些函数引用 bench_subshl1_n() , 以及 main().

函数调用图:
这是这个函数的调用关系图:

◆ main()

int main ( void )

在文件 addsub_shift.c 第 73 行定义.

73 {
74 setvbuf(stdout, NULL, _IONBF, 0);
76 puts("[lmmpn/addsub_shift]");
77 run_limb_sizes("addshl1_n", bench_addshl1_n);
78 run_limb_sizes("subshl1_n", bench_subshl1_n);
79 run_limb_sizes("shr1add_n", bench_shr1add_n);
80 run_limb_sizes("shr1sub_n", bench_shr1sub_n);
82 return 0;
83}
static double bench_shr1add_n(mp_size_t n, const bench_options *o)
static double bench_subshl1_n(mp_size_t n, const bench_options *o)
static double bench_addshl1_n(mp_size_t n, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
static double bench_shr1sub_n(mp_size_t n, const bench_options *o)
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)

引用了 bench_addshl1_n(), bench_shr1add_n(), bench_shr1sub_n(), bench_subshl1_n(), lmmp_global_deinit(), lmmp_global_init() , 以及 main().

函数调用图: