issue with smp on x86 32b platform

From: George Caragea (george_at_east_dot_isi_dot_edu)
Date: Wed Jul 23 2008 - 13:02:23 PDT

  • Next message: George Caragea: "implementing new GASNet conduit: gasnetc_bootstrapExchange"
    Hi all,
    
    I am using berkeley-upc-2.6.0 on an i686 Linux machine, with the online 
    translator. I am using the smp conduit, with pthreads (although I 
    disabled pthreads to pinpoint the problem).  I think I have encountered 
    a bug either with the translator or the run-time system.
    
    I am running the program below with one single thread (pthreads 
    disabled), but I cannot get the correct result. The program I am trying 
    to run is :
    
    --------------
    #include <upc_relaxed.h>
    #include <stdio.h>
    #include <upc.h>
    
    shared int *twiddle;
    //shared [1] int twiddle[2];
    
    int main(){
    
      twiddle = (shared int *) upc_all_alloc(1, 2*sizeof(int));
    
      int TID=0;
      int index = 1-TID;
    
      twiddle[TID]     = 1;
      twiddle[1-TID]   = 2;
      //twiddle[index]   = 2;
    
      if(MYTHREAD == 0) {
        int i;
        for(i=0;i<2;i++){
          printf("%d\n", twiddle[i]);
        }
        upc_free(twiddle);
      }
    }
    ---------------
    
    I am compiling and running this with:
    $ upcc -T 1 -pthreads=0 fft_1.upc -o fft_1
    $ upcrun fft_1
    
    However, instead of printing the values 1 and 2, I get some random 
    numbers in the array.
    
    The problem seems to come from the line twiddle[1-TID]=2. If I use 
    twiddle[index] instead, it works just fine. I think there is some 
    casting problem. Running upcc -v I get these warnings from the translator:
    
    !!!rearranging upc pointer arithmetic expression failed!!!
    [...]
    internal translator warning (from fft_1.upc:16): Attempt to directly 
    cast to upcr_{p}shared_ptr_t
    
    Am I doing something incorrect in the code? Note that when I compile and 
    run this on a x86_64 machine, it works fine. This makes me think there 
    is a problem with casting between 32b/64b pointers and values, which 
    seems to be the case when I look in the output of the translator. The 
    problem also happens when I use an array instead of upc_all_alloc().
    
    I am attaching my upcc --version output and the output of the translator 
    for reference.
    
    Thank you,
    George
    
    
    #include <upc_relaxed.h>
    #include <stdio.h>
    #include <upc.h>
    
    shared int *twiddle;
    //shared [1] int twiddle[2];
    
    int main(){
    
      twiddle = (shared int *) upc_all_alloc(1, 2*sizeof(int));
    
      int TID=0;
      int index = 1-TID;
    
      twiddle[TID]     = 1;
      twiddle[1-TID]   = 2;
      //twiddle[index]   = 2;
    
      if(MYTHREAD == 0) {
        int i;
        for(i=0;i<2;i++){
          printf("%d\n", twiddle[i]);
        }
        upc_free(twiddle);
      }
    }
    
    



  • Next message: George Caragea: "implementing new GASNet conduit: gasnetc_bootstrapExchange"