upc_threadof() inconsistency?

From: Reinhold Bader (bader-reinhold_at_t-online.de)
Date: Sun Apr 11 2010 - 13:41:55 PDT

  • Next message: Paul H. Hargrove: "Re: upc_threadof() inconsistency?"
     Hello,
    
      the following program, built with the Berkeley UPC (2.8 or 2.10)
      installations on the sgi Altix (IA64) as well sgi ICE (Nehalem)
      systems ...
    
    
    #include <upc.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    
    shared [*] int a[THREADS][3];
    
    int main(void) {
      int i, j, q;
      for (i=0; i<3; i++) {
        a[MYTHREAD][i] = MYTHREAD;
      }
      upc_barrier;
      if (MYTHREAD == 0) {
        for (q=0; q<THREADS; q++) {
           j = upc_threadof(&a[q][2]);
           printf("a[%d][2] is on thread %d with value %d\n",q,
                   j,a[q][2]);
        }
    
      }
      return 0;
    }
    
    
    
      ... produces the following result.
    
    upcrun -n 8 ./symmetric_data.exe
    UPCR: UPC thread 1 of 8 on r1i2n2 (process 1 of 8, pid=5833)
    UPCR: UPC thread 2 of 8 on r1i2n2 (process 2 of 8, pid=5834)
    UPCR: UPC thread 3 of 8 on r1i2n2 (process 3 of 8, pid=5835)
    UPCR: UPC thread 4 of 8 on r1i2n2 (process 4 of 8, pid=5836)
    UPCR: UPC thread 5 of 8 on r1i2n2 (process 5 of 8, pid=5837)
    UPCR: UPC thread 6 of 8 on r1i2n2 (process 6 of 8, pid=5838)
    UPCR: UPC thread 7 of 8 on r1i2n2 (process 7 of 8, pid=5839)
    UPCR: UPC thread 0 of 8 on r1i2n2 (process 0 of 8, pid=5832)
    a[0][2] is on thread 2 with value 0
    a[1][2] is on thread 3 with value 1
    a[2][2] is on thread 4 with value 2
    a[3][2] is on thread 5 with value 3
    a[4][2] is on thread 6 with value 4
    a[5][2] is on thread 7 with value 5
    a[6][2] is on thread 0 with value 6
    a[7][2] is on thread 1 with value 7
    
    
       The value of upc_threadof() appears to be inconsistent with the
       MYTHREADS value. On the other hand, the available documentation
       repeatedly mentions constructions like
       if (upc_threadof(&data) == MYTHREADS) {
    
          ...
    
        }
       to ensure locality of reference. Any explanations or hints?
    
    Best Regards
    
    -- 
     Dr. Reinhold Bader
    
     Leibniz-Rechenzentrum, Abt. Hochleistungssysteme | Tel. +49 89 35831 8825
     Boltzmannstr. 1, 85748 Garching                  | Fax  +49 89 35831 9700
    

  • Next message: Paul H. Hargrove: "Re: upc_threadof() inconsistency?"