LMMP
4.3.0
Lamina High-Precision Arithmetic Library
Toggle main menu visibility
载入中...
搜索中...
未找到
mul_basecase.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
26
static
double
bench_mul_basecase
(
mp_size_t
a,
mp_size_t
b,
const
bench_options
*o) {
27
if
(a < b) {
28
mp_size_t
t
= a;
29
a = b;
30
b =
t
;
31
}
32
mp_ptr
pa = alloc_limbs(a), pb = alloc_limbs(b), d = alloc_limbs(a + b + 1);
33
fill_random(pa, a, 0x0badcafef00dfaceull + a * 31 + b);
34
fill_random(pb, b, 0x13579bdf2468ace0ull + b * 17 + a);
35
double
us;
36
BENCH_MEASURE
(us, o,
lmmp_mul_basecase_
(d, pa, a, pb, b); bench_sink += d[0];);
37
lmmp_free
(pa);
38
lmmp_free
(pb);
39
lmmp_free
(d);
40
return
us;
41
}
42
43
static
void
run_unbal
(
void
) {
44
report_ab(
"mul_basecase"
, 1000, 7,
bench_mul_basecase
(1000, 7, &bench_default), 1000 * 7 * 8.0);
45
report_ab(
"mul_basecase"
, 10000, 70,
bench_mul_basecase
(10000, 70, &bench_default), 10000 * 70 * 8.0);
46
}
47
48
int
main
(
void
) {
49
setvbuf(stdout, NULL, _IONBF, 0);
50
lmmp_global_init
();
51
puts(
"[lmmpn/mul_basecase]"
);
52
const
mp_size_t
SZ[] = {50, 200, 1000};
53
for
(
size_t
i = 0; i <
ARRAY_SIZE
(SZ); ++i) {
54
mp_size_t
n
= SZ[i];
55
report_n(
"mul_basecase"
,
n
,
bench_mul_basecase
(
n
,
n
, &bench_default), 0);
56
}
57
run_unbal
();
58
lmmp_global_deinit
();
59
return
0;
60
}
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
lmmp_global_deinit
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
定义
global.c:65
lmmpn.h
lmmp_mul_basecase_
void lmmp_mul_basecase_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_srcptr numb, mp_size_t nb)
基础乘法运算 [dst,na+nb] = [numa,na] * [numb,nb]
t
#define t
n
#define n
bench_mul_basecase
static double bench_mul_basecase(mp_size_t a, mp_size_t b, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
mul_basecase.c:26
run_unbal
static void run_unbal(void)
定义
mul_basecase.c:43
perf.h
ARRAY_SIZE
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义
perf.h:40
BENCH_MEASURE
#define BENCH_MEASURE(result, options,...)
定义
perf.h:93
bench_options
定义
perf.h:44
src
lmmp
lmmpn
perf
mul_basecase.c
生成于
, 为 LMMP使用
1.18.0