Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SWIFTsim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
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
SWIFT
SWIFTsim
Commits
a8f5af22
Commit
a8f5af22
authored
8 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Added support for output of 'char' fields in the snapshots.
parent
33476206
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/common_io.c
+1
-1
1 addition, 1 deletion
src/common_io.c
src/xmf.c
+50
-4
50 additions, 4 deletions
src/xmf.c
tests/testKernel.c
+3
-3
3 additions, 3 deletions
tests/testKernel.c
with
54 additions
and
8 deletions
src/common_io.c
+
1
−
1
View file @
a8f5af22
...
...
@@ -74,7 +74,7 @@ hid_t io_hdf5_type(enum IO_DATA_TYPE type) {
case
DOUBLE
:
return
H5T_NATIVE_DOUBLE
;
case
CHAR
:
return
H5T_
C_S1
;
return
H5T_
NATIVE_CHAR
;
default:
error
(
"Unknown type"
);
return
0
;
...
...
This diff is collapsed.
Click to expand it.
src/xmf.c
+
50
−
4
View file @
a8f5af22
...
...
@@ -181,6 +181,50 @@ void xmf_write_groupfooter(FILE* xmfFile, enum part_type ptype) {
part_type_names
[
ptype
]);
}
/**
* @brief Returns the precision of a given dataset type
*/
int
xmf_precision
(
enum
IO_DATA_TYPE
type
)
{
switch
(
type
)
{
case
FLOAT
:
return
4
;
break
;
case
DOUBLE
:
return
8
;
break
;
case
ULONGLONG
:
return
8
;
break
;
case
CHAR
:
return
1
;
break
;
default:
error
(
"Unsupported type"
);
}
return
0
;
}
/**
* @brief Returns the Xdmf type name of a given dataset type
*/
const
char
*
xmf_type
(
enum
IO_DATA_TYPE
type
)
{
switch
(
type
)
{
case
FLOAT
:
case
DOUBLE
:
return
"Float"
;
break
;
case
ULONGLONG
:
return
"Int"
;
break
;
case
CHAR
:
return
"Char"
;
break
;
default:
error
(
"Unsupported type"
);
}
return
""
;
}
/**
* @brief Writes the lines corresponding to an array of the HDF5 output
*
...
...
@@ -203,13 +247,15 @@ void xmf_write_line(FILE* xmfFile, const char* fileName,
name
,
dim
==
1
?
"Scalar"
:
"Vector"
);
if
(
dim
==
1
)
fprintf
(
xmfFile
,
"<DataItem Dimensions=
\"
%zu
\"
NumberType=
\"
Double
\"
"
"<DataItem Dimensions=
\"
%zu
\"
NumberType=
\"
%s
\"
"
"Precision=
\"
%d
\"
Format=
\"
HDF
\"
>%s:%s/%s</DataItem>
\n
"
,
N
,
type
==
FLOAT
?
4
:
8
,
fileName
,
partTypeGroupName
,
name
);
N
,
xmf_type
(
type
),
xmf_precision
(
type
),
fileName
,
partTypeGroupName
,
name
);
else
fprintf
(
xmfFile
,
"<DataItem Dimensions=
\"
%zu %d
\"
NumberType=
\"
Double
\"
"
"<DataItem Dimensions=
\"
%zu %d
\"
NumberType=
\"
%s
\"
"
"Precision=
\"
%d
\"
Format=
\"
HDF
\"
>%s:%s/%s</DataItem>
\n
"
,
N
,
dim
,
type
==
FLOAT
?
4
:
8
,
fileName
,
partTypeGroupName
,
name
);
N
,
dim
,
xmf_type
(
type
),
xmf_precision
(
type
),
fileName
,
partTypeGroupName
,
name
);
fprintf
(
xmfFile
,
"</Attribute>
\n
"
);
}
This diff is collapsed.
Click to expand it.
tests/testKernel.c
+
3
−
3
View file @
a8f5af22
...
...
@@ -91,7 +91,7 @@ int main() {
printf
(
"
\n
Vector Output for kernel_deval_2_vec
\n
"
);
printf
(
"-------------
\n
"
);
/* Test vectorised kernel that uses two vectors. */
for
(
int
i
=
0
;
i
<
numPoints
;
i
+=
VEC_SIZE
)
{
...
...
@@ -100,7 +100,7 @@ int main() {
vector
vx_2
,
vx_h_2
;
vector
W_vec_2
,
dW_vec_2
;
for
(
int
j
=
0
;
j
<
VEC_SIZE
;
j
++
)
{
vx
.
f
[
j
]
=
(
i
+
j
)
*
2
.
25
f
/
numPoints
;
vx_2
.
f
[
j
]
=
(
i
+
j
)
*
2
.
25
f
/
numPoints
;
...
...
@@ -127,7 +127,7 @@ int main() {
return
1
;
}
}
/* Check second vector results. */
for
(
int
j
=
0
;
j
<
VEC_SIZE
;
j
++
)
{
printf
(
"%2d: h= %f H= %f x=%f W(x,h)=%f dW(x,h)=%f
\n
"
,
i
+
j
,
h
,
...
...
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