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
63e3f2ab
Commit
63e3f2ab
authored
9 years ago
by
Matthieu Schaller
Browse files
Options
Downloads
Patches
Plain Diff
Updated the test of a pair of cells and remaned it
parent
e0a31e5b
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!136
Master
,
!133
Updated vectorisation tests
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
.gitignore
+1
-1
1 addition, 1 deletion
.gitignore
tests/Makefile.am
+3
-3
3 additions, 3 deletions
tests/Makefile.am
tests/difffloat.py
+83
-0
83 additions, 0 deletions
tests/difffloat.py
tests/testPair.c
+4
-0
4 additions, 0 deletions
tests/testPair.c
tests/testPair.sh
+3
-0
3 additions, 0 deletions
tests/testPair.sh
with
94 additions
and
4 deletions
.gitignore
+
1
−
1
View file @
63e3f2ab
...
...
@@ -25,7 +25,7 @@ examples/swift_mindt
examples/swift_mindt_mpi
examples/swift_mpi
tests/test
Vectorize
tests/test
Pair
tests/brute_force.dat
tests/swift_dopair.dat
tests/testGreetings
...
...
This diff is collapsed.
Click to expand it.
tests/Makefile.am
+
3
−
3
View file @
63e3f2ab
...
...
@@ -21,10 +21,10 @@ AM_CFLAGS = -I../src $(HDF5_CPPFLAGS) -DTIMER
AM_LDFLAGS
=
../src/.libs/libswiftsim.a
$(
HDF5_LDFLAGS
)
$(
HDF5_LIBS
)
# List of programs and scripts to run in the test suite
TESTS
=
testGreetings testReading.sh testSingle test
TimeIntegration
TESTS
=
testGreetings testReading.sh testSingle test
Pair.sh
# List of test programs to compile
check_PROGRAMS
=
testGreetings testReading testSingle testTimeIntegration testSPHStep test
Vectorize
check_PROGRAMS
=
testGreetings testReading testSingle testTimeIntegration testSPHStep test
Pair
# Sources for the individual programs
testGreetings_SOURCES
=
testGreetings.c
...
...
@@ -37,7 +37,7 @@ testSPHStep_SOURCES = testSPHStep.c
testSingle_SOURCES
=
testSingle.c
test
Vectorize
_SOURCES
=
test
Vectorize
.c
test
Pair
_SOURCES
=
test
Pair
.c
# Files necessary for distribution
EXTRA_DIST
=
testReading.sh makeInput.py
This diff is collapsed.
Click to expand it.
tests/difffloat.py
0 → 100644
+
83
−
0
View file @
63e3f2ab
###############################################################################
# This file is part of SWIFT.
# Copyright (c) 2016 Matthieu Schaller (matthieu.schaller@durham.ac.uk)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
from
numpy
import
*
import
sys
abs_tol
=
1e-7
rel_tol
=
1e-7
# Compares the content of two ASCII tables of floats line by line and
# reports all differences beyond the given tolerances
# Comparisons are done both in absolute and relative values
file1
=
sys
.
argv
[
1
]
file2
=
sys
.
argv
[
2
]
if
len
(
sys
.
argv
)
>=
5
:
abs_tol
=
sys
.
argv
[
3
]
rel_tol
=
sys
.
argv
[
4
]
print
"
Absolute difference tolerance:
"
,
abs_tol
print
"
Relative difference tolerance:
"
,
rel_tol
data1
=
loadtxt
(
file1
)
data2
=
loadtxt
(
file2
)
if
shape
(
data1
)
!=
shape
(
data2
):
print
"
Non-matching array sizes in the files
"
,
file1
,
"
and
"
,
file2
,
"
.
"
sys
.
exit
(
1
)
n_lines
=
shape
(
data1
)[
0
]
n_columns
=
shape
(
data1
)[
1
]
error
=
False
for
i
in
range
(
n_lines
):
for
j
in
range
(
n_columns
):
abs_diff
=
abs
(
data1
[
i
,
j
]
-
data2
[
i
,
j
])
sum
=
abs
(
data1
[
i
,
j
]
+
data2
[
i
,
j
])
if
sum
>
0
:
rel_diff
=
abs
(
data1
[
i
,
j
]
-
data2
[
i
,
j
])
/
sum
else
:
rel_diff
=
0.
#
if
(
abs_diff
>
abs_tol
):
print
"
Absolute difference larger than tolerance (%e) on line %d, column %d:
"
%
(
abs_tol
,
i
,
j
)
print
"
%18s: a = %e
"
%
(
file1
,
data1
[
i
,
j
])
print
"
%18s: b = %e
"
%
(
file2
,
data2
[
i
,
j
])
print
"
%18s: |a-b| = %e
"
%
(
"
Difference
"
,
abs_diff
)
print
""
error
=
True
if
(
rel_diff
>
rel_tol
):
print
"
Relative difference larger than tolerance (%e) on line %d, column %d:
"
%
(
rel_tol
,
i
,
j
)
print
"
%18s: a = %e
"
%
(
file1
,
data1
[
i
,
j
])
print
"
%18s: b = %e
"
%
(
file2
,
data2
[
i
,
j
])
print
"
%18s: |a-b|/|a+b| = %e
"
%
(
"
Difference
"
,
rel_diff
)
print
""
error
=
True
if
error
:
sys
.
exit
(
1
)
else
:
print
"
No differences found
"
sys
.
exit
(
0
)
This diff is collapsed.
Click to expand it.
tests/test
Vectorize
.c
→
tests/test
Pair
.c
+
4
−
0
View file @
63e3f2ab
...
...
@@ -125,6 +125,10 @@ int main(int argc, char *argv[]) {
static
unsigned
long
long
partId
=
0
;
ticks
tic
,
toc
,
time
;
/* Initialize CPU frequency, this also starts time. */
unsigned
long
long
cpufreq
=
0
;
clocks_set_cpufreq
(
cpufreq
);
while
((
c
=
getopt
(
argc
,
argv
,
"h:p:r:t:"
))
!=
-
1
)
{
switch
(
c
)
{
case
'h'
:
...
...
This diff is collapsed.
Click to expand it.
tests/testPair.sh
0 → 100755
+
3
−
0
View file @
63e3f2ab
#!/bin/bash
./testPair
-p
6
-r
1
python difffloat.py brute_force.dat swift_dopair.dat 1e-5 2e-6
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