LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
mul_1.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 "
limb_sizes.h
"
24
25
static
double
bench_mul_1
(
mp_size_t
n
,
const
bench_options
*o) {
26
mp_ptr
a = alloc_limbs(
n
), d = alloc_limbs(
n
+ 1);
27
fill_random(a,
n
, 0x0a0b0c0d0e0f0102ull +
n
);
28
mp_limb_t
x = 0x9e3779b97f4a7c15ull;
29
double
us;
30
BENCH_MEASURE
(us, o, bench_sink +=
lmmp_mul_1_
(d, a,
n
, x););
31
lmmp_free
(a);
32
lmmp_free
(d);
33
return
us;
34
}
35
36
static
double
bench_addmul_1
(
mp_size_t
n
,
const
bench_options
*o) {
37
mp_ptr
a = alloc_limbs(
n
), d = alloc_limbs(
n
+ 1);
38
fill_random(a,
n
, 0x1112131415161718ull +
n
);
39
fill_random(d,
n
, 0x2122232425262728ull +
n
);
40
mp_limb_t
x = 0x9e3779b97f4a7c15ull;
41
double
us;
42
BENCH_MEASURE
(us, o, bench_sink +=
lmmp_addmul_1_
(d, a,
n
, x););
43
lmmp_free
(a);
44
lmmp_free
(d);
45
return
us;
46
}
47
48
static
double
bench_submul_1
(
mp_size_t
n
,
const
bench_options
*o) {
49
mp_ptr
a = alloc_limbs(
n
), d = alloc_limbs(
n
+ 1);
50
fill_random(a,
n
, 0x3132333435363738ull +
n
);
51
fill_random(d,
n
, 0x4142434445464748ull +
n
);
52
mp_limb_t
x = 0x9e3779b97f4a7c15ull;
53
double
us;
54
BENCH_MEASURE
(us, o, bench_sink +=
lmmp_submul_1_
(d, a,
n
, x););
55
lmmp_free
(a);
56
lmmp_free
(d);
57
return
us;
58
}
59
60
int
main
(
void
) {
61
setvbuf(stdout, NULL, _IONBF, 0);
62
lmmp_global_init
();
63
puts(
"[lmmpn/mul_1]"
);
64
run_limb_sizes(
"mul_1"
,
bench_mul_1
);
65
run_limb_sizes(
"addmul_1"
,
bench_addmul_1
);
66
run_limb_sizes(
"submul_1"
,
bench_submul_1
);
67
lmmp_global_deinit
();
68
return
0;
69
}
limb_sizes.h
main
int main(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
main.c:26
mp_ptr
mp_limb_t * mp_ptr
定义
lmmp.h:96
mp_size_t
uint64_t mp_size_t
定义
lmmp.h:93
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
lmmp_addmul_1_
mp_limb_t lmmp_addmul_1_(mp_ptr numa, mp_srcptr numb, mp_size_t n, mp_limb_t b)
乘以单limb并累加操作 [numa,n] += [numb,n] * b
定义
mul_1.c:76
lmmp_mul_1_
mp_limb_t lmmp_mul_1_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_limb_t x)
乘以单limb操作 [dst,na] = [numa,na] * x
定义
mul_1.c:27
lmmp_submul_1_
mp_limb_t lmmp_submul_1_(mp_ptr numa, mp_srcptr numb, mp_size_t n, mp_limb_t b)
乘以单limb并累减操作 [numa,n] -= [numb,n] * b
定义
mul_1.c:131
n
#define n
bench_addmul_1
static double bench_addmul_1(mp_size_t n, const bench_options *o)
定义
mul_1.c:36
bench_mul_1
static double bench_mul_1(mp_size_t n, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
mul_1.c:25
bench_submul_1
static double bench_submul_1(mp_size_t n, const bench_options *o)
定义
mul_1.c:48
BENCH_MEASURE
#define BENCH_MEASURE(result, options,...)
定义
perf.h:93
bench_options
定义
perf.h:44
src
lmmp
lmmpn
perf
mul_1.c
生成于
, 为 LMMP使用
1.18.0