Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
spm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
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
solverstack
spm
Commits
e481f9bc
Commit
e481f9bc
authored
7 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
Add functionnalities to generate fake values for any pattern matrix
parent
fb6ff07b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CMakeLists.txt
+1
-0
1 addition, 0 deletions
CMakeLists.txt
spm.h
+10
-1
10 additions, 1 deletion
spm.h
spm_gen_fake_values.c
+223
-0
223 additions, 0 deletions
spm_gen_fake_values.c
with
234 additions
and
1 deletion
CMakeLists.txt
+
1
−
0
View file @
e481f9bc
...
@@ -66,6 +66,7 @@ set(spm_sources
...
@@ -66,6 +66,7 @@ set(spm_sources
spm_integers.c
spm_integers.c
spm_dof_extend.c
spm_dof_extend.c
spm_read_driver.c
spm_read_driver.c
spm_gen_fake_values.c
drivers/skitf.f
drivers/skitf.f
drivers/iohb.c
drivers/iohb.c
drivers/mmio.c
drivers/mmio.c
...
...
This diff is collapsed.
Click to expand it.
spm.h
+
10
−
1
View file @
e481f9bc
...
@@ -96,7 +96,7 @@ void spmBase( pastix_spm_t *spm, int baseval );
...
@@ -96,7 +96,7 @@ void spmBase( pastix_spm_t *spm, int baseval );
pastix_int_t
spmFindBase
(
const
pastix_spm_t
*
spm
);
pastix_int_t
spmFindBase
(
const
pastix_spm_t
*
spm
);
int
spmConvert
(
int
ofmttype
,
pastix_spm_t
*
ospm
);
int
spmConvert
(
int
ofmttype
,
pastix_spm_t
*
ospm
);
void
spmUpdateComputedFields
(
pastix_spm_t
*
spm
);
void
spmUpdateComputedFields
(
pastix_spm_t
*
spm
);
void
spmGenFakeValues
(
pastix_spm_t
*
spm
);
/**
/**
* @}
* @}
...
@@ -215,6 +215,15 @@ static inline void d_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, doubl
...
@@ -215,6 +215,15 @@ static inline void d_spmPrintElt( FILE *f, pastix_int_t i, pastix_int_t j, doubl
static
inline
void
s_spmPrintElt
(
FILE
*
f
,
pastix_int_t
i
,
pastix_int_t
j
,
float
A
){
static
inline
void
s_spmPrintElt
(
FILE
*
f
,
pastix_int_t
i
,
pastix_int_t
j
,
float
A
){
fprintf
(
f
,
"%ld %ld %e
\n
"
,
(
long
)
i
,
(
long
)
j
,
A
);
fprintf
(
f
,
"%ld %ld %e
\n
"
,
(
long
)
i
,
(
long
)
j
,
A
);
}
}
/**
* @copydoc z_spmPrintElt
* @details Pattern case
*
* @remark: uses a macro to avoid accessing A that would generate segfault.
*/
#define p_spmPrintElt( f, i, j, A ) { \
fprintf( f, "%ld %ld\n", (long)i, (long)j ); \
}
/**
/**
* @}
* @}
...
...
This diff is collapsed.
Click to expand it.
spm_gen_fake_values.c
0 → 100644
+
223
−
0
View file @
e481f9bc
/**
* @file spm_gen_fake_values.c
*
* SParse Matrix generic laplacian value generator routines.
*
* @copyright 2016-2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
* Univ. Bordeaux. All rights reserved.
*
* @version 1.0.0
* @author Mathieu Faverge
* @author Xavier Lacoste
* @author Theophile Terraz
* @date 2015-01-01
*
**/
#include
"common.h"
#include
"spm.h"
/**
*******************************************************************************
*
* @ingroup spm_dev_driver
*
* @brief Compute the degree of each vertex.
*
*******************************************************************************
*
* @param[in] spm
* At start, an allocated spm structure.
* Contains the size of the laplacian in spm->n.
* At exit, contains the matrix in csc format.
*
* @param[inout] degrees
* Array of size spm->n allocated on entry. On exit, contains the
* degree of each vertex in the spm matrix.
*
*******************************************************************************/
static
inline
void
spm_compute_degrees
(
const
pastix_spm_t
*
spm
,
pastix_int_t
*
degrees
)
{
pastix_int_t
i
,
j
,
k
;
pastix_int_t
*
colptr
=
spm
->
colptr
;
pastix_int_t
*
rowptr
=
spm
->
rowptr
;
pastix_int_t
baseval
;
baseval
=
spmFindBase
(
spm
);
memset
(
degrees
,
0
,
spm
->
n
*
sizeof
(
pastix_int_t
)
);
switch
(
spm
->
fmttype
)
{
case
PastixCSR
:
/* Swap pointers to call CSC */
colptr
=
spm
->
rowptr
;
rowptr
=
spm
->
colptr
;
case
PastixCSC
:
for
(
j
=
0
;
j
<
spm
->
n
;
j
++
,
colptr
++
)
{
for
(
k
=
colptr
[
0
];
k
<
colptr
[
1
];
k
++
,
rowptr
++
)
{
i
=
*
rowptr
-
baseval
;
if
(
i
!=
j
)
{
degrees
[
j
]
+=
1
;
if
(
spm
->
mtxtype
!=
PastixGeneral
)
{
degrees
[
i
]
+=
1
;
}
}
}
}
break
;
case
PastixIJV
:
for
(
k
=
0
;
k
<
spm
->
nnz
;
k
++
,
rowptr
++
,
colptr
++
)
{
i
=
*
rowptr
-
baseval
;
j
=
*
colptr
-
baseval
;
if
(
i
!=
j
)
{
degrees
[
j
]
+=
1
;
if
(
spm
->
mtxtype
!=
PastixGeneral
)
{
degrees
[
i
]
+=
1
;
}
}
}
}
}
/**
*******************************************************************************
*
* @ingroup spm_dev_driver
*
* @brief Generate the fake values array such that \[ M = \alpha * D - \beta * A \]
*
* D is the degree matrix, and A the adjacency matrix.
*
*******************************************************************************
*
* @param[inout] spm
* The spm structure for which the values array must be generated.
*
* @param[in] degrees
* Array of size spm->n that containes the degree of each vertex in the
* spm structure.
*
*******************************************************************************/
static
inline
void
spm_generate_fake_values
(
pastix_spm_t
*
spm
,
const
pastix_int_t
*
degrees
,
double
alpha
,
double
beta
)
{
double
*
values
;
pastix_int_t
i
,
j
,
k
;
pastix_int_t
*
colptr
=
spm
->
colptr
;
pastix_int_t
*
rowptr
=
spm
->
rowptr
;
pastix_int_t
baseval
;
baseval
=
spmFindBase
(
spm
);
spm
->
values
=
malloc
(
spm
->
nnzexp
*
sizeof
(
double
)
);
values
=
spm
->
values
;
switch
(
spm
->
fmttype
)
{
case
PastixCSR
:
/* Swap pointers to call CSC */
colptr
=
spm
->
rowptr
;
rowptr
=
spm
->
colptr
;
case
PastixCSC
:
for
(
j
=
0
;
j
<
spm
->
n
;
j
++
,
colptr
++
)
{
for
(
k
=
colptr
[
0
];
k
<
colptr
[
1
];
k
++
,
rowptr
++
,
values
++
)
{
i
=
*
rowptr
-
baseval
;
if
(
i
==
j
)
{
*
values
=
alpha
*
degrees
[
j
];
}
else
{
*
values
=
-
beta
;
}
}
}
break
;
case
PastixIJV
:
for
(
k
=
0
;
k
<
spm
->
nnz
;
k
++
,
rowptr
++
,
colptr
++
,
values
++
)
{
i
=
*
rowptr
-
baseval
;
j
=
*
colptr
-
baseval
;
if
(
i
==
j
)
{
*
values
=
alpha
*
degrees
[
j
];
}
else
{
*
values
=
-
beta
;
}
}
}
spm
->
flttype
=
PastixDouble
;
}
/**
*******************************************************************************
*
* @ingroup pastix_spm
*
* @brief Generate the fake values array such that \[ M = \alpha * D - \beta * A \]
*
* D is the degree matrix, and A the adjacency matrix. The resulting matrix uses
* real double.
*
*******************************************************************************
*
* @param[inout] spm
* The spm structure for which the values array must be generated.
*
*******************************************************************************/
void
spmGenFakeValues
(
pastix_spm_t
*
spm
)
{
pastix_int_t
*
degrees
;
double
alpha
=
10
.;
double
beta
=
1
.;
assert
(
spm
->
flttype
==
PastixPattern
);
assert
(
spm
->
values
==
NULL
);
assert
(
spm
->
dof
==
1
);
/*
* Read environment values for alpha/beta
*/
{
char
*
str
=
pastix_getenv
(
"PASTIX_FAKE_ALPHA"
);
double
value
;
if
(
str
!=
NULL
)
{
value
=
strtod
(
str
,
NULL
);
if
(
(
value
!=
HUGE_VAL
)
&&
(
value
!=
0
.)
&&
!
isnan
(
value
)
&&
!
isinf
(
value
)
)
{
alpha
=
value
;
}
pastix_cleanenv
(
str
);
}
str
=
pastix_getenv
(
"PASTIX_FAKE_BETA"
);
if
(
str
!=
NULL
)
{
value
=
strtod
(
str
,
NULL
);
if
(
(
value
!=
HUGE_VAL
)
&&
(
value
!=
0
.)
&&
!
isnan
(
value
)
&&
!
isinf
(
value
)
)
{
beta
=
value
;
}
pastix_cleanenv
(
str
);
}
}
degrees
=
malloc
(
spm
->
n
*
sizeof
(
pastix_int_t
));
spm_compute_degrees
(
spm
,
degrees
);
spm_generate_fake_values
(
spm
,
degrees
,
alpha
,
beta
);
return
;
}
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