karx11erx

What is wrong with this code?

Discussion created by karx11erx on Apr 27, 2009
Latest reply on Apr 29, 2009 by gaurav.garg
Brook+ compile works, CAL compile fails

The following code looks valid to me, but the Brook+ compiler flags errors for it and deletes all output files:

#define HALFPI    1.5707963267948966
#define FORTPI    0.78539816339744833
#define PI        3.14159265358979323846
#define SPI     3.14159265359
#define TWOPI    6.2831853071795864769
#define EPS        1.0e-12
#define HUGE    1.0e308

typedef struct { double x, y; } XY;
typedef struct { double lam, phi; } LP;

typedef struct {
    int over;  
    int geoc;  
        int is_latlong; 
          int is_geocent;
    double a;
        double a_orig;
    double es;
        double es_orig;
    double e;
    double ra;
    double one_es;
    double rone_es;
    double lam0;
    double phi0;
    double x0;
    double y0;
    double k0;
    double to_meter;
    double fr_meter;
    int datum_type;
        double datum_params[7];
        double from_greenwich;
        double long_wrap_center;
    } PJ;   


kernel double fabs (double d)
{
return (d < 0.0) ? -d : d;
}


kernel double adjlon (out double lon<> )
{
if (fabs (lon) > SPI) {
    lon += PI;
    lon -= TWOPI * (double) floor ((float) (lon / TWOPI));
    lon -= PI;
    }
return lon;
}


kernel double tan (double phi<> )
{
    double cosphi = (double) cos ((float) phi);
   
return (cosphi == 0.0) ? HUGE : (double) sin ((float) phi) / cosphi;
}


kernel double atan (double phi<> )
{
    double phi2 = phi * phi;
   
return (phi + 0.43157974 * phi2 * phi) / (1.0 + 0.76443945 * phi2 + 0.05831938 * phi2 * phi2);
}


kernel void pj_inv_pre (double x_in<>, double y_in<>, out double x_out<>, out double y_out<>, double to_meter, double x0, double y0, double ra)
{
x_out = (x_in * to_meter - x0) * ra; 
y_out = (y_in * to_meter - y0) * ra;
}


kernel void merc_s_inverse (double x<>, double y<>, out double lam<>, out double phi<>, double k0)
{
phi = HALFPI - 2.0 * atan ((double) exp ((float) (-y / k0)));
lam = x / k0;
}


kernel void pj_inv_post (double lam_in<>, double phi_in<>, out double lam_out<>, out double phi_out<>, double lam0, double one_es, int geoc, int over)
{
lam_out = lam_in + lam0;
if (!over)
    lam_out = adjlon (lam_out);
if (((double) geoc != 0.0) && (fabs (fabs (phi_in) - PI > EPS)))
    phi_out = atan (one_es * tan (phi_in));
else
    phi_out = phi_in;
}


void pj_inv_par (PJ* P, double x[], double y[], double lam[], double phi[], int nCoord)
{
    double x_in , y_in, x_temp , y_temp ;
    double lam_in , phi_in, lam_temp , phi_temp ;

streamRead (x_in, x);
streamRead (y_in, y);
pj_inv_pre (x_in, y_in, x_temp, y_temp, P->to_meter, P->x0, P->y0, P->ra);
merc_s_inverse (x_temp, y_temp, lam_temp, phi_temp, P->k0);
pj_inv_post (lam_temp, phi_temp, lam_out, phi_out, P->lam0, P->one_es, P->geoc, P->over);
streamWrite (lam, lam_out);
streamWrite (phi, phi_out);
}

 

1>------ Build started: Project: proj, Configuration: Debug Win32 ------
1>Brook+ compilation
1>NOTICE: Parse error
1>While processing :105
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>While processing :105
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ","
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_pj_inv_pre.hlsl
1>Error--:cal back end failed to compile kernel "pj_inv_pre"
1>NOTICE: Parse error
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ";"
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_pj_inv_pre_addr.hlsl
1>Error--:cal back end failed to compile kernel "pj_inv_pre"
1>NOTICE: Parse error
1>While processing :105
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>While processing :105
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ","
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_merc_s_inverse.hlsl
1>Error--:cal back end failed to compile kernel "merc_s_inverse"
1>NOTICE: Parse error
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ";"
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_merc_s_inverse_addr.hlsl
1>Error--:cal back end failed to compile kernel "merc_s_inverse"
1>NOTICE: Parse error
1>While processing :105
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>While processing :105
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ","
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_pj_inv_post.hlsl
1>Error--:cal back end failed to compile kernel "pj_inv_post"
1>NOTICE: Parse error
1>In compiler at zzerror()[parser.y:112]
1>  message = syntax error
1>ERROR: Parse error. Expected declaration.
1>In compiler at zzparse()[parser.y:198]
1>  (yyvsp[0]) = ";"
1>Aborting...
1>Problem with compiling d:\projects\proj-4.6.1\src\pj_merc_br_pj_inv_post_addr.hlsl
1>Error--:cal back end failed to compile kernel "pj_inv_post"
1>deleting file : d:\projects\proj-4.6.1\src\pj_merc_br.cpp
1>deleting file : d:\projects\proj-4.6.1\src\pj_merc_br.h
1>deleting file : d:\projects\proj-4.6.1\src\pj_merc_br_gpu.h
1>***Code generation found errors
1>Project : error PRJ0019: A tool returned an error code from "Brook+ compilation"
1>Build log was saved at "file://d:\projects\proj-4.6.1\VisualC\Debug\BuildLog.htm"
1>proj - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

It doesn't play a role whether I am using double or float in the code (tried both). Catalyst 9.4, HD 4870 1 GB, WinXP SP 3 32 bit.

Outcomes