Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
The Python sum function may return a float64 array even if the argume…
Browse files Browse the repository at this point in the history
…nts are float32, so we need to force the result's dtype.

Adding more explicit error messages.
  • Loading branch information
peter17 committed Nov 22, 2013
1 parent e08c7e0 commit 9b74b8b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hedge/backends/cuda/diff_shared_fld.py
Expand Up @@ -194,7 +194,7 @@ def __call__(self, op_class, field):

block, func = self.get_kernel(op_class, elgroup)

assert field.dtype == given.float_type
assert field.dtype == given.float_type, "Wrong types: %s: %s, %s: %s" % (field, field.dtype, given, given.float_type)

use_debugbuf = set(["cuda_diff", "cuda_debugbuf"]) <= discr.debug
if use_debugbuf:
Expand Down
4 changes: 2 additions & 2 deletions hedge/backends/cuda/fluxgather.py
Expand Up @@ -283,7 +283,7 @@ def make_kernel(self, discr, executor, fluxes):



def make_plan(discr, eg, given, tune_for, dofs_per_face, quadrature_tag,
def make_plan(discr, eg, given, tune_for, dofs_per_face, quadrature_tag,
given_mbs_per_block=None):
from hedge.backends.cuda.execute import Executor
if tune_for is not None:
Expand Down Expand Up @@ -466,7 +466,7 @@ def __call__(self, eval_dependency, lift_plan):
else:
dep_field = discr.volume_zeros()

assert dep_field.dtype == given.float_type
assert dep_field.dtype == given.float_type, "Wrong types: %s: %s, %s: %s" % (dep_expr, dep_field.dtype, given, given.float_type)
dep_field.bind_to_texref_ext(texref_map[dep_expr],
allow_double_hack=True)

Expand Down
4 changes: 2 additions & 2 deletions hedge/vector_primitives.py
Expand Up @@ -49,10 +49,10 @@ def __call__(self, *args):

class UnoptimizedLinearCombiner(object):
def __init__(self, result_dtype, scalar_dtype):
self.result_type = result_dtype.type
self.result_dtype = result_dtype

def __call__(self, *args):
return sum(vec*self.result_type(fac) for fac, vec in args)
return sum(vec*self.result_dtype.type(fac) for fac, vec in args).astype(self.result_dtype)


class NumpyLinearCombiner(object):
Expand Down

0 comments on commit 9b74b8b

Please sign in to comment.