Since the library of standard mathematical functions doesn't support double precision, I decided to write my own function to perform an exponential. In doing so I get this error:
ERROR: Expected a object of type 'struct'
While processing <buffer>:103
In compiler at GetSubpart()[astsymbol.cpp:636]
Name() = <literal>
member_name = x
Aborting...
Problem with compiling basisFunc_computeBasisFunction.hlslERROR: Expected a object of type 'struct'
While processing <buffer>:160
In compiler at GetSubpart()[astsymbol.cpp:636]
Name() = <literal>
member_name = x
Aborting...
Problem with compiling basisFunc_computeBasisFunction_addr.hlsl
(ignore the line numbers on the left. All numbers variables are declared as double).
23 sum = 1.0;
24 exponent = val;
26 sum += exponent;
27 exponent*=exponent;
28 tmp = exponent / 2.0;
29 sum += tmp;
30 exponent*=exponent;
32 sum += exponent/6.0;
33 exponent*=exponent;
34 sum += exponent/24.0;
35 exponent*=exponent;
36 sum += exponent/120.0;
37 exponent*=exponent;
38 sum += exponent/720.0;
39 exponent*=exponent;
41 basis = sum;
Hi Rick,
There seems to be some issue with codegen while using double literals in an expression.
As a workaround you can declare your double literals before using them in an expression. e.g. change
sum += exponent/<literal>
to
double temp = <literal>;
sum += exponent/temp;
Ok, cool. Thanks!
Gaurav,
I tried your suggestion, but Brook+ appears to always put zero in for the literal regardless of what I set it to.
E.g.
kernel void(out val<>
{
double l0 = 2.0;
val = l0;
}
will return a stream of all zeros. Any suggestions? Also, is it a requirement that all variables be declared before any non-declarative operations/assignments take place?
That seems strange. Kernel code has to be C compliant.
Also, could you try error checking and errorLog on your outputs stream?
Call error() and errorLog() on your output stream and see if you get any information.
Originally posted by: gaurav.garg Also, could you try error checking and errorLog on your outputs stream?
Call error() and errorLog() on your output stream and see if you get any information.
No dice. I've commented everything out of my code except for basically
double l0 = 1.0;
output = l0;
I don't see any errors whatsoever. Assigning the output to an input stream does work, so I don't think my stream allocations are incorrect.
Originally posted by: Ceq To the question: "Also, is it a requirement that all variables be declared before any non-declarative operations/assignments take place?" You can call other kernels as helper functions sou you don't need to declare every temporal variable at the beginning of the first kernel. You also can use brackets to define a new scope inside the kernel, but the variables defined inside it would be inaccesible after its end, example: kernel void ker(float i<>, out float o<> { float t1 = 2.0f; float t2 = i * 3.0f; another_kernel(i, o); o = t1 + t2; { float t3 = 4.0f; o += 4.0f; } }
Well, an example of code that doesn't compile for me is:
kernel void(double in<>,out double output<>
{
double l0;
l0 = 1.0;
double test;
output = in;
}
I get basisFunc.br(17) : Error (parse error) before 'double'
double test;
^
***Unable to parse basisFunc.br
However, this does:
kernel void(double in<>,out double output<>
{
double l0;
double test;
l0 = 1.0;
output = in;
}
Did this solve the problem? I'm getting similar errors (compiling with Brook+ 1.3), and while defining variables for all my constants removed the compile error, it appears the calculations are no longer working. It worked fine with floats, but now double-type variables fail.