Skip to content

Stride mismatch using fortran ordered (0,N) arrays #581

@nchristensen

Description

@nchristensen

In the below code, knl(queue, input=a_c) successfully executes with a C ordered argument of shape (0,2). Calling the same kernel with an F ordered argument of shape (0,2) raises the following error.

Traceback (most recent call last):
  File "/autofs/nccs-svm1_home1/njchris/Workspace/test_0_length_array.py", line 31, in <module>
    result2 = knl(queue, input=a_f)
  File "/autofs/nccs-svm1_home1/njchris/Workspace/loopy/loopy/translation_unit.py", line 347, in __call__
    return pex(*args, **kwargs)
  File "/autofs/nccs-svm1_home1/njchris/Workspace/loopy/loopy/target/pyopencl_execution.py", line 371, in __call__
    return translation_unit_info.invoker(
  File "/ccs/home/njchris/miniconda3/envs/dev/lib/python3.10/site-packages/pytools/py_codegen.py", line 150, in __call__
    return self.func(*args, **kwargs)
  File "<generated code for 'invoke_loopy_kernel_loopy_kernel'>", line 101, in invoke_loopy_kernel_loopy_kernel
TypeError: strides mismatch on argument 'input' (after removing unit length dims, got: (8,), expected: (8,))
import pyopencl as cl
import pyopencl.array as cla
import numpy as np
import loopy as lp

ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

a_c = cla.Array(queue, (0,2), np.float64, order='C')
a_f = cla.Array(queue, (0,2), np.float64, order='F')

print(a_c.shape)
print(a_c.strides)
print(a_f.shape)
print(a_f.strides)

knl = lp.make_kernel(

    "{ [i,j]: 0<=i<n and 0<=j<m }",

    """
    output[i,j] = sqrt(input[i,j])

    """)

print(knl)

# Succeeds
result = knl(queue, input=a_c)
print(result[1])

# Fails
result2 = knl(queue, input=a_f)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions