Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psaap3-weno
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
psaap3-weno
Commits
319b4d98
Commit
319b4d98
authored
5 years ago
by
Timothy A. Smith
Browse files
Options
Downloads
Patches
Plain Diff
take transforms out of compute_flux_derivatives
parent
6122d5fd
No related branches found
Branches containing commit
No related tags found
1 merge request
!8
Test refactoring
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
kernel_fixtures.py
+2
-17
2 additions, 17 deletions
kernel_fixtures.py
setup_fixtures.py
+4
-0
4 additions, 0 deletions
setup_fixtures.py
test.py
+9
-3
9 additions, 3 deletions
test.py
transform_fixtures.py
+15
-0
15 additions, 0 deletions
transform_fixtures.py
with
30 additions
and
20 deletions
kernel_fixtures.py
+
2
−
17
View file @
319b4d98
...
...
@@ -29,23 +29,7 @@ def mult_mat_vec(queue, prg, alpha, a, b):
return
c_dev
.
get
()
def
compute_flux_derivatives
(
ctx_factory
,
params
,
arrays
):
queue
=
device
.
get_queue
(
ctx_factory
)
prg
=
program
.
get_weno
()
cfd
=
prg
[
"
compute_flux_derivatives
"
]
cfd
=
lp
.
assume
(
cfd
,
"
nx > 0 and ny > 0 and nz > 0
"
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
flux_derivatives_generalized
"
,
lp
.
AddressSpace
.
GLOBAL
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
generalized_fluxes
"
,
lp
.
AddressSpace
.
GLOBAL
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
weno_flux_tmp
"
,
lp
.
AddressSpace
.
GLOBAL
)
prg
=
prg
.
with_kernel
(
cfd
)
def
compute_flux_derivatives
(
queue
,
prg
,
params
,
arrays
):
flux_derivatives_dev
=
cl
.
array
.
empty
(
queue
,
(
params
.
nvars
,
params
.
ndim
,
params
.
nx_halo
,
params
.
ny_halo
,
params
.
nz_halo
),
dtype
=
np
.
float32
,
order
=
"
F
"
)
...
...
@@ -53,6 +37,7 @@ def compute_flux_derivatives(ctx_factory, params, arrays):
states
=
arrays
.
states
,
fluxes
=
arrays
.
fluxes
,
metrics
=
arrays
.
metrics
,
metric_jacobians
=
arrays
.
metric_jacobians
,
flux_derivatives
=
flux_derivatives_dev
)
return
flux_derivatives_dev
.
get
()
def
compute_flux_derivatives_gpu
(
ctx_factory
,
params
,
arrays
):
...
...
This diff is collapsed.
Click to expand it.
setup_fixtures.py
+
4
−
0
View file @
319b4d98
...
...
@@ -39,6 +39,10 @@ class FluxDerivativeArrays:
self
.
metric_jacobians
=
metric_jacobians
def
flux_derivative_params
(
nvars
,
ndim
,
n
):
return
FluxDerivativeParams
(
nvars
,
ndim
,
n
,
n
,
n
)
def
random_array
(
*
shape
):
return
np
.
random
.
random_sample
(
shape
).
astype
(
np
.
float32
).
copy
(
order
=
"
F
"
)
...
...
This diff is collapsed.
Click to expand it.
test.py
+
9
−
3
View file @
319b4d98
...
...
@@ -8,6 +8,7 @@ from pyopencl.tools import ( # noqa
import
device_fixtures
as
device
import
program_fixtures
as
program
import
transform_fixtures
as
transform
import
setup_fixtures
as
setup
import
kernel_fixtures
as
kernel
import
comparison_fixtures
as
compare
...
...
@@ -25,14 +26,19 @@ def test_matvec(ctx_factory):
def
test_compute_flux_derivatives
(
ctx_factory
):
params
=
setup
.
FluxDerivativeParams
(
ndim
=
3
,
nvars
=
5
,
nx
=
10
,
ny
=
10
,
nz
=
10
)
queue
=
device
.
get_queue
(
ctx_factory
)
prg
=
program
.
get_weno
()
prg
=
transform
.
compute_flux_derivative_basic
(
prg
)
params
=
setup
.
flux_derivative_params
(
ndim
=
3
,
nvars
=
5
,
n
=
10
)
arrays
=
setup
.
random_flux_derivative_arrays
(
params
)
kernel
.
compute_flux_derivatives
(
ctx_factory
,
params
,
arrays
)
kernel
.
compute_flux_derivatives
(
queue
,
prg
,
params
,
arrays
)
@pytest.mark.skip
(
"
slow
"
)
def
test_compute_flux_derivatives_gpu
(
ctx_factory
):
params
=
setup
.
F
lux
D
erivative
P
arams
(
ndim
=
3
,
nvars
=
5
,
n
x
=
10
,
ny
=
10
,
nz
=
10
)
params
=
setup
.
f
lux
_d
erivative
_p
arams
(
ndim
=
3
,
nvars
=
5
,
n
=
10
)
arrays
=
setup
.
random_flux_derivative_arrays_on_device
(
ctx_factory
,
params
)
kernel
.
compute_flux_derivatives_gpu
(
ctx_factory
,
params
,
arrays
)
...
...
This diff is collapsed.
Click to expand it.
transform_fixtures.py
+
15
−
0
View file @
319b4d98
import
loopy
as
lp
def
compute_flux_derivative_basic
(
prg
):
cfd
=
prg
[
"
compute_flux_derivatives
"
]
cfd
=
lp
.
assume
(
cfd
,
"
nx > 0 and ny > 0 and nz > 0
"
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
flux_derivatives_generalized
"
,
lp
.
AddressSpace
.
GLOBAL
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
generalized_fluxes
"
,
lp
.
AddressSpace
.
GLOBAL
)
cfd
=
lp
.
set_temporary_scope
(
cfd
,
"
weno_flux_tmp
"
,
lp
.
AddressSpace
.
GLOBAL
)
return
prg
.
with_kernel
(
cfd
)
def
weno_for_gpu
(
prg
):
cfd
=
prg
[
"
compute_flux_derivatives
"
]
...
...
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