Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Support inner-contiguous specialization selection

  • Loading branch information...
commit 94ddebde099334c37d4264ba4fe52e4d81a1e106 1 parent 6a6e9a7
@markflorisson authored
Showing with 25 additions and 4 deletions.
  1. +24 −3 Cython/Compiler/Vector.py
  2. +1 −1  Cython/minivect
View
27 Cython/Compiler/Vector.py
@@ -44,6 +44,7 @@ def map_type(self, type, wrap=False):
raise minierror.UnmappableTypeError(type)
class CythonSpecializerMixin(object):
+ is_partial_mapping = False
def visit_FunctionNode(self, node):
node = super(CythonSpecializerMixin, self).visit_FunctionNode(node)
@@ -70,6 +71,7 @@ def visit_FunctionNode(self, node):
return node
def visit_NodeWrapper(self, node):
+ self.is_partial_mapping = True
for op in node.operands:
op.variable = self.visit(op.variable)
return node
@@ -97,9 +99,10 @@ def visit_ErrorHandler(self, node):
def visit_FunctionNode(self, node):
result = super(CCodeGen, self).visit_FunctionNode(node)
- self.code.function_declarations.putln("__Pyx_RefNannyDeclarations")
- self.code.before_loop.putln(
- '__Pyx_RefNannySetupContext("%s", 1);' % node.mangled_name)
+ if self.specializer.is_partial_mapping:
+ self.code.function_declarations.putln("__Pyx_RefNannyDeclarations")
+ self.code.before_loop.putln(
+ '__Pyx_RefNannySetupContext("%s", 1);' % node.mangled_name)
def visit_NodeWrapper(self, node):
for operand in node.operands:
@@ -591,6 +594,21 @@ def _put_tiled_specialization(self, code, if_clause, mixed_contig):
if not mixed_contig:
code.putln("}")
+ return if_clause
+
+ def _put_inner_contig_specializations(self, code, if_clause, mixed_contig):
+ if not mixed_contig:
+ code.putln("%s (%s & __PYX_ARRAYS_ARE_INNER_CONTIG) {" %
+ (if_clause, self.array_layout.result()))
+ self.put_ordered_specializations(
+ code,
+ specializers.StridedCInnerContigSpecializer,
+ specializers.StridedFortranInnerContigSpecializer)
+ code.putln("}")
+ if_clause = "else if"
+
+ return if_clause
+
def _put_strided_specializations(self, code, if_clause, mixed_contig):
if mixed_contig:
return
@@ -615,6 +633,9 @@ def generate_result_code(self, code):
contig, mixed_contig)
if_clause = self._put_tiled_specialization(code, if_clause,
mixed_contig)
+ if self.target.type.ndim > 1:
+ if_clause = self._put_inner_contig_specializations(code, if_clause,
+ mixed_contig)
self._put_strided_specializations(code, if_clause, mixed_contig)
def contig_condition(self, specializer):
2  Cython/minivect
@@ -1 +1 @@
-Subproject commit c1d62728e1bc590a4ae4d66e0e7e761834a72355
+Subproject commit 37a5ca0196f89c388049efcee1fae6312c6ffa76
Please sign in to comment.
Something went wrong with that request. Please try again.