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
fb6ff07b
Commit
fb6ff07b
authored
7 years ago
by
Mathieu Faverge
Browse files
Options
Downloads
Patches
Plain Diff
Add spmNew, spmFree function for better handling of the spm in Fortran
parent
7a930fb9
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
spm.c
+134
-43
134 additions, 43 deletions
spm.c
spm.h
+16
-15
16 additions, 15 deletions
spm.h
with
150 additions
and
58 deletions
spm.c
+
134
−
43
View file @
fb6ff07b
...
...
@@ -191,37 +191,99 @@ spmUpdateComputedFields( pastix_spm_t *spm )
/**
*******************************************************************************
*
* @brief
Init the spm structure
.
* @brief
Generate a new spm structure out of the provided information
.
*
*******************************************************************************
*
* @param[inout] spm
* The sparse matrix to init.
* @param[in] mtxtype
* Specify the matrix symmetry property
* - PastixGeneral, if the matrix is general
* - PastixSymmetric, if the matrix is symmetric
* - PastixHermitian, if the matrix is complex hermitian
*
* @param[in] flttype
* Specify the floating point arithmetic used by the matrix
* - PastixPattern, if only the pattern is provided and no values
* - PastixFloat, if the values are real single precision
* - PastixDouble, if the values are real double precision
* - PastixComplex32, if the values are complex single precision
* - PastixComplex64, if the values are complex double precision
*
* @param[in] fmttype
* Specify the format used to store the matrix
* - PastixIJV, if in the IJV format
* - PastixCSC, if in the compressed sparse column format
* - PastixCSR, if in the compressed sparse row format
*
* @param[in] n
* Specify the number of unknow in the matrix graph
*
* @param[in] nnz
* Specify the number of non-zeros in the matrix graph (ie the number
* of edges)
*
* @param[in] colptr
* The column index array of size n+1 if fmttype == PastixCSC, nnz
* otherwise.
*
* @param[in] rowptr
* The row index array of size n+1 if fmttype == PastixCSR, nnz
* otherwise.
*
* @param[in] values
* The values array in type flttype and of size nnz, or nnz * (the size
* of each elemental matrix) if the numbef of degrees of freedom is
* different from 1.
*
* @param[in] loc2glob
* The correspondance array of local indices vertices to global
* numbering. (Unused for now)
*
* @param[in] dof Sepecify the degrees of freedom of each elementary. It must be
* 1 by default. If dof > 1, the a constant degree of freedom is used,
* otherwise if dof < 1, variadic degrees are used and specified by
* dofs.
*
* @param[in] layout
* Specify the layout used to stotre each elementatry matrix in the
* values array.
* - PastixRowMajor, if row major layout
* - PastixColMajor, if column major layout
*
* @param[in] dofs
* The index array of each local vertex in the expanded matrix of size
* n+1. The degree of freedom of the vertex i is given by
* dofs[i+1]-dofs[i].
*
*******************************************************************************
*
* @return The newly allocated matrix on success, and NULL otherwise.
*
*******************************************************************************/
void
spm
(
pastix_spm_t
*
spm
,
pastix_symmetry_t
mtxtype
,
pastix_coeftype_t
flttype
,
pastix_fmttype_t
fmttype
,
pastix_int_t
n
,
pastix_int_t
nnz
,
pastix_int_t
*
colptr
,
pastix_int_t
*
rowptr
,
void
*
values
,
pastix_int_t
*
loc2glob
,
pastix_int_t
dof
,
pastix_layout_t
layout
,
pastix_int_t
*
dofs
)
pastix_spm_t
*
spmNew
(
pastix_symmetry_t
mtxtype
,
pastix_coeftype_t
flttype
,
pastix_fmttype_t
fmttype
,
pastix_int_t
n
,
pastix_int_t
nnz
,
pastix_int_t
*
colptr
,
pastix_int_t
*
rowptr
,
void
*
values
,
pastix_int_t
*
loc2glob
,
pastix_int_t
dof
,
pastix_layout_t
layout
,
pastix_int_t
*
dofs
)
{
pastix_spm_t
*
spm
=
malloc
(
sizeof
(
pastix_spm_t
)
);
spmInit
(
spm
);
if
(
(
mtxtype
!=
PastixGeneral
)
&&
(
mtxtype
!=
Pastix
General
)
&&
(
mtxtype
!=
Pastix
General
)
)
if
(
(
mtxtype
!=
PastixGeneral
)
&&
(
mtxtype
!=
Pastix
Symmetric
)
&&
(
mtxtype
!=
Pastix
Hermitian
)
)
{
fprintf
(
stderr
,
"spm: The sparse matrix type must be PastixGeneral, PastixSymmetric or PastixHermitian
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The sparse matrix type must be PastixGeneral, PastixSymmetric or PastixHermitian
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
mtxtype
=
mtxtype
;
...
...
@@ -231,8 +293,9 @@ spm( pastix_spm_t *spm,
(
flttype
!=
PastixComplex32
)
&&
(
flttype
!=
PastixComplex64
)
)
{
fprintf
(
stderr
,
"spm: The sparse matrix coefficient type must be PastixPattern, PastixFloat, PastixDouble, PastixComplex32, or PastixComplex64
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The sparse matrix coefficient type must be PastixPattern, PastixFloat, PastixDouble, PastixComplex32, or PastixComplex64
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
flttype
=
flttype
;
...
...
@@ -240,47 +303,54 @@ spm( pastix_spm_t *spm,
(
fmttype
!=
PastixCSR
)
&&
(
fmttype
!=
PastixIJV
)
)
{
fprintf
(
stderr
,
"spm: The sparse matrix format type must be PastixCSC, PastixCSR, or PastixIJV
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The sparse matrix format type must be PastixCSC, PastixCSR, or PastixIJV
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
fmttype
=
fmttype
;
if
(
n
<=
0
)
{
fprintf
(
stderr
,
"spm: The local matrix size n, must be strictly positive
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The local matrix size n, must be strictly positive
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
n
=
n
;
if
(
nnz
<=
0
)
{
fprintf
(
stderr
,
"spm: The number of non zeros in the local matrix must be strictly positive
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The number of non zeros in the local matrix must be strictly positive
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
nnz
=
nnz
;
if
(
colptr
==
NULL
)
{
fprintf
(
stderr
,
"spm: The colptr array must be provided and of size n+1, if PastixCSC, nnz otherwise
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The colptr array must be provided and of size n+1, if PastixCSC, nnz otherwise
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
colptr
=
colptr
;
if
(
rowptr
==
NULL
)
{
fprintf
(
stderr
,
"spm: The rowptr array must be provided and of size n+1, if PastixCSR, nnz otherwise
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The rowptr array must be provided and of size n+1, if PastixCSR, nnz otherwise
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
rowptr
=
rowptr
;
if
(
loc2glob
!=
NULL
)
{
fprintf
(
stderr
,
"spm: The distributed interface is not supported for now
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The distributed interface is not supported for now
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
loc2glob
=
NULL
;
if
(
(
flttype
!=
PastixPattern
)
&&
(
values
==
NULL
)
)
{
fprintf
(
stderr
,
"spm: The values array of size nnz, and of type flttype must be provided
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The values array of size nnz, and of type flttype must be provided
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
values
=
values
;
...
...
@@ -291,15 +361,17 @@ spm( pastix_spm_t *spm,
if
(
(
layout
!=
PastixColMajor
)
&&
(
layout
!=
PastixRowMajor
)
)
{
fprintf
(
stderr
,
"spm: The sparse matrix layout for multi-dof must be PastixColMajor or PastixRowMajor
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The sparse matrix layout for multi-dof must be PastixColMajor or PastixRowMajor
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
layout
=
layout
;
if
(
dof
<
1
)
{
if
(
dofs
==
NULL
)
{
fprintf
(
stderr
,
"spm: The dofs array must be provided when dof < 1
\n
"
);
return
;
fprintf
(
stderr
,
"spmNew: The dofs array must be provided when dof < 1
\n
"
);
free
(
spm
);
return
NULL
;
}
spm
->
dofs
=
dofs
;
}
...
...
@@ -308,12 +380,13 @@ spm( pastix_spm_t *spm,
}
}
spmUpdateComputedFields
(
spm
);
return
spm
;
}
/**
*******************************************************************************
*
* @brief
Free
the spm structure.
* @brief
Cleanup
the spm structure
but do not free the spm pointer
.
*
*******************************************************************************
*
...
...
@@ -336,6 +409,24 @@ spmExit( pastix_spm_t *spm )
memFree_null
(
spm
->
dofs
);
}
/**
*******************************************************************************
*
* @brief Cleanup the spm structure and free the spm pointer.
*
*******************************************************************************
*
* @param[inout] spm
* The sparse matrix to free.
*
*******************************************************************************/
void
spmFree
(
pastix_spm_t
*
spm
)
{
spmExit
(
spm
);
free
(
spm
);
}
/**
*******************************************************************************
*
...
...
This diff is collapsed.
Click to expand it.
spm.h
+
16
−
15
View file @
fb6ff07b
...
...
@@ -75,27 +75,28 @@ typedef struct pastix_spm_s {
* @name SPM basic subroutines
* @{
*/
void
spmInit
(
pastix_spm_t
*
spm
);
void
spmExit
(
pastix_spm_t
*
spm
);
pastix_spm_t
*
spmNew
(
pastix_symmetry_t
mtxtype
,
pastix_coeftype_t
flttype
,
pastix_fmttype_t
fmttype
,
pastix_int_t
n
,
pastix_int_t
nnz
,
pastix_int_t
*
colptr
,
pastix_int_t
*
rowptr
,
void
*
values
,
pastix_int_t
*
loc2glob
,
pastix_int_t
dof
,
pastix_layout_t
layout
,
pastix_int_t
*
dofs
);
void
spmInit
(
pastix_spm_t
*
spm
);
void
spmExit
(
pastix_spm_t
*
spm
);
void
spmFree
(
pastix_spm_t
*
spm
);
pastix_spm_t
*
spmCopy
(
const
pastix_spm_t
*
spm
);
void
spmBase
(
pastix_spm_t
*
spm
,
int
baseval
);
pastix_int_t
spmFindBase
(
const
pastix_spm_t
*
spm
);
int
spmConvert
(
int
ofmttype
,
pastix_spm_t
*
ospm
);
void
spmUpdateComputedFields
(
pastix_spm_t
*
spm
);
void
spm
(
pastix_spm_t
*
spm
,
pastix_symmetry_t
mtxtype
,
pastix_coeftype_t
flttype
,
pastix_fmttype_t
fmttype
,
pastix_int_t
n
,
pastix_int_t
nnz
,
pastix_int_t
*
colptr
,
pastix_int_t
*
rowptr
,
void
*
values
,
pastix_int_t
*
loc2glob
,
pastix_int_t
dof
,
pastix_layout_t
layout
,
pastix_int_t
*
dofs
);
/**
* @}
...
...
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