Skip to content

Instantly share code, notes, and snippets.

@kaushikcfd
Last active March 5, 2018 20:34
Show Gist options
  • Save kaushikcfd/39314c465c90b74b676097d5d7dc37bd to your computer and use it in GitHub Desktop.
Save kaushikcfd/39314c465c90b74b676097d5d7dc37bd to your computer and use it in GitHub Desktop.

Introduction

  • After the discussion with the Firedrake group on 8th Februray, we started working towards function calls on arrays in Loopy.
  • In order to tackle the generalized problem we are working towards calling kernels from kernels within Loopy, so that the intended operation on arrays could be packed in a separate callee kernel.
  • WIP Merge Request: https://gitlab.tiker.net/inducer/loopy/merge_requests/232

The expected behavior is:

callee_knl = lp.make_kernel(
    "{i, j}: 0<=i, j<16",
    "b[i, j]=sin(a[i, j])")

caller_knl = lp.make_kernel(
    "{k, l, m, i0, j0, i1, j1}: 0<=i0, j0, i1, j1, k, l, m <16",
    "[i0, j0]: z[k, i0, j0, l, m] = transformed_sin([i1, j1]: x[l, i1, k, j1, m])")

# apply transformations to callee_knl in order to expect optimized behavior

knl = lp.register_callable_knl(caller_knl, 'transformed_sin', callee_knl)

Work done:

  • Syntax handling. (needs to add support for slices, which would be a preprocessing step in order to convert to the above form in the kernel)
  • Stride alignment: Sending the intended data chunk to the callee.
  • Type inference: Reading the type from the caller kernel. Throws an exception if type associtation couldn't be handled
  • Code Generation. Handles "easy" cases, need to be more sophisticated.(address in point 2 of the next section)

Currently working on:

  • Improving the function mangling interface in Loopy, so that we could have a generalized mangler-like interface which would be an umbrella interface for all function calls in Loopy, thereby including the kernel calls.
  • Better association between the caller and callee during the handling of concurrent iname tags.
  • Expected to be completed by the next meet of TransformFEM.

With this done, we expect Loopy to have good interface with function calls on arrays which could be used for library calls such as MatSetValues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment