12 Replies Latest reply on Apr 29, 2009 5:36 PM by gaurav.garg

    What is wrong with this code?

    karx11erx
      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.

        • What is wrong with this code?
          gaurav.garg

          As I said earlier (http://forums.amd.com/forum/messageview.cfm?catid=328&threadid=110350&enterthread=y&STARTPAGE=4), you must change your struct declaration from-

          typedef struct { double x, y; } XY;

          to-

          typedef struct { double x; double y; } XY;

          Also, you must change the name of tan and atan kernels, they are not yet supported, but they are reserve keyword.

          If you want to keep the output and temporary files, you can compile br files with -k flag.

            • What is wrong with this code?
              karx11erx

              Oops. Sorry, yes you did, and I had followed your advice. Wonder how that mistake could slip back in.

               

              Getting further now - tan is indeed an intrinsic function, and heh, the CAL compiler has apparently been built with antlr ... I know that kind of messages ...

                • What is wrong with this code?
                  karx11erx

                  Well, still doesn't work ... here's the fixed code:

                   

                  #define HALFPI    (double) 1.5707963267948966
                  #define FORTPI    (double) 0.78539816339744833
                  #define PI        (double) 3.14159265358979323846
                  #define SPI     (double) 3.14159265359
                  #define TWOPI    (double) 6.2831853071795864769
                  #define EPS        (double) 1.0e-12
                  #define HUGE    (double) 1.0e36

                  typedef struct {
                      double x;
                      double y;
                  } XY;

                  typedef struct {
                      double lam;
                      double 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 < (double) 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 == (double) 0.0) ? HUGE : (double) sin ((float) phi) / cosphi;
                  }


                  kernel double Atan (double phi<>
                  {
                      double phi2 = phi * phi;
                     
                  return (phi + (double) 0.43157974 * phi2 * phi) / ((double)1.0 + (double) 0.76443945 * phi2 + (double) 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 - (double) (double) 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 != (double) 0.0) && (fabs (fabs (phi_in) - PI > EPS)))
                      phi_out = Atan (one_es * (double) 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<nCoord>, y_in<nCoord>, x_temp<nCoord>, y_temp<nCoord>;
                      double lam_in<nCoord>, phi_in<nCoord>, lam_temp<nCoord>, phi_temp<nCoord>;

                  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);
                  }

                   

                  These are the error messages - totally cryptic to me. I might ofc examine the HLSL code, but I probably still wouldn't know what's wrong with my Brook+ code afterwards.

                  1>------ Build started: Project: proj, Configuration: Debug Win32 ------
                  1>Brook+ compilation
                  1>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:161
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:210
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:155
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:204
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:161
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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>ERROR: ASSERT(GetNumSlots() == 1) failed
                  1>While processing <buffer>:210
                  1>In compiler at ILRegister::WidenSwizzleTo()[ilregister.cpp:299]
                  1>  GetNumSlots() = 2
                  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 ==========

                   

                  Another problem is that Brook+ rejects my redefinition of tan, but demands a tan function to be defined before it gets called. So I get one error when I define tan myself, and another error if I don't. How am I supposed t call built-in functions, or functions from the math lib from Brook+ code then?

                    • What is wrong with this code?
                      gaurav.garg

                      Unfortunately, double datatype is not very well supported. Following sre some workarounds that you can use -

                      #define HALFPI    (double) 1.5707963267948966
                      #define FORTPI    (double) 0.78539816339744833
                      #define PI        (double) 3.14159265358979323846
                      #define SPI     (double) 3.14159265359
                      #define TWOPI    (double) 6.2831853071795864769
                      #define EPS        (double) 1.0e-12
                      #define HUGE    (double) 1.0e36

                      typedef struct {
                          double x;
                          double y;
                      } XY;

                      typedef struct {
                          double lam;
                          double 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 dabs (double d) // fabs is reserved keyword
                      {
                          if(d < 0.0) // ?: not supported for double
                          {
                              return -d;
                          }
                          else
                          {
                              return d;
                          }

                      }


                      kernel double adjlon (out double lon<>
                      {
                      if (dabs(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);

                          if(cosphi == 0.0)
                          {
                              return 0.0;
                          }
                          else
                          {
                              return (double) sin ((float) phi) / cosphi;
                          }

                      }


                      kernel double Atan (double phi<>
                      {
                          double phi2 = phi * phi;
                        
                      return (phi + (double) 0.43157974 * phi2 * phi) / ((double)1.0 + (double) 0.76443945 * phi2 + (double) 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 - (double) (double) 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 ((geoc != 0) && ((int)(dabs (dabs (phi_in) - PI > EPS)))) //&& not supported for double
                          phi_out = Atan (one_es * (double) 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);
                      }

                        • What is wrong with this code?
                          karx11erx

                          Thanks.

                          @ ATI:

                          It's a bloody joke that none of these issues are flagged by the Brook+ compiler (it particularly doesn't complain about fabs which I introduced because abs didn't work with the arguments I provided). Not complaining about invalid implicit type conversion but screwing up in the CAL compile step is another big fat stumbling stone for anybody new to Brook+/CAL.

                          Type cast boolean expressions to int and using "&&" on them isn't supported? Brook+ doesn't complain, I have done some shader programming with OpenGL and know that it's supported there.

                          Why is ?: not accepted for double in an expression like "return ((double) i < 0.0) ? 1.0 : 0.0"? The condition yields a boolean (integer) result, not a double one!

                          Brook+ and CAL look more and more like a beta to me and not like a 1.4.

                          I am using all kinds of standard C constructs and while Brook+ swallows them, the CAL compiler constantly goofs up because of stuff like that? WTF?

                            • What is wrong with this code?
                              gaurav.garg

                              abs actually work, it gives a warning that double intrinsic is not supported and hence it would be converted into float. Conversion into float should not be a problem with abs as denorms are any way not supported.

                                • What is wrong with this code?
                                  karx11erx

                                  gaurav,

                                  thank you for your help. How did you figure all this? I am by no means a novice programmer, but I wouldn't have known how to find out about such issues. I might have been able to eventually figure it from the HLSL code, but specifying -k to Brook+ didn't keep it from deleting these files after compile errors.

                                   

                                  The following code now compiles:

                                  #define HALFPI    (double) 1.5707963267948966
                                  #define FORTPI    (double) 0.78539816339744833
                                  #define PI        (double) 3.14159265358979323846
                                  #define SPI     (double) 3.14159265359
                                  #define TWOPI    (double) 6.2831853071795864769
                                  #define EPS        (double) 1.0e-12
                                  #define HUGE    (double) 1.0e36

                                  typedef struct {
                                      double x;
                                      double y;
                                  } XY;

                                  typedef struct {
                                      double lam;
                                      double 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 Dabs (double d)
                                  {
                                  if (d >= (double) 0.0)
                                      return d;
                                  return -d;
                                  }


                                  kernel double adjlon (out double lon<>
                                  {
                                  if (Dabs (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);
                                     
                                  if (cosphi == (double) 0.0)
                                      return HUGE;
                                  else
                                      return (double) sin ((float) phi) / cosphi;
                                  }


                                  kernel double Atan (double phi<>
                                  {
                                      double phi2 = phi * phi;
                                     
                                  return (phi + (double) 0.43157974 * phi2 * phi) / ((double)1.0 + (double) 0.76443945 * phi2 + (double) 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 - (double) (double) 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 ((geoc != 0) && (int) (Dabs (Dabs (phi_in) - PI) > EPS))
                                      phi_out = Atan (one_es * (double) 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<nCoord>, y_in<nCoord>, x_temp<nCoord>, y_temp<nCoord>;
                                      double lam_in<nCoord>, phi_in<nCoord>, lam_temp<nCoord>, phi_temp<nCoord>;

                                  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);
                                  }

                                   

                                  It sucks big time that you don't get useful diagnostic and error messages from Brook+ and CAL.

                                    • What is wrong with this code?
                                      gaurav.garg

                                      Are you sure you have specified -k in brcc command options? It keeps all the intermediate hlsl files.

                                      If you see an error like this -

                                      1>Brook+ compilation
                                      1>NOTICE: Parse error
                                      1>While processing :105 => line 105 of hlsl file mentioned below
                                      1>In compiler at zzerror()[parser.y:112]
                                      1>  message = syntax error => Error message, the message is usually not informative, so you have to do some trial and 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 => Problem in pj_merc_br_pj_inv_pre.hlsl file

                                      Now based on the error, you need to change your brook kernel.