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

One more Thetis issue #73

Closed
tkarna opened this issue May 12, 2016 · 3 comments · Fixed by #72
Closed

One more Thetis issue #73

tkarna opened this issue May 12, 2016 · 3 comments · Fixed by #72

Comments

@tkarna
Copy link
Collaborator

tkarna commented May 12, 2016

Test

py.test test/tracerEq/test_v-diffusion_mes.py::test_vertical_diffusion[order-0-explicit] -v -s -x

results in

E                                   CompilationError: Command "['mpicc', '-std=c99', '-fPIC', '-Wall', '-march=native', '-O3', '-fno-ivopts', '-I/home/tuomas/sources/firedrake/local/lib/python2.7/site-packages/petsc/include', '-I/home/tuomas/sources/firedrake/src/PyOP2/pyop2', '-msse', '-o', '/home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.so.tmp', '/home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.c', '-shared', '-L/home/tuomas/sources/firedrake/local/lib/python2.7/site-packages/petsc/lib', '-Wl,-rpath,/home/tuomas/sources/firedrake/local/lib/python2.7/site-packages/petsc/lib', '-lpetsc', '-lm']" return error status 1.
E                                   Unable to compile code
E                                   Compile log in /home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.log
E                                   Compile errors in /home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.err

Compiler error log says

/home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.c:157:15: warning: unused variable ‘t53’ [-Wunused-variable]
       double  t53  = (t0[j] * t44 * t0[k+2] * 0.5 * t38);
               ^
/home/tuomas/temp/pyop2-cache/37209587b1f6d3bc6fa3cc551f1b990b_p19719.c:163:20: error: ‘t53’ undeclared (first use in this function)
       A00[j][k] += t53;
                    ^

so t53 seems to be in wrong scope. C code is


        #include <petsc.h>
        #include <stdbool.h>
        #include <math.h>





            #include <immintrin.h>



static inline void form00_interior_facet_horiz_integral_otherwise (double  A[6][6] , const double *restrict *restrict coords_ )
{
  double  A00[3][3]  = {0.0};
  double  A01[3][3]  = {0.0};
  double  A10[3][3]  = {0.0};
  double  A11[3][3]  = {0.0};
  double  coords[2][18] ;

  for (int  i  = 0; i < 6; i += 1)
  {
    coords[0][i] = coords_[i][0];

  }

  for (int  i  = 0; i < 6; i += 1)
  {
    coords[1][i] = coords_[i+6][0];

  }

  for (int  i  = 0; i < 6; i += 1)
  {
    coords[0][i+6] = coords_[i+12][0];

  }

  for (int  i  = 0; i < 6; i += 1)
  {
    coords[1][i+6] = coords_[i+18][0];

  }

  for (int  i  = 0; i < 6; i += 1)
  {
    coords[0][i+12] = coords_[i+24][0];
    coords[1][i+12] = coords_[i+30][0];

  }
  double  t28[3] ;
  static const double  t0[3]  = {0.0, 0.0, 1.0};
  double  t27  = 0.0;
  double  t26  = 0.0;
  double  t25  = 0.0;
  double  t24  = 0.0;
  double  t23  = 0.0;
  double  t22  = 0.0;
  double  t21  = 0.0;
  double  t20  = 0.0;
  double  t19  = 0.0;
  double  t18  = 0.0;
  static const double  t1[2][1][18]  = {{{-1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
  double  t17  = 0.0;
  static const double  t2[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
  double  t16  = 0.0;
  static const double  t3[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333}}};
  double  t15  = 0.0;
  static const double  t4[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
  double  t14  = 0.0;
  static const double  t5[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0}}};
  double  t13  = 0.0;
  static const double  t6[2][1][18]  = {{{-1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
  double  t12  = 0.0;
  static const double  t7[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0}}};
  double  t11  = 0.0;
  static const double  t8[2][1][18]  = {{{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -1.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};
  double  t10  = 0.0;
  static const double  t9[2][1][18]  = {{{-0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}, 
  {{-0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, -0.333333333333333, 0.333333333333333, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}};

  for (int  i_0  = 0; i_0 < 4; i_0 += 1)
  {
    t11 += t8[0][0][i_0+6] * coords[1][i_0+6];
    t12 += t7[0][0][i_0+12] * coords[1][i_0+12];
    t18 += t1[0][0][i_0] * coords[1][i_0];
    t22 += t1[1][0][i_0] * coords[0][i_0];
    t24 += t7[1][0][i_0+12] * coords[0][i_0+12];
    t27 += t8[1][0][i_0+6] * coords[0][i_0+6];

  }

  for (int  i_0  = 0; i_0 < 6; i_0 += 1)
  {
    t10 += t9[0][0][i_0] * coords[1][i_0];
    t13 += t6[0][0][i_0] * coords[1][i_0];
    t14 += t5[0][0][i_0+12] * coords[1][i_0+12];
    t15 += t4[0][0][i_0+6] * coords[1][i_0+6];
    t16 += t3[0][0][i_0+12] * coords[1][i_0+12];
    t17 += t2[0][0][i_0+6] * coords[1][i_0+6];
    t19 += t9[1][0][i_0] * coords[0][i_0];
    t20 += t4[1][0][i_0+6] * coords[0][i_0+6];
    t21 += t3[1][0][i_0+12] * coords[0][i_0+12];
    t23 += t6[1][0][i_0] * coords[0][i_0];
    t25 += t2[1][0][i_0+6] * coords[0][i_0+6];
    t26 += t5[1][0][i_0+12] * coords[0][i_0+12];

  }
  double  t29  = (1 * t27);
  double  t30  = (1 * t26);
  double  t31  = (1 * t25);
  double  t32  = (1 * t24);
  double  t33  = ((t29 * t30) + (-1 * t31 * t32));
  double  t34  = (1 * t23);
  double  t35  = (1 * t22);
  double  t36  = ((t34 * t32) + (-1 * t35 * t30));
  double  t37  = ((t35 * t31) + (-1 * t34 * t29));
  double  t38  = (0.5 * sqrt((t33 * t33) + (t36 * t36) + (t37 * t37)));
  double  t39  = ((t27 * t26) + (-1 * t25 * t24));
  double  t40  = ((t22 * ((t25 * t21) + (-1 * t20 * t26))) + (t23 * ((t20 * t24) + (-1 * t27 * t21))) + (t19 * t39));
  double  t41  = ((t39 / t40) * 1);
  double  t42  = ((((t23 * t24) + (-1 * t22 * t26)) / t40) * 1);
  double  t43  = ((((t22 * t25) + (-1 * t23 * t27)) / t40) * 1);
  double  t44  = (t43 / sqrt((t41 * t41) + (t42 * t42) + (t43 * t43)));
  double  t45  = ((t11 * t14) + (-1 * t17 * t12));
  double  t46  = ((t18 * ((t17 * t16) + (-1 * t15 * t14))) + (t13 * ((t15 * t12) + (-1 * t11 * t16))) + (t10 * t45));
  double  t47  = ((t45 / t46) * -1);
  double  t48  = ((((t13 * t12) + (-1 * t18 * t14)) / t46) * -1);
  double  t49  = ((((t18 * t17) + (-1 * t13 * t11)) / t46) * -1);
  double  t50  = (t49 / sqrt((t47 * t47) + (t48 * t48) + (t49 * t49)));
  double  k_3_0_0[3] ;
  double  k_4_0_0[3] ;

  for (int  k  = 0; k < 3; k += 1)
  {
    k_3_0_0[k] = 0.5 * t0[k];
    k_4_0_0[k] = k_3_0_0[k];

  }

  for (int  j  = 0; j < 3; j += 1)
  {
    double  j_3_0_0  = (t50 * t0[j]);
    double  j_4_0_0  = (t50 * t0[j]);

    for (int  k  = 0; k < 1; k += 1)
    {
      double  t53  = (t0[j] * t44 * t0[k+2] * 0.5 * t38);

    }

    for (int  k  = 0; k < 3; k += 1)
    {
      A00[j][k] += t53;
      A01[j][k] += t53;
      A10[j][k] += k_3_0_0[k] * j_3_0_0 * t38;
      A11[j][k] += j_4_0_0 * k_4_0_0[k] * t38;

    }

  }
  A[0][0] = A00[0][0];
  A[0][1] = A01[0][0];
  A[0][2] = A00[0][1];
  A[0][3] = A01[0][1];
  A[0][4] = A00[0][2];
  A[0][5] = A01[0][2];
  A[1][0] = A10[0][0];
  A[1][1] = A11[0][0];
  A[1][2] = A10[0][1];
  A[1][3] = A11[0][1];
  A[1][4] = A10[0][2];
  A[1][5] = A11[0][2];
  A[2][0] = A00[1][0];
  A[2][1] = A01[1][0];
  A[2][2] = A00[1][1];
  A[2][3] = A01[1][1];
  A[2][4] = A00[1][2];
  A[2][5] = A01[1][2];
  A[3][0] = A10[1][0];
  A[3][1] = A11[1][0];
  A[3][2] = A10[1][1];
  A[3][3] = A11[1][1];
  A[3][4] = A10[1][2];
  A[3][5] = A11[1][2];
  A[4][0] = A00[2][0];
  A[4][1] = A01[2][0];
  A[4][2] = A00[2][1];
  A[4][3] = A01[2][1];
  A[4][4] = A00[2][2];
  A[4][5] = A01[2][2];
  A[5][0] = A10[2][0];
  A[5][1] = A11[2][0];
  A[5][2] = A10[2][1];
  A[5][3] = A11[2][1];
  A[5][4] = A10[2][2];
  A[5][5] = A11[2][2];

}



        void wrap_form00_interior_facet_horiz_integral_otherwise(int start, int end,
                      Mat arg0_0_, int *arg0_0_map0_0, int *arg0_0_map1_0, double *arg1_0, int *arg1_0_map0_0
                      , int start_layer, int end_layer, int top_layer) {
  Mat arg0_0_0 = arg0_0_;
  int xtr_arg0_0_map0_0[2];
    int xtr_arg0_0_map1_0[2];
  double *arg1_0_vec[36];
  for ( int n = start; n < end; n++ ) {
    int i = n;
    arg1_0_vec[0] = arg1_0 + (arg1_0_map0_0[i * 6 + 0])* 3;
    arg1_0_vec[1] = arg1_0 + (arg1_0_map0_0[i * 6 + 1])* 3;
    arg1_0_vec[2] = arg1_0 + (arg1_0_map0_0[i * 6 + 2])* 3;
    arg1_0_vec[3] = arg1_0 + (arg1_0_map0_0[i * 6 + 3])* 3;
    arg1_0_vec[4] = arg1_0 + (arg1_0_map0_0[i * 6 + 4])* 3;
    arg1_0_vec[5] = arg1_0 + (arg1_0_map0_0[i * 6 + 5])* 3;
    arg1_0_vec[6] = arg1_0 + (arg1_0_map0_0[i * 6 + 0] + 1)* 3;
    arg1_0_vec[7] = arg1_0 + (arg1_0_map0_0[i * 6 + 1] + 1)* 3;
    arg1_0_vec[8] = arg1_0 + (arg1_0_map0_0[i * 6 + 2] + 1)* 3;
    arg1_0_vec[9] = arg1_0 + (arg1_0_map0_0[i * 6 + 3] + 1)* 3;
    arg1_0_vec[10] = arg1_0 + (arg1_0_map0_0[i * 6 + 4] + 1)* 3;
    arg1_0_vec[11] = arg1_0 + (arg1_0_map0_0[i * 6 + 5] + 1)* 3;
    arg1_0_vec[12] = arg1_0 + (arg1_0_map0_0[i * 6 + 0])* 3 + 1;
    arg1_0_vec[13] = arg1_0 + (arg1_0_map0_0[i * 6 + 1])* 3 + 1;
    arg1_0_vec[14] = arg1_0 + (arg1_0_map0_0[i * 6 + 2])* 3 + 1;
    arg1_0_vec[15] = arg1_0 + (arg1_0_map0_0[i * 6 + 3])* 3 + 1;
    arg1_0_vec[16] = arg1_0 + (arg1_0_map0_0[i * 6 + 4])* 3 + 1;
    arg1_0_vec[17] = arg1_0 + (arg1_0_map0_0[i * 6 + 5])* 3 + 1;
    arg1_0_vec[18] = arg1_0 + (arg1_0_map0_0[i * 6 + 0] + 1)* 3 + 1;
    arg1_0_vec[19] = arg1_0 + (arg1_0_map0_0[i * 6 + 1] + 1)* 3 + 1;
    arg1_0_vec[20] = arg1_0 + (arg1_0_map0_0[i * 6 + 2] + 1)* 3 + 1;
    arg1_0_vec[21] = arg1_0 + (arg1_0_map0_0[i * 6 + 3] + 1)* 3 + 1;
    arg1_0_vec[22] = arg1_0 + (arg1_0_map0_0[i * 6 + 4] + 1)* 3 + 1;
    arg1_0_vec[23] = arg1_0 + (arg1_0_map0_0[i * 6 + 5] + 1)* 3 + 1;
    arg1_0_vec[24] = arg1_0 + (arg1_0_map0_0[i * 6 + 0])* 3 + 2;
    arg1_0_vec[25] = arg1_0 + (arg1_0_map0_0[i * 6 + 1])* 3 + 2;
    arg1_0_vec[26] = arg1_0 + (arg1_0_map0_0[i * 6 + 2])* 3 + 2;
    arg1_0_vec[27] = arg1_0 + (arg1_0_map0_0[i * 6 + 3])* 3 + 2;
    arg1_0_vec[28] = arg1_0 + (arg1_0_map0_0[i * 6 + 4])* 3 + 2;
    arg1_0_vec[29] = arg1_0 + (arg1_0_map0_0[i * 6 + 5])* 3 + 2;
    arg1_0_vec[30] = arg1_0 + (arg1_0_map0_0[i * 6 + 0] + 1)* 3 + 2;
    arg1_0_vec[31] = arg1_0 + (arg1_0_map0_0[i * 6 + 1] + 1)* 3 + 2;
    arg1_0_vec[32] = arg1_0 + (arg1_0_map0_0[i * 6 + 2] + 1)* 3 + 2;
    arg1_0_vec[33] = arg1_0 + (arg1_0_map0_0[i * 6 + 3] + 1)* 3 + 2;
    arg1_0_vec[34] = arg1_0 + (arg1_0_map0_0[i * 6 + 4] + 1)* 3 + 2;
    arg1_0_vec[35] = arg1_0 + (arg1_0_map0_0[i * 6 + 5] + 1)* 3 + 2;
    xtr_arg0_0_map0_0[0] = *(arg0_0_map0_0 + i * 1 + 0);
          xtr_arg0_0_map0_0[1] = *(arg0_0_map0_0 + i * 1 + 0) + 1;
          xtr_arg0_0_map1_0[0] = *(arg0_0_map1_0 + i * 1 + 0);
          xtr_arg0_0_map1_0[1] = *(arg0_0_map1_0 + i * 1 + 0) + 1;
          for (int j_0 = start_layer; j_0 < end_layer; ++j_0){
    double buffer_arg0_0[6][6]  = {{0.0}};
    form00_interior_facet_horiz_integral_otherwise(buffer_arg0_0, arg1_0_vec);
                        double tmp_buffer_arg0_0[6][6] ;
                        for ( int j = 0; j < 2; j++ ) {
                           for ( int k = 0; k < 3; k++ ) {
                              for ( int l = 0; l < 2; l++ ) {
                                 for ( int m = 0; m < 3; m++ ) {
                                    tmp_buffer_arg0_0[3*j + k][3*l + m] = buffer_arg0_0[j + 2*k][l + 2*m];
                                 }
                              }
                           }
                        }
        MatSetValuesBlockedLocal(arg0_0_0, 2, xtr_arg0_0_map0_0,
                                                 2, xtr_arg0_0_map1_0,
                                                 (const PetscScalar *)tmp_buffer_arg0_0,
                                                 ADD_VALUES);;
    xtr_arg0_0_map0_0[0] += 1;
      xtr_arg0_0_map0_0[1] += 1;
      xtr_arg0_0_map1_0[0] += 1;
      xtr_arg0_0_map1_0[1] += 1;
      arg1_0_vec[0] += 1 * 3;
      arg1_0_vec[1] += 1 * 3;
      arg1_0_vec[2] += 1 * 3;
      arg1_0_vec[3] += 1 * 3;
      arg1_0_vec[4] += 1 * 3;
      arg1_0_vec[5] += 1 * 3;
      arg1_0_vec[6] += 1 * 3;
      arg1_0_vec[7] += 1 * 3;
      arg1_0_vec[8] += 1 * 3;
      arg1_0_vec[9] += 1 * 3;
      arg1_0_vec[10] += 1 * 3;
      arg1_0_vec[11] += 1 * 3;
      arg1_0_vec[12] += 1 * 3;
      arg1_0_vec[13] += 1 * 3;
      arg1_0_vec[14] += 1 * 3;
      arg1_0_vec[15] += 1 * 3;
      arg1_0_vec[16] += 1 * 3;
      arg1_0_vec[17] += 1 * 3;
      arg1_0_vec[18] += 1 * 3;
      arg1_0_vec[19] += 1 * 3;
      arg1_0_vec[20] += 1 * 3;
      arg1_0_vec[21] += 1 * 3;
      arg1_0_vec[22] += 1 * 3;
      arg1_0_vec[23] += 1 * 3;
      arg1_0_vec[24] += 1 * 3;
      arg1_0_vec[25] += 1 * 3;
      arg1_0_vec[26] += 1 * 3;
      arg1_0_vec[27] += 1 * 3;
      arg1_0_vec[28] += 1 * 3;
      arg1_0_vec[29] += 1 * 3;
      arg1_0_vec[30] += 1 * 3;
      arg1_0_vec[31] += 1 * 3;
      arg1_0_vec[32] += 1 * 3;
      arg1_0_vec[33] += 1 * 3;
      arg1_0_vec[34] += 1 * 3;
      arg1_0_vec[35] += 1 * 3;
    }
  }
}
@miklos1
Copy link
Contributor

miklos1 commented May 12, 2016

The same problem occurs with tests/regression/test_ip_viscosity.py in the Firedrake test suite with the COFFEE branch fix-thetis and the TSFC branch fix-coffee-glue.

@FabioLuporini
Copy link
Contributor

FabioLuporini commented May 12, 2016

Pushed a fix to fix-thetis. Please, try it and let me know. Running both firedrake and thetis tests at the moment

@tkarna
Copy link
Collaborator Author

tkarna commented May 12, 2016

All thetis tests appear to pass, so this looks good to me.

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

Successfully merging a pull request may close this issue.

3 participants