Newsgroups: comp.parallel.pvm From: keith@crosslinkinc.com Subject: Re: Packing/Unpacking an array of int from a 2-D array Organization: Deja News - The Leader in Internet Discussion Date: Fri, 14 Aug 1998 17:23:33 GMT Message-ID: <6r1rql$ut1$1@nnrp1.dejanews.com> In article <6q2nb1$v07$1@nnrp1.dejanews.com>, sjalali@nortel.ca wrote: > Hello, > > I have a 2-D array i.e. an array of array of int's, and I > want to pack/send/unpack/ one of those arrays. My question is > should I use the stride of 1 or a stride of the last dimension? > > int (*Marry)[12]; > > Marry = new [arg1] [12]; > > blah...... > > pvm_initsend(...); > pvm_pkint( Marry[2], 12, 1 ); > pvm_send( destin_tid, TAG1 ); > > And in the recipient, > > pvm_trecv( ....., TAG1 ); > pvm_unpkint( DestArry[3], 12, 1 ); > > Above I have used the stride of 1. > > Does anybody think the stride should be 12? no, the stride should be 1 and not 12 if you want to sent all 12 elements for Marry[2]. the stride refers to the number of elements in the array to skip in between. nitem refers to the total number of elements to sent. if you set the stride to 12, you will get a seg fault because the pack function will try to index into non existant elements( Marry[2][11], Marry[2][23], Marry[2][35] and so on ). keith > I am assuming here that the 2-D array is stored in memory as: > > Marry[1] int1 int2 int3 int4 ..... int12 > Marry[2] int1 int2 int3 int4 ..... int12 > > ... and .. so ... on .... > > Marry[12] int1 int2 int3 int4 ..... int12 > > and I think I wanted to send all the 12 int's in Marry[2]. > > Thanks a lot, > > Susheel > > -----== Posted via Deja News, The Leader in Internet Discussion ==----- > http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum > -----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum