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

浏览该文件的源代码.

函数

static double bench_mul (mp_size_t a, mp_size_t b, const bench_options *o)
 Copyright (C) 2026 HJimmyK (Jericho Knox)
static double bench_mul_n (mp_size_t n, const bench_options *o)
int main (void)
static void run_mul (void)
static void run_mul_n (void)
static void run_unbal (void)

函数说明

◆ bench_mul()

double bench_mul ( mp_size_t a,
mp_size_t b,
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

在文件 mul.c 第 26 行定义.

26 {
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 + 2);
33 fill_random(pa, a, 0x1111222233334444ull + a * 31 + b);
34 fill_random(pb, b, 0x5555666677778888ull + b * 17 + a);
35 double us;
36 BENCH_MEASURE(us, o, lmmp_mul_(d, pa, a, pb, b););
37 lmmp_free(pa);
38 lmmp_free(pb);
39 lmmp_free(d);
40 return us;
41}
mp_limb_t * mp_ptr
定义 lmmp.h:96
uint64_t mp_size_t
定义 lmmp.h:93
void lmmp_free(void *ptr)
内存释放函数(调用lmmp_heap_free_fn)
void lmmp_mul_(mp_ptr dst, mp_srcptr numa, mp_size_t na, mp_srcptr numb, mp_size_t nb)
不等长乘法操作 [dst,na+nb] = [numa,na] * [numb,nb]
#define t
#define BENCH_MEASURE(result, options,...)
定义 perf.h:93

引用了 BENCH_MEASURE, bench_mul(), lmmp_free(), lmmp_mul_() , 以及 t.

被这些函数引用 bench_mul(), run_mul() , 以及 run_unbal().

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

◆ bench_mul_n()

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

在文件 mul.c 第 43 行定义.

43 {
44 mp_ptr a = alloc_limbs(n), b = alloc_limbs(n), d = alloc_limbs(2 * n + 2);
45 fill_random(a, n, 0x120e3489bceull + n);
46 fill_random(b, n, 0x92cab543221ull + n * 3);
47 double us;
48 BENCH_MEASURE(us, o, lmmp_mul_n_(d, a, b, n););
49 lmmp_free(a);
50 lmmp_free(b);
51 lmmp_free(d);
52 return us;
53}
#define lmmp_mul_n_
#define n

引用了 BENCH_MEASURE, bench_mul_n(), lmmp_free(), lmmp_mul_n_ , 以及 n.

被这些函数引用 bench_mul_n() , 以及 run_mul_n().

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

◆ main()

int main ( void )

在文件 mul.c 第 77 行定义.

77 {
78 setvbuf(stdout, NULL, _IONBF, 0);
80 puts("[lmmpn/mul/mul]");
81 run_mul();
82 puts("[lmmpn/mul/mul_n]");
83 run_mul_n();
84 puts("[lmmpn/mul/unbal]");
85 run_unbal();
87 return 0;
88}
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
static void run_mul_n(void)
定义 mul.c:63
static void run_mul(void)
定义 mul.c:55
static void run_unbal(void)

引用了 lmmp_global_deinit(), lmmp_global_init(), main(), run_mul(), run_mul_n() , 以及 run_unbal().

函数调用图:

◆ run_mul()

void run_mul ( void )
static

在文件 mul.c 第 55 行定义.

55 {
56 const mp_size_t SZ[] = {10, 50, 100, 500, 1000, 5000};
57 for (size_t i = 0; i < ARRAY_SIZE(SZ); ++i) {
58 mp_size_t n = SZ[i];
59 report_n("mul", n, bench_mul(n, n, &bench_default), 0);
60 }
61}
static double bench_mul(mp_size_t a, mp_size_t b, const bench_options *o)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 mul.c:26
#define ARRAY_SIZE(a)
Copyright (C) 2026 HJimmyK (Jericho Knox)
定义 perf.h:40

引用了 ARRAY_SIZE, bench_mul(), n , 以及 run_mul().

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

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

◆ run_mul_n()

void run_mul_n ( void )
static

在文件 mul.c 第 63 行定义.

63 {
64 const mp_size_t SZ[] = {10, 50, 100, 500, 1000, 5000};
65 for (size_t i = 0; i < ARRAY_SIZE(SZ); ++i) {
66 mp_size_t n = SZ[i];
67 report_n("mul_n", n, bench_mul_n(n, &bench_default), 0);
68 }
69}
static double bench_mul_n(mp_size_t n, const bench_options *o)
定义 mul.c:43

引用了 ARRAY_SIZE, bench_mul_n(), n , 以及 run_mul_n().

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

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

◆ run_unbal()

void run_unbal ( void )
static

在文件 mul.c 第 71 行定义.

71 {
72 report_ab("mul", 1000, 7, bench_mul(1000, 7, &bench_default), 1000 * 7 * 8.0);
73 report_ab("mul", 5000, 100, bench_mul(5000, 100, &bench_default), 5000 * 100 * 8.0);
74 report_ab("mul", 10000, 3000, bench_mul(10000, 3000, &bench_default), 10000 * 3000 * 8.0);
75}

引用了 bench_mul() , 以及 run_unbal().

函数调用图: