[pyfr] 15/88: Cleanups.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Wed Nov 16 12:05:25 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository pyfr.
commit 56d9e0f120f820539da5a2731c6ebd075e4cd741
Author: Freddie Witherden <freddie at witherden.org>
Date: Wed Apr 20 20:22:43 2016 -0700
Cleanups.
---
pyfr/backends/base/backend.py | 12 +++++++++++-
pyfr/backends/cuda/base.py | 7 -------
pyfr/backends/mic/base.py | 7 -------
pyfr/backends/opencl/base.py | 7 -------
pyfr/backends/openmp/base.py | 7 -------
pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako | 7 +------
pyfr/template.py | 4 ++--
7 files changed, 14 insertions(+), 37 deletions(-)
diff --git a/pyfr/backends/base/backend.py b/pyfr/backends/base/backend.py
index a8519cd..40ab6a4 100644
--- a/pyfr/backends/base/backend.py
+++ b/pyfr/backends/base/backend.py
@@ -4,11 +4,14 @@ from abc import ABCMeta, abstractmethod
from collections import defaultdict
from functools import wraps
from itertools import count
-from weakref import WeakValueDictionary, WeakKeyDictionary
+import math
+from weakref import WeakKeyDictionary, WeakValueDictionary
import numpy as np
from pyfr.backends.base.kernels import NotSuitableError
+from pyfr.template import DottedTemplateLookup
+from pyfr.util import lazyprop
def recordmat(fn):
@@ -50,6 +53,13 @@ class BaseBackend(object, metaclass=ABCMeta):
# Mapping from backend objects to memory extents
self._obj_extents = WeakKeyDictionary()
+ @lazyprop
+ def lookup(self):
+ pkg = 'pyfr.backends.{0}.kernels'.format(self.name)
+ dfltargs = dict(alignb=self.alignb, fpdtype=self.fpdtype, math=math)
+
+ return DottedTemplateLookup(pkg, dfltargs)
+
def malloc(self, obj, extent):
# If no extent has been specified then autocommit
if extent is None:
diff --git a/pyfr/backends/cuda/base.py b/pyfr/backends/cuda/base.py
index b379810..cf536f9 100644
--- a/pyfr/backends/cuda/base.py
+++ b/pyfr/backends/cuda/base.py
@@ -5,7 +5,6 @@ import re
from pyfr.backends.base import BaseBackend
from pyfr.mpiutil import get_local_rank
-from pyfr.template import DottedTemplateLookup
class CUDABackend(BaseBackend):
@@ -58,12 +57,6 @@ class CUDABackend(BaseBackend):
self.xchg_matrix_cls = types.CUDAXchgMatrix
self.xchg_view_cls = types.CUDAXchgView
- # Template lookup
- self.lookup = DottedTemplateLookup(
- 'pyfr.backends.cuda.kernels',
- fpdtype=self.fpdtype, alignb=self.alignb
- )
-
# Instantiate the base kernel providers
kprovs = [provider.CUDAPointwiseKernelProvider,
blasext.CUDABlasExtKernels,
diff --git a/pyfr/backends/mic/base.py b/pyfr/backends/mic/base.py
index 512ef81..2a74f15 100644
--- a/pyfr/backends/mic/base.py
+++ b/pyfr/backends/mic/base.py
@@ -4,7 +4,6 @@ import numpy as np
from pyfr.backends.base import BaseBackend
from pyfr.mpiutil import get_local_rank
-from pyfr.template import DottedTemplateLookup
class MICBackend(BaseBackend):
@@ -45,12 +44,6 @@ class MICBackend(BaseBackend):
self.xchg_matrix_cls = types.MICXchgMatrix
self.xchg_view_cls = types.MICXchgView
- # Template lookup
- self.lookup = DottedTemplateLookup(
- 'pyfr.backends.mic.kernels',
- fpdtype=self.fpdtype, alignb=self.alignb
- )
-
# Kernel provider classes
kprovcls = [provider.MICPointwiseKernelProvider,
blasext.MICBlasExtKernels,
diff --git a/pyfr/backends/opencl/base.py b/pyfr/backends/opencl/base.py
index ec4f20d..bff3625 100644
--- a/pyfr/backends/opencl/base.py
+++ b/pyfr/backends/opencl/base.py
@@ -4,7 +4,6 @@ import numpy as np
from pyfr.backends.base import BaseBackend
from pyfr.mpiutil import get_local_rank
-from pyfr.template import DottedTemplateLookup
class OpenCLBackend(BaseBackend):
@@ -64,12 +63,6 @@ class OpenCLBackend(BaseBackend):
self.xchg_matrix_cls = types.OpenCLXchgMatrix
self.xchg_view_cls = types.OpenCLXchgView
- # Template lookup
- self.lookup = DottedTemplateLookup(
- 'pyfr.backends.opencl.kernels',
- fpdtype=self.fpdtype, alignb=self.alignb
- )
-
# Instantiate the base kernel providers
kprovs = [provider.OpenCLPointwiseKernelProvider,
blasext.OpenCLBlasExtKernels,
diff --git a/pyfr/backends/openmp/base.py b/pyfr/backends/openmp/base.py
index 945f6c2..a986dcd 100644
--- a/pyfr/backends/openmp/base.py
+++ b/pyfr/backends/openmp/base.py
@@ -3,7 +3,6 @@
import numpy as np
from pyfr.backends.base import BaseBackend
-from pyfr.template import DottedTemplateLookup
class OpenMPBackend(BaseBackend):
@@ -29,12 +28,6 @@ class OpenMPBackend(BaseBackend):
self.xchg_matrix_cls = types.OpenMPXchgMatrix
self.xchg_view_cls = types.OpenMPXchgView
- # Template lookup
- self.lookup = DottedTemplateLookup(
- 'pyfr.backends.openmp.kernels',
- fpdtype=self.fpdtype, alignb=self.alignb
- )
-
# Kernel provider classes
kprovcls = [provider.OpenMPPointwiseKernelProvider,
blasext.OpenMPBlasExtKernels,
diff --git a/pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako b/pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako
index a91053f..8a9aefb 100644
--- a/pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako
+++ b/pyfr/solvers/baseadvecdiff/kernels/shocksensor.mako
@@ -2,11 +2,6 @@
<%inherit file='base'/>
<%namespace module='pyfr.backends.base.makoutil' name='pyfr'/>
-<%
- import math
- pi = math.pi
-%>
-
<%pyfr:kernel name='shocksensor' ndim='1'
s='in fpdtype_t[${str(nupts)}]'
amu='out fpdtype_t'>
@@ -26,7 +21,7 @@
// Compute cell-wise artificial viscosity
fpdtype_t mu = (se < se0 - ${c['kappa']})
? 0.0
- : ${0.5*c['max-amu']}*(1.0 + sin(${0.5*pi/c['kappa']}*(se - se0)));
+ : ${0.5*c['max-amu']}*(1.0 + sin(${0.5*math.pi/c['kappa']}*(se - se0)));
mu = (se < se0 + ${c['kappa']}) ? mu : ${c['max-amu']};
amu = mu;
diff --git a/pyfr/template.py b/pyfr/template.py
index 546315f..ec7e88b 100644
--- a/pyfr/template.py
+++ b/pyfr/template.py
@@ -7,9 +7,9 @@ from mako.template import Template
class DottedTemplateLookup(TemplateLookup):
- def __init__(self, pkg, **kwargs):
+ def __init__(self, pkg, dfltargs):
self.dfltpkg = pkg
- self.dfltargs = kwargs
+ self.dfltargs = dfltargs
def adjust_uri(self, uri, relto):
return uri
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyfr.git
More information about the debian-science-commits
mailing list