-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmajorant.c
76 lines (65 loc) · 2.09 KB
/
majorant.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
#include "majorant.h"
#include "norm.h"
#include <stdio.h>
void bound_triangular_matrix(
double ***A_tiles, int ldA,
double *restrict A_norms,
int num_tiles, int *p,
matrix_desc_t type,
memory_layout_t mem_layout)
{
#define A_norms(i,j) A_norms[(i) + (j) * num_tiles]
switch(type) {
case UPPER_TRIANGULAR:
{
for (int i = 0; i < num_tiles; i++) {
#pragma omp task
for (int j = i; j < num_tiles; j++) {
// Compute dimensions of tile (i,j).
const int m = p[i + 1] - p[i];
const int n = p[j + 1] - p[j];
if (m > 0 && n > 0) {
// Compute majorant of A(i,j).
if (mem_layout == COLUMN_MAJOR)
A_norms(i,j) = matrix_infnorm(m, n, A_tiles[i][j], ldA);
else // TILE_LAYOUT
A_norms(i,j) = matrix_infnorm(m, n, A_tiles[i][j], m);
}
}
}
break;
}
case LOWER_TRIANGULAR:
{
for (int i = 0; i < num_tiles; i++) {
#pragma omp task
for (int j = 0; j <= i; j++) {
// Compute dimensions of tile (i,j).
const int m = p[i + 1] - p[i];
const int n = p[j + 1] - p[j];
// Compute majorant of A(i,j).
if (mem_layout == COLUMN_MAJOR)
A_norms(i,j) = matrix_infnorm(m, n, A_tiles[i][j], ldA);
else // TILE_LAYOUT
A_norms(i,j) = matrix_infnorm(m, n, A_tiles[i][j], m);
}
}
break;
}
default:
{
break;
}
}
#undef A_norms
}
void compute_column_majorants(
int m, int n,
const double *restrict C, int ldC,
double *restrict C_norms)
{
// Compute column-wise norm.
for (int j = 0; j < n; j++) {
C_norms[j] = vector_infnorm(m, C + j * ldC);
}
}