Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PuReMD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SParTA
PuReMD
Commits
69a25536
Commit
69a25536
authored
8 years ago
by
Kurt A. O'Hearn
Browse files
Options
Downloads
Patches
Plain Diff
sPuReMD: decrease memory usage for thread-local SpMV buffers.
parent
4c09c5f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
puremd_rc_1003/sPuReMD/GMRES.c
+32
-17
32 additions, 17 deletions
puremd_rc_1003/sPuReMD/GMRES.c
puremd_rc_1003/sPuReMD/QEq.c
+1
-1
1 addition, 1 deletion
puremd_rc_1003/sPuReMD/QEq.c
with
33 additions
and
18 deletions
puremd_rc_1003/sPuReMD/GMRES.c
+
32
−
17
View file @
69a25536
...
...
@@ -24,6 +24,8 @@
#include
"list.h"
#include
"vector.h"
#include
<omp.h>
/* sparse matrix-vector product Ax=b
* where:
...
...
@@ -36,20 +38,35 @@ static void Sparse_MatVec( const sparse_matrix * const A,
int
i
,
j
,
k
,
n
,
si
,
ei
;
real
H
;
#ifdef _OPENMP
real
*
b_local
;
static
real
**
b_local
;
unsigned
int
tid
;
#endif
n
=
A
->
n
;
Vector_MakeZero
(
b
,
n
);
#pragma omp parallel \
default(none) shared(n) private(b_local, si, ei, H, i, j, k)
{
#ifdef _OPENMP
if
(
(
b_local
=
(
real
*
)
calloc
(
n
,
sizeof
(
real
)))
==
NULL
)
/* keep b_local for program duration to avoid allocate/free
* overhead per Sparse_MatVec call*/
if
(
b_local
==
NULL
)
{
b_local
=
(
real
**
)
malloc
(
omp_get_num_threads
()
*
sizeof
(
real
*
));
for
(
i
=
0
;
i
<
omp_get_num_threads
();
++
i
)
{
exit
(
INSUFFICIENT_SPACE
);
if
(
(
b_local
[
i
]
=
(
real
*
)
malloc
(
n
*
sizeof
(
real
)))
==
NULL
)
{
exit
(
INSUFFICIENT_SPACE
);
}
}
}
#endif
#pragma omp parallel \
default(none) shared(n, b_local) private(si, ei, H, j, k, tid)
{
#ifdef _OPENMP
tid
=
omp_get_thread_num
();
Vector_MakeZero
(
b_local
[
tid
],
n
);
#endif
#pragma omp for schedule(guided)
for
(
i
=
0
;
i
<
n
;
++
i
)
...
...
@@ -62,8 +79,8 @@ static void Sparse_MatVec( const sparse_matrix * const A,
j
=
A
->
entries
[
k
].
j
;
H
=
A
->
entries
[
k
].
val
;
#ifdef _OPENMP
b_local
[
j
]
+=
H
*
x
[
i
];
b_local
[
i
]
+=
H
*
x
[
j
];
b_local
[
tid
][
j
]
+=
H
*
x
[
i
];
b_local
[
tid
][
i
]
+=
H
*
x
[
j
];
#else
b
[
j
]
+=
H
*
x
[
i
];
b
[
i
]
+=
H
*
x
[
j
];
...
...
@@ -72,24 +89,22 @@ static void Sparse_MatVec( const sparse_matrix * const A,
// the diagonal entry is the last one in
#ifdef _OPENMP
b_local
[
i
]
+=
A
->
entries
[
k
].
val
*
x
[
i
];
b_local
[
tid
][
i
]
+=
A
->
entries
[
k
].
val
*
x
[
i
];
#else
b
[
i
]
+=
A
->
entries
[
k
].
val
*
x
[
i
];
#endif
}
}
#ifdef _OPENMP
#pragma omp critical(redux)
for
(
tid
=
0
;
tid
<
omp_get_num_threads
();
++
tid
)
{
for
(
i
=
0
;
i
<
n
;
++
i
)
{
for
(
i
=
0
;
i
<
n
;
++
i
)
{
b
[
i
]
+=
b_local
[
i
];
}
b
[
i
]
+=
b_local
[
tid
][
i
];
}
free
(
b_local
);
#endif
}
#endif
}
...
...
This diff is collapsed.
Click to expand it.
puremd_rc_1003/sPuReMD/QEq.c
+
1
−
1
View file @
69a25536
...
...
@@ -297,7 +297,7 @@ static void ICHOL_PAR( const sparse_matrix * const A, const unsigned int sweeps,
{
/* for each nonzero */
#pragma omp parallel for schedule(guided) \
default(none) private(sum, ei_x, ei_y) firstprivate(x, y)
default(none)
shared(DAD)
private(sum, ei_x, ei_y
, k
) firstprivate(x, y)
for
(
j
=
0
;
j
<
A
->
start
[
A
->
n
];
++
j
)
{
sum
=
ZERO
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment