To the rest of the list, I am sorry for this being continued on the list
when it is not LAM specific. I tried to respond to the original poster
off-list and offer assistance, but it came back to the list anyway. I
am responding one final time just so those on the list can see that I
think this has been resolved.
Marcelo,
As I said before. This is not LAM specific and really should have been
taken to usenet or at least off-list. I offered to assist off-list, but
you brought it back to the list. I don't really understand why you did
this after my offer. This tempted me to move onto other things, but I
decided to look at your code. As I suspected, it is a simple, yet
subtle error.
You are passing &num to Iprobe rather that &flag. Change &num to &flag
and your code will work.
Dave.
Marcelo Fukushima wrote:
> i must apoligize first cuz my english sux yeah i know... and maybe
> thats why i cant seen to make you guys understand...
> ill paste the source code here... but this is only my test program...
> what im really trying to do is to check if theres any message sent to
> a node (in the test case, the node 1), and if there is, process that
> message...if not, try again...
> now heres the small test program:
>
> #include <stdio.h>
> #include <mpi.h>
> #include <unistd.h>
>
> #define TAG 1001
>
> int main(int argc, char* argv[]) {
> MPI_Request req;
> MPI_Status status;
> int size, rank;
> int num, flag;
> int i, errCode;
> MPI_Init(&argc, &argv);
> MPI_Comm_rank(MPI_COMM_WORLD, &rank);
> MPI_Comm_size(MPI_COMM_WORLD, &size);
>
> printf ("starting waiting....\n");
>
> if (rank == 1) {
> flag = 0;
> while (!flag){
> sleep(1);
> errCode = MPI_Iprobe (MPI_ANY_SOURCE, MPI_ANY_TAG,
> MPI_COMM_WORLD, &num,&status) ;
> if (errCode != MPI_SUCCESS) {
> switch (errCode) {
> case MPI_ERR_COMM:
> printf ("comm error\n");
> break;
> case MPI_ERR_TAG:
> printf ("TAG ERR\n");
> break;
> case MPI_ERR_RANK:
> printf ("rank \n");
> break;
> }
> }
> }
> printf ("New message! receiving....\n");
> errCode = MPI_Recv (&num, 1, MPI_INT, MPI_ANY_SOURCE,
> MPI_ANY_TAG, MPI_COMM_WORLD, &status);
> if (errCode != MPI_SUCCESS) {
> switch (errCode) {
> case MPI_ERR_COMM:
> printf ("comm error\n");
> break;
> case MPI_ERR_TAG:
> printf ("TAG ERR\n");
> break;
> case MPI_ERR_RANK:
> printf ("rank \n");
> break;
> }
> }
>
> printf ("Received: %d\n", num);
> }
> else if (rank == 0) {
> num= 123;
> scanf ("%d", &num);
> errCode = MPI_Send (&num, 1, MPI_INT, 1,TAG, MPI_COMM_WORLD);
> if (errCode != MPI_SUCCESS) {
> switch (errCode) {
> case MPI_ERR_COMM:
> printf ("comm error\n");
> break;
> case MPI_ERR_TAG:
> printf ("TAG ERR\n");
> break;
> case MPI_ERR_RANK:
> printf ("rank \n");
> break;
> }
> }
> printf ("Sent! \n");
> }
> printf ("%d is saying bye...\n", rank);
> MPI_Finalize();
> return 0;
> }
>
> its now using the iprobe to check for messages... i also tried the
> irecv but the result is the same: it never receives a msg... is there
> anything wrong with my code? am i using probe correctly? is there any
> other way to do the same (wich is to preemptively receive a msg)?
> i hope i could make myself clear now.. im not good with words guys and
> for that i apologize...
>
> ty in advance...
>
>
> On 7/5/05, Jeff Squyres <jsquyres_at_[hidden]> wrote:
>
>>No, I think David perfectly understood your problem (I assume you meant
>>"Iprobe" or "Irecv" -- there is no MPI function call named "Ipost").
>>
>>If the value of TAG does not match on the sender and the receiver, you
>>will see "lock up" behavior because the receive (or probe or whatever
>>you are using) will not match, and therefore it will not complete.
>>Note, however, that you only showed code for the Irecv case (BTW, when
>>you immediately follow Irecv with Wait, it's pretty much exactly like
>>calling Recv -- you're not gaining any of the benefits of non-blocking
>>communication). You mentioned that you changed your code to poll over
>>(assumedly) Iprobe. Make sure that you're not calling Irecv in this
>>loop -- that you're only looping on the flag value from Iprobe (and
>>ensuring that the tag is the same between the sender and receiver).
>>
>>You might want to take a quick MPI tutorial to get more familiar with
>>these kinds of issues. There's a good one at
>>http://webct.ncsa.uiuc.edu:8900/public/MPI/, for example. I also wrote
>>a magazine column about MPI for a while; back-issues, with lots of
>>background information on MPI (including one issue where I give my
>>opinion about why the probe functions are evil), can be found at
>>http://cw.squyres.com/.
>>
>>
>>On Jul 4, 2005, at 5:15 PM, Marcelo Fukushima wrote:
>>
>>
>>>i think your not getting my problem.. ill try to explain myself better:
>>>the MPI_Ipost is not working the way its suppose to... for instance,
>>>in my example, i send n1 a msg from n0 (input by stdin)... while n1
>>>keep pooling the msg buffer (by probing it, nonblocking) until it says
>>>n1 got a message to receive... them, he receives, print it and
>>>exits....
>>>what is happening right now is the probe never returns TRUE (i mean
>>>its flag, not the return itself wich is always MPI_SUCCESS), even
>>>tough i use the blocking send on the n0 (and this blocking send goes
>>>normally as well)... so, the real question comes now: am i using probe
>>>correctly? i also tried pooling with the unsync receive, but the
>>>result is the same...
>>>
>>>ty in advance...
>>>
>>>On 7/4/05, David Cronk <cronk_at_[hidden]> wrote:
>>>
>>>>This really doesn't seem like a LAM specific situation, so I am
>>>>reluctant to
>>>>continue in this forum. The usenet group comp.parallel.mpi is a good
>>>>source
>>>>for general MPI questions.
>>>>
>>>>The only other thing I see right now is I don't see where TAG is
>>>>defined.
>>>>Make sure TAG has the same value for both sender and receiver.
>>>>
>>>>Dave.
>>>>
>>>>
>>>>Marcelo Fukushima wrote:
>>>>ok ty didnt realise that... but it aint working still...
>>>
>>>On 7/4/05, David
>>>
>>>>Cronk <cronk_at_[hidden]> wrote:
>>>
>>>>You are sending from rank 0 to rank 0. You need to send to rank
>>>>1.
>>>
>>>Dave.
>>>
>>>Marcelo Fukushima wrote:
>>>
>>>
>>>
>>>>hello guys!!! another noobish question...
>>>
>>>im trying the simplest of all
>>>
>>>>non-blocking routine and it simply locks up...
>>>
>>>int main(int argc, char*
>>>
>>>>argv[]) {
>>>
>>> MPI_Request req;
>>> MPI_Status status;
>>> int size, rank;
>>> int num,
>>>
>>>>flag;
>>>
>>> int i;
>>> MPI_Init(&argc, &argv);
>>> MPI_Comm_rank(MPI_COMM_WORLD,
>>>
>>>>&rank);
>>>
>>> MPI_Comm_size(MPI_COMM_WORLD, &size);
>>>
>>> printf ("starting
>>>
>>>>waiting....\n");
>>>
>>> if (rank == 1) {
>>> //MPI_Irecv (&num, 1, MPI_INT,
>>>
>>>>MPI_ANY_SOURCE, TAG,MPI_COMM_WORLD, &req);
>>>
>>> //flag = 0;
>>> //while (!flag){
>>>
>>>>MPI_Irecv (&num, 1, MPI_INT, MPI_ANY_SOURCE, TAG,MPI_COMM_WORLD,
>>>>&req);
>>>>MPI_Wait (&req, &status);
>>>
>>> printf ("Received: %d\n", num);
>>> }
>>> else if (rank
>>>
>>>>== 0) {
>>>
>>> num= 123;
>>> scanf ("%d", &num);
>>> printf ("Sending %d\n", num);
>>>
>>>>MPI_Send (&num, 1, MPI_INT, 0,TAG, MPI_COMM_WORLD);
>>>
>>> }
>>> printf ("%d is
>>>
>>>>saying bye...\n", rank);
>>>
>>> MPI_Finalize();
>>> return
>>>
>>>>0;
>>>
>>>---------------------------
>>>bottom line is: im posting a receive without
>>>
>>>>the sender has sent the
>>>
>>>msg and it stucks... i also tried pooling the
>>>
>>>>receive post with the
>>>
>>>MPI_Test and also locks (the request never turn into a
>>>
>>>>completed
>>>
>>>one)... so, in more general words, what i want to do is a
>>>
>>>>"preemptive"
>>>
>>>check if there was any msg sent to this node... is there a way?
>>>
>>>>cuz i
>>>
>>>didnt find on the tutorials.... ty in advance
>>>
>>>
>>>
>>>
>>>
>>>
>>>>_______________________________________________
>>>
>>>This list
>>>
>>>>is archived at http://www.lam-mpi.org/MailArchives/lam/
>>>
>>>
>>>>
>>>>_______________________________________________
>>>>This list is archived at
>>>>http://www.lam-mpi.org/MailArchives/lam/
>>>>
>>>>
>>>
>>>
>>>--
>>>[]'s
>>>Marcelo Takeshi Fukushima
>>>
>>>_______________________________________________
>>>This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>>>
>>
>>--
>>{+} Jeff Squyres
>>{+} jsquyres_at_[hidden]
>>{+} http://www.lam-mpi.org/
>>
>>_______________________________________________
>>This list is archived at http://www.lam-mpi.org/MailArchives/lam/
>>
>
>
>
--
Dr. David Cronk, Ph.D. phone: (865) 974-3735
Research Leader fax: (865) 974-8296
Innovative Computing Lab http://www.cs.utk.edu/~cronk
University of Tennessee, Knoxville
|