Skip to content

Instantly share code, notes, and snippets.

@kaushikcfd
Last active January 7, 2018 23:29
Show Gist options
  • Save kaushikcfd/ea719de97690494dd224767609441eb8 to your computer and use it in GitHub Desktop.
Save kaushikcfd/ea719de97690494dd224767609441eb8 to your computer and use it in GitHub Desktop.

Making the Kernel

knl = lp.make_kernel(
        "{ [i, j, k, k1]: 0<=i, j, k, k1<256 }",
        """
        temp_cnst[k] = 2.0 {id=insn_1}
        temp_cnst_2[k1] = 2*temp_cnst[k1] {id=insn_4}
        c[i, j] = reduce(sum, k, a[i,k]*b[k,j]*temp_cnst_2[k]) {id=insn_2}
        c[i, j] = reduce(sum, k1, a[i,k1]*b[k1,j]*temp_cnst_2[k1]) {id=insn_3}
        """)

Code to resolve it

processed_knl = lp.preprocess.preprocess_kernel(knl)
fixed_knl = processed_knl.copy()
while not lp.has_schedulable_iname_nesting(fixed_knl):
    iname, insn = next(lp.get_iname_duplication_options(fixed_knl))
    fixed_knl = lp.duplicate_inames(fixed_knl, iname, insn)
print('After all this duplication business, we have'
      ' has_schedulable_iname_nesting =',
      lp.has_schedulable_iname_nesting(fixed_knl))
knl = fixed_knl

Error

I am receiving the error message: ERROR: Sorry--loo.py did not find a schedule for your kernel..

Slight difference between this(i.e. smaller example kernel) and the mixed problem kernel

In the case of the smaller kernel the lp.has_schedulable_iname_nesting directly returns True hence it does not enter the while loop. But in mixed kernel case, after doing some duplications it succesfully enters and exits the while loop and still gives out the same scheduling error and performing some iname_duplication transformations.

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