Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Enhancements on DSL #60

Open
wimrijnders opened this issue Jul 20, 2018 · 2 comments
Open

Feature Request: Enhancements on DSL #60

wimrijnders opened this issue Jul 20, 2018 · 2 comments

Comments

@wimrijnders
Copy link
Contributor

wimrijnders commented Jul 20, 2018

This are things I encountered during kernel development.

Operators

Given:

Int a;
Float b;
Float c;

... the following should work:

c = a+b;       // No operator for Int, Float combination
c = a*b;       // idem
a += 16;       // operator doesn't exist
c += b;        // operator doesn't exist
a = (b < 0);   // Can't assign result BoolExpr to Int

The first three have alternatives:

c = toFloat(a)+b;
c = toFloat(a)*b;
c = c + b;

...but I personally would truly appreciate it if the initial versions worked. I can sort of understand if you want to have explicit casts, but still.

Conversion of number values to DSL

I would appreciate the possibility to mix constants with DSL variables, for example:

 Int a = 1;
 Float b= 3.14f*radius;   // Also mix in expressions

Related, when using generator functions, it would be nice if a Float/Int can be initialized with a (C++) constant, just like with k.run():

void Generator(Int a, Float b, int c = 0, int d = 12.34f) { ... }
...
Generator(3, 2.78f);
Generator(valA, valB, 1, 24.68f);  // Also, pass in C++ values.

If that works like Where

I would like to see an If-operator that works like Where:

  Where (x > 10) x++; End

This works per vector element; if a given element satisfies the condition, the if-block is executed. Other elements are untouched.

Currently, Where only allows assignments and expressions. An If that works analogously, and which allows all statements, would be appreciated.

@wimrijnders
Copy link
Contributor Author

Increment operator not working as expected

Kernel code:

void kernel(Ptr<Int> result) {
  Int outIndex = 0;
  result[outIndex++] = 0;

  // This works, of course
  // result[outIndex] = 0;
  // outIndex++;
}

Results in compile error:

error: no match for ‘operator[]’ (operand types are ‘QPULib::Ptr<QPULib::Int>’ and ‘void’)
   result[outIndex++] = 0;
         ^

@wimrijnders
Copy link
Contributor Author

Question: What is the difference between Cond and BoolExpr?

When scanning their definition in the Library, they are practically identical. Can't they be combined?

I also encountered the following:

struct BoolExpr
{
  // Abstract syntax tree
  BExpr* bexpr;
  // Constructor
  BoolExpr(BExpr* b) { bexpr = b; }
  // Cast to Cond
  //operator Cond();     // <----- THIS commented out
};

This makes good sense to me and would nullify this question. Why is it commented out? Are there issues with it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant