-
-
Notifications
You must be signed in to change notification settings - Fork 295
/
bench_blas3.c
93 lines (75 loc) · 2.47 KB
/
bench_blas3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*****************************************************************************
*
* MODULE: Grass PDE Numerical Library
* AUTHOR(S): Soeren Gebbert, Berlin (GER) Dec 2007
* soerengebbert <at> gmx <dot> de
*
* PURPOSE: Unit benchs for les creation
*
* COPYRIGHT: (C) 2007 by the GRASS Development Team
*
* This program is free software under the GNU General Public
* License (>=v2). Read the file COPYING that comes with GRASS
* for details.
*
*****************************************************************************/
#include <grass/gis.h>
#include <grass/glocale.h>
#include <grass/gmath.h>
#include <math.h>
#include "test_gmath_lib.h"
#include <sys/time.h>
/* prototypes */
static void bench_blas_level_3_double(int rows);
/* *************************************************************** */
/* Perfrome the blas level 3 benchs ****************************** */
/* *************************************************************** */
int bench_blas_level_3(int rows)
{
G_message(_("\n++ Running blas level 3 benchmark ++"));
bench_blas_level_3_double(rows);
return 1;
}
/* *************************************************************** */
/* ************** D O U B L E ************************************ */
/* *************************************************************** */
void bench_blas_level_3_double(int rows)
{
struct timeval tstart;
struct timeval tend;
double **A, **B, **C, *x, *y;
x = G_alloc_vector(rows);
y = G_alloc_vector(rows);
A = G_alloc_matrix(rows, rows);
B = G_alloc_matrix(rows, rows);
C = G_alloc_matrix(rows, rows);
fill_d_vector_range_1(x, 1, rows);
fill_d_vector_range_1(y, 1, rows);
fill_d_vector_range_1(A[0], 1, rows*rows);
fill_d_vector_range_1(B[0], 1, rows*rows);
gettimeofday(&tstart, NULL);
#pragma omp parallel default(shared)
{
G_math_d_aA_B(A, B, 4.0 , C, rows , rows);
}
gettimeofday(&tend, NULL);
printf("Computation time G_math_d_aA_B: %g\n", compute_time_difference(tstart, tend));
gettimeofday(&tstart, NULL);
#pragma omp parallel default(shared)
{
G_math_d_AB(A, B, C, rows , rows , rows);
}
gettimeofday(&tend, NULL);
printf("Computation time G_math_d_AB: %g\n", compute_time_difference(tstart, tend));
if(x)
G_free_vector(x);
if(y)
G_free_vector(y);
if(A)
G_free_matrix(A);
if(B)
G_free_matrix(B);
if(C)
G_free_matrix(C);
return;
}