From: Reinhold Bader (Reinhold.Bader_at_lrz.de)
Date: Tue Apr 13 2010 - 05:45:11 PDT
Hello, trying out upc_all_alloc() to obtain a distributed object with the following program: #include <upc.h> #include <stdlib.h> #include <stdio.h> #define ASIZE 4 int main(void) { shared int *a; int i, j, q; a = (shared int *) upc_all_alloc(THREADS,ASIZE*sizeof(int)); for (i=0; i<ASIZE; i++) { a[MYTHREAD*ASIZE+i] = MYTHREAD; } upc_barrier; if (MYTHREAD == 0) { for (q=0; q<THREADS; q++) { for (i=0; i<ASIZE; i++) { j = upc_threadof(&a[q*ASIZE+i]); printf("a[%d][%d] is on thread %d with value %d\n",q,i,\ j,a[q*ASIZE+i]); } } } upc_barrier; upc_free(a); return 0; } I get the following output when running with 12 Threads: a[0][0] is on thread 0 with value 0 a[0][1] is on thread 1 with value 0 a[0][2] is on thread 2 with value 0 a[0][3] is on thread 3 with value 0 a[1][0] is on thread 4 with value 1 a[1][1] is on thread 5 with value 1 a[1][2] is on thread 6 with value 1 a[1][3] is on thread 7 with value 1 ... This seems to contradict the specification which says "The upc all alloc function allocates shared space compatible with the following declaration: shared [nbytes] char[nblocks * nbytes]." It appears the BUPC implementation performs shared [1] char[nblocks * nbytes] instead. Regards Reinhold