From: Dan Bonachea (bonachea_at_cs_dot_berkeley_dot_edu)
Date: Wed Jan 05 2005 - 12:38:42 PST
At 11:19 AM 1/5/2005, Venelin Mitov wrote: >Hello, >Can somebody explain me how exactly the >upc_memget, upc_memput and upc_memcpy functions work by specification and >implementation? I'm interested in what they do when the shared memory >block to copy from/to is not local to only one thread only. Are those >functions written in upc(can we see their code)? See the UPC spec for the complete formal spec. All three functions are specified with wording of the form: The upc_memcpy function treats the dst and src pointers as if they had type: shared [] char[n] This means the source and destination areas never "wrap" across threads - they are treated as a single contiguous block of memory with indefinite blocking factor. If you need to move data to/from a memory area with affinity to more than one thread, then you need several calls. Dan >THREADS = 2 >#define N (4*THREADS) > >shared[N/THREADS] int P[2][N]; >int begin = 0, end = 6; > >int* p = (int*)malloc((end-begin)*sizeof(int)); > if(p == NULL) > upc_global_exit(3); > > //upc_memget(p, &P[idx][begin], (end-begin)*sizeof(int)); > > for(i = 0; i < end - begin; i++) > p[i] = P[idx][begin+i]; > >When to apply a for cycle or a upc_mem* function? > >Regards, >Venelin Mitov