Re: program freezing

From: Dan Bonachea (bonachea_at_cs_dot_berkeley_dot_edu)
Date: Thu Dec 08 2005 - 10:23:47 PST

  • Next message: Eric Frederich: "Re: program freezing"
    Hi Eric -
    
    It appears that your program has exposed a bug in our UPC translator, which is 
    causing the incorrect behavior. Specifically, your application of the ABS() 
    macro to a shared array element is causing the translator to generate 
    incorrect code.
    
    I've submitted the problem to our bug database, and someone should look into 
    it shortly - you can track the status here:
    http://upc-bugs.lbl.gov/bugzilla/show_bug.cgi?id=1352
    
    Apologies for the confusion and inconvenience. In the meantime, the patch to 
    your program shown below provides a workaround.
    
    Incidentally, this is probably the way you should write the code anyhow, 
    because it implies fewer communication operations, at least in a naive 
    translation. By reading the (potentially remote) array element into the tmp 
    before operating on it, you guarantee there will be at most one (get) 
    communication operation for that statement. Applying the macro directly to a 
    remote array element (eg ABS(a[j][i])) expands to something like (a[j][i] < 0 
    ? -(a[j][i]) : (a[j][i])), which naively implies two get communication 
    operations unless the optimizer is smart enough to remove one.
    
    Hope this helps...
    Dan
    
    --- matrixSolver-orig.upc       2005-12-08 10:12:40.000000000 -0800
    +++ matrixSolver.upc    2005-12-08 10:13:50.000000000 -0800
    @@ -71,10 +71,12 @@
      //                printf("a[%d][%d] : %f\n",maxrow,i,a[maxrow][i]); 
    fflush(stdout);
      //                printf("ABS(a[%d][%d]) : %f\n",j,i,ABS(a[j][i])); 
    fflush(stdout);
      //                printf("ABS(a[%d][%d]) : 
    %f\n",maxrow,i,ABS(a[maxrow][i])); fflush(stdout);
    -                tmpa = ABS(a[j][i]);
    -                tmpb = ABS(a[maxrow][i]);
    +                tmpa = a[j][i];
    +                tmpb = a[maxrow][i];
    +                tmpa = ABS(tmpa);
    +                tmpb = ABS(tmpb);
      //                printf("tmpa : %f\ntmpb : %f\n",tmpa,tmpb); 
    fflush(stdout);
    -                if (ABS(a[j][i]) > ABS(a[maxrow][i])){
    +                if (tmpa > tmpb){
      //                    printf("Seting maxrow to %d\n",maxrow);
                          maxrow = j;
                      }
    
    
    At 02:47 PM 12/7/2005, Eric Frederich wrote:
    >Hello,
    >I'd like to share something that has been troubling me.
    >
    >Attached I have two files.  One is the program, the other is the input to the 
    >program.
    >
    >I compiled the program with
    >
    >./upcc -pthreads -o matrixSolver -T=2 matrixSolver.upc
    >
    >and run the program like
    >
    >./upcrun -n 2 -c 2 -p 2 matrixSolver <http://matrix.500.in>matrix.500.in
    >
    >As the program is attached it freezes on me at the following point in the 
    >code.
    >if (ABS(a[j][i]) > ABS(a[maxrow][i]))
    >
    >I take the two operands of this inequality and store them in local variables 
    >tmpa and tmpb.
    >If you use these variables for the inequality (like if(tmpa > tmpb) ) the 
    >program runs fine and solves the matrix.
    >
    >This confuses me greatly since the macro ABS still works since I am using it 
    >when storing the variables in tmpa and tmpb.
    >
    >the ABS macro is defined as follows...
    >
    >#define ABS(x) (x < 0 ? -(x) : (x))
    >
    >Any ideas anyone?
    >
    >Also, I hope that I am accomplishing what I wanted to do.  I want to 
    >distribute the rows of the matrix in a round robin fashion.
    >I haven't got to dynamic memory allocation with UPC yet so I defined the 
    >array as follows.
    >
    >shared[1001] double a[1000][1001];
    >
    >By doing this is affinity of a[0][0] through a[0][1001] going to the first 
    >thread,
    >and the affinity of a[1][0] through a[1][1001] going to the next thread,
    >and the affinity of a[2][0] through a[2][1001] to the next, and so on?
    >
    >This is a square matrix with an extra column to store the one dimensional 
    >vector.
    >
    >
    >
    >Thanks ahead of time,
    >------------------------
    >Eric L. Frederich
    >
    >#Attachment Converted: "c:\program 
    >files\eudora\data\imap\dominant\inbox\attach\matrixSolver.upc"
    >
    >#Attachment Converted: "c:\program 
    >files\eudora\data\imap\dominant\inbox\attach\Makefile.in"
    

  • Next message: Eric Frederich: "Re: program freezing"