Skip to content

precompute parsing bugs in the command line tool #349

@Infinoid

Description

@Infinoid

Scheduling directives in the command line tool are parsed in a way that treats spaces as equivalent to commas. It uses std::stringstream, which splits the string up on whitespace, and it replaces parentheses and commas with spaces to enable that. This is not the biggest problem. Though it does mean that a lot of things are parsed the same way:

$ taco 'A(i,j) = B(i,j) * 5' -s='reorder(j,i)'
$ taco 'A(i,j) = B(i,j) * 5' -s='reorder(j i)'
$ taco 'A(i,j) = B(i,j) * 5' -s='reorder(j i'
$ taco 'A(i,j) = B(i,j) * 5' -s='reorder j i'
$ taco 'A(i,j) = B(i,j) * 5' -s='reorder(j)i'
$ taco 'A(i,j) = B(i,j) * 5' -s='reorder,j(i)'

However, the precompute directive needs more careful parsing. It takes an index expression as a parameter. If that index expression contains a space, it gets chopped in half and only the first half is parsed.

Example:

taco 'A(i,j) = B(i,j) * 5' -s='precompute(B(i,j)*5,j,j)'  > code.c
taco 'A(i,j) = B(i,j) * 5' -s='precompute(B(i, j)*5,j,j)' > code.c
terminate called after throwing an instance of 'taco::TacoException'
  what():  Error at /home/infinoid/workspace/taco/git/tools/taco.cpp:222 in operator():
 Index variable 'j)*5' not defined in statement forall(i, forall(j, A(i,j) = B(i,j) * 5))
Aborted

The first one worked. The second one failed. I had to fix it so that the error was reported properly. Previously the error was:

terminate called after throwing an instance of 'char const*'
Aborted

The parser needs to be smarter about splitting up parameter strings on the right boundaries. I am working on a patch for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions