Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lbmpy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
lbmpy
Commits
c1c40069
Commit
c1c40069
authored
8 months ago
by
Frederik Hennig
Browse files
Options
Downloads
Patches
Plain Diff
Enable vectorization in some tests
parent
3962799b
No related branches found
No related tags found
1 merge request
!172
Changes for compatibility with pystencils 2.0
Pipeline
#70368
failed
8 months ago
Stage: pretest
Stage: test
Stage: prerelease
Stage: docs
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lbmpy/_compat.py
+7
-1
7 additions, 1 deletion
src/lbmpy/_compat.py
tests/full_scenarios/schaefer_turek/scenario_schaefer_turek.py
+2
-0
2 additions, 0 deletions
.../full_scenarios/schaefer_turek/scenario_schaefer_turek.py
tests/test_vectorization.py
+67
-31
67 additions, 31 deletions
tests/test_vectorization.py
with
76 additions
and
32 deletions
src/lbmpy/_compat.py
+
7
−
1
View file @
c1c40069
...
...
@@ -13,7 +13,13 @@ if PYSTENCILS_VERSION_MAJOR == 2:
return
DEFAULTS
.
spatial_counters
[
coord
]
def
get_supported_instruction_sets
():
return
[]
from
pystencils
import
Target
vector_targets
=
Target
.
available_vector_cpu_targets
()
isas
=
[]
for
target
in
vector_targets
:
tokens
=
target
.
name
.
split
(
"
_
"
)
isas
.
append
(
tokens
[
-
1
].
lower
())
return
isas
else
:
from
pystencils.backends.simd_instruction_sets
import
(
...
...
This diff is collapsed.
Click to expand it.
tests/full_scenarios/schaefer_turek/scenario_schaefer_turek.py
+
2
−
0
View file @
c1c40069
...
...
@@ -10,6 +10,8 @@ import warnings
import
numpy
as
np
import
pytest
from
pystencils
import
Target
from
lbmpy._compat
import
get_supported_instruction_sets
from
lbmpy.boundaries.boundaryconditions
import
NoSlip
from
lbmpy.geometry
import
get_pipe_velocity_field
...
...
This diff is collapsed.
Click to expand it.
tests/test_vectorization.py
+
67
−
31
View file @
c1c40069
import
numpy
as
np
import
pytest
from
dataclasses
import
replace
import
pystencils
as
ps
from
lbmpy._compat
import
get_supported_instruction_sets
from
lbmpy._compat
import
get_supported_instruction_sets
,
IS_PYSTENCILS_2
from
lbmpy.scenarios
import
create_lid_driven_cavity
from
lbmpy.creationfunctions
import
LBMConfig
,
LBMOptimisation
...
...
@@ -11,7 +12,7 @@ if vector_isas is None:
vector_isas
=
[]
@pytest.mark.skipif
(
not
vector_isas
,
reason
=
'
cannot detect CPU instruction set
'
)
@pytest.mark.skipif
(
not
vector_isas
,
reason
=
"
cannot detect CPU instruction set
"
)
def
test_lbm_vectorization_short
():
print
(
"
Computing reference solutions
"
)
size1
=
(
64
,
32
)
...
...
@@ -21,30 +22,45 @@ def test_lbm_vectorization_short():
ldc1_ref
.
run
(
10
)
lbm_config
=
LBMConfig
(
relaxation_rate
=
relaxation_rate
)
config
=
ps
.
CreateKernelConfig
(
cpu_vectorize_info
=
{
'
instruction_set
'
:
get_supported_instruction_sets
()[
-
1
],
'
assume_aligned
'
:
True
,
'
nontemporal
'
:
True
,
'
assume_inner_stride_one
'
:
True
,
'
assume_sufficient_line_padding
'
:
False
,
})
ldc1
=
create_lid_driven_cavity
(
size1
,
lbm_config
=
lbm_config
,
config
=
config
,
fixed_loop_sizes
=
False
)
config
=
ps
.
CreateKernelConfig
(
cpu_vectorize_info
=
{
"
instruction_set
"
:
get_supported_instruction_sets
()[
-
1
],
"
assume_aligned
"
:
True
,
"
nontemporal
"
:
True
,
"
assume_inner_stride_one
"
:
True
,
"
assume_sufficient_line_padding
"
:
False
,
}
)
ldc1
=
create_lid_driven_cavity
(
size1
,
lbm_config
=
lbm_config
,
config
=
config
,
fixed_loop_sizes
=
False
)
ldc1
.
run
(
10
)
@pytest.mark.skipif
(
not
vector_isas
,
reason
=
'
cannot detect CPU instruction set
'
)
@pytest.mark.parametrize
(
'
instruction_set
'
,
vector_isas
)
@pytest.mark.parametrize
(
'
aligned_and_padding
'
,
[[
False
,
False
],
[
True
,
False
],
[
True
,
True
]])
@pytest.mark.parametrize
(
'
nontemporal
'
,
[
False
,
True
])
@pytest.mark.parametrize
(
'
double_precision
'
,
[
False
,
True
])
@pytest.mark.parametrize
(
'
fixed_loop_sizes
'
,
[
False
,
True
])
@pytest.mark.skipif
(
not
vector_isas
,
reason
=
"
cannot detect CPU instruction set
"
)
@pytest.mark.xfail
(
reason
=
"
Loop splitting is not available yet
"
)
@pytest.mark.parametrize
(
"
instruction_set
"
,
vector_isas
)
@pytest.mark.parametrize
(
"
aligned_and_padding
"
,
[[
False
,
False
],
[
True
,
False
],
[
True
,
True
]]
)
@pytest.mark.parametrize
(
"
nontemporal
"
,
[
False
,
True
])
@pytest.mark.parametrize
(
"
double_precision
"
,
[
False
,
True
])
@pytest.mark.parametrize
(
"
fixed_loop_sizes
"
,
[
False
,
True
])
@pytest.mark.longrun
def
test_lbm_vectorization
(
instruction_set
,
aligned_and_padding
,
nontemporal
,
double_precision
,
fixed_loop_sizes
):
vectorization_options
=
{
'
instruction_set
'
:
instruction_set
,
'
assume_aligned
'
:
aligned_and_padding
[
0
],
'
nontemporal
'
:
nontemporal
,
'
assume_inner_stride_one
'
:
True
,
'
assume_sufficient_line_padding
'
:
aligned_and_padding
[
1
]}
def
test_lbm_vectorization
(
instruction_set
,
aligned_and_padding
,
nontemporal
,
double_precision
,
fixed_loop_sizes
,
):
vectorization_options
=
{
"
instruction_set
"
:
instruction_set
,
"
assume_aligned
"
:
aligned_and_padding
[
0
],
"
nontemporal
"
:
nontemporal
,
"
assume_inner_stride_one
"
:
True
,
"
assume_sufficient_line_padding
"
:
aligned_and_padding
[
1
],
}
time_steps
=
100
size1
=
(
64
,
32
)
size2
=
(
666
,
34
)
...
...
@@ -57,20 +73,40 @@ def test_lbm_vectorization(instruction_set, aligned_and_padding, nontemporal, do
ldc2_ref
.
run
(
time_steps
)
lbm_config
=
LBMConfig
(
relaxation_rate
=
relaxation_rate
)
config
=
ps
.
CreateKernelConfig
(
data_type
=
"
float64
"
if
double_precision
else
"
float32
"
,
default_number_float
=
"
float64
"
if
double_precision
else
"
float32
"
,
cpu_vectorize_info
=
vectorization_options
)
config
=
ps
.
CreateKernelConfig
(
data_type
=
"
float64
"
if
double_precision
else
"
float32
"
,
cpu_vectorize_info
=
vectorization_options
,
)
if
not
IS_PYSTENCILS_2
:
config
=
replace
(
config
,
default_number_float
=
"
float64
"
if
double_precision
else
"
float32
"
,
)
lbm_opt_split
=
LBMOptimisation
(
cse_global
=
True
,
split
=
True
)
lbm_opt
=
LBMOptimisation
(
cse_global
=
True
,
split
=
False
)
print
(
f
"
Vectorization test, double precision
{
double_precision
}
, vectorization
{
vectorization_options
}
,
"
f
"
fixed loop sizes
{
fixed_loop_sizes
}
"
)
ldc1
=
create_lid_driven_cavity
(
size1
,
fixed_loop_sizes
=
fixed_loop_sizes
,
lbm_config
=
lbm_config
,
lbm_optimisation
=
lbm_opt
,
config
=
config
)
print
(
f
"
Vectorization test, double precision
{
double_precision
}
, vectorization
{
vectorization_options
}
,
"
f
"
fixed loop sizes
{
fixed_loop_sizes
}
"
)
ldc1
=
create_lid_driven_cavity
(
size1
,
fixed_loop_sizes
=
fixed_loop_sizes
,
lbm_config
=
lbm_config
,
lbm_optimisation
=
lbm_opt
,
config
=
config
,
)
ldc1
.
run
(
time_steps
)
np
.
testing
.
assert_almost_equal
(
ldc1_ref
.
velocity
[:,
:],
ldc1
.
velocity
[:,
:])
ldc2
=
create_lid_driven_cavity
(
size2
,
fixed_loop_sizes
=
fixed_loop_sizes
,
lbm_config
=
lbm_config
,
lbm_optimisation
=
lbm_opt_split
,
config
=
config
)
ldc2
=
create_lid_driven_cavity
(
size2
,
fixed_loop_sizes
=
fixed_loop_sizes
,
lbm_config
=
lbm_config
,
lbm_optimisation
=
lbm_opt_split
,
config
=
config
,
)
ldc2
.
run
(
time_steps
)
np
.
testing
.
assert_almost_equal
(
ldc2_ref
.
velocity
[:,
:],
ldc2
.
velocity
[:,
:])
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