Question

I try to compile a code with many lines of Algebra in it. Basically, it is a brute force contraction of 2 tensors with 12 dimensions and variable mode size. However, the performance of the code is not an issue at the moment, since it does not even compile. The code itself is embedded in a larger framework written in C99, which tries to mimic C++ behaviour, i.e. it uses macros for substituting templates and many inline functions. Basically, this is what does not compile (I know it is not elegant, but the code is generated using Mathematica in order to get the tensor indices right. It will be optimized later on):

void __attribute__((optimize("O0"))) MP(dineutron_uddu)(double complex* result, double complex* VVV_, double complex* vMv_, unsigned int L, int tis){

    unsigned int lt=(unsigned int)nsites_dir[TUP];
    double complex (*vMv)[L][4][lt][L][4]= (double complex (*)[L][4][lt][L][4]) vMv_;
    double complex (*vvv)[L][nt][L]= (double complex (*)[L][nt][L]) VVV_;
    unsigned int nnodes3=nnodes_dir[XUP]*nnodes_dir[YUP]*nnodes_dir[ZUP];
    unsigned int mynode3=mynode_dir[XUP]+nnodes_dir[XUP]*(mynode_dir[YUP]+nnodes_dir[YUP]*mynode_dir[ZUP]);

    {
            unsigned int tf;
            for(tf=0; tf<lt; tf++){
                    int tfs= lt*mynode_dir[TUP]+tf;

                    unsigned int n0, n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11;
                    COMPLEX sum=0.;
                    unsigned int run=0;

                    for(n0=0; n0<L; n0++){
                            for(n1=0; n1<L; n1++){
                                    for(n2=0; n2<L; n2++){
                                            for(n3=0; n3<L; n3++){
                                                    for(n4=0; n4<L; n4++){
                                                            for(n5=0; n5<L; n5++){
                                                                    for(n6=0; n6<L; n6++){
                                                                            for(n7=0; n7<L; n7++){
                                                                                    for(n8=0; n8<L; n8++){
                                                                                            for(n9=0; n9<L; n9++){
                                                                                                    for(n10=0; n10<L; n10++){
                                                                                                            for(n11=0; n11<L; n11++){

                                                                                                                    if(run%nnodes3==mynode3){

                                                                                                                            sum += vvv[n0][n4][tfs][n8] * vvv[n1][n5][tfs][n9] * ~(vvv[n2][n6][tis][n10]) * ~(vvv[n3][n7][tis][n11]) * 

    (

     + 0.25 * vMv[0][n2][0][tf][n9][1] * vMv[0][n3][0][tf][n5][1] * vMv[0][n11][0][tf][n4][1] * vMv[0][n7][1][tf][n8][0] * vMv[0][n10][1][tf][n1][0] * vMv[0][n6][1][tf][n0][0]

.....

about 600 lines of code follow, wich are pretty much like the previous one, but for different combinations of indices. It cannot be simplified further algebraically. ....

then the loops close and that is it.

So basically, the code just contains complex additions and multiplications, using the C99 double complex datatype. The loop indices are not known at compile time. I specified the attribute O0 in order to turn of optimizations to check whether this causes trouble, but it still just hangs. My question is:

1) does any of you know what is going wrong here? 2) if not, how can I find out, i.e. print the actual line of code the compiler is working on, i.e. getting some kind of live-output of what the compiler does.

Thank you very much

Was it helpful?

Solution

  1. Can you split your function into several pieces and put each mini function into a separate file (translation unit)? I imagine GCC takes an exponentially long time in rearranging basic blocks

  2. Perhaps you can play with -fdump-... optionis?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top