NRECV(3PVM)

πŸ“¦ version 3.4.6, in debian bookworm, ubuntu jammy

πŸ’– NRECV β€” the pvm_nrecv page (3PVM) πŸ’–

okay bestie, so you're in the PVM section of the manual (that's the 3PVM part, in case anyone asks) and you wanna know if a message showed up yet, without, like, standing at the door forever waiting. Say less. PVM Version 3.4 has you. πŸ¦‹


✨ NAME ✨

pvm_nrecv β€” non-blocking receive. she checks, she does NOT wait around. main character energy only. πŸ’…


✨ SYNOPSIS ✨

C:

int bufid = pvm_nrecv( int tid, int msgtag )

Fortran:

call pvmfnrecv( tid, msgtag, bufid )

πŸŽ€ PARAMETERS πŸŽ€

  • tid β€” integer task identifier of the sending process, supplied by you, bestie. πŸ‘‘
  • msgtag β€” integer message tag supplied by you. and like, msgtag should be >= 0. respectfully. 🌸
  • bufid β€” integer that returns the value of the new active receive buffer identifier. values less than zero mean something went wrong. πŸ’€

🌈 DESCRIPTION 🌈

pvm_nrecv peeks to see if a message with label msgtag has arrived from tid, and it also clears the current receive buffer if there is one. if a matching message has already arrived, pvm_nrecv immediately drops that message into a brand-new active receive buffer and hands you back the buffer identifier in bufid. iconic behavior. ✨

if the message you asked for hasn't arrived yet, pvm_nrecv returns immediately with a 0 in bufid. no waiting, no drama. and if some error happens, bufid will be < 0. 😭

a -1 in msgtag or tid matches anything. this is the wildcard, and it gives you these options:

  • if tid = -1 and msgtag is defined by you, then pvm_nrecv will accept a message from any process that has a matching msgtag. 🫢
  • if msgtag = -1 and tid is defined by you, then pvm_nrecv will accept any message that is sent from process tid. πŸ’œ
  • if tid = -1 and msgtag = -1, then pvm_nrecv will accept any message from any process. literally anything. wild. 🌈

okay and now the part that's giving ✨guaranteed✨ β€” the PVM model promises this about message order: if task 1 sends message A to task 2, then task 1 sends message B to task 2, message A will arrive at task 2 before message B. and on top of that, if both messages arrive before task 2 does a receive, then a wildcard receive will always return message A. no cap. πŸ”₯

pvm_nrecv is non-blocking in the sense that the routine always returns immediately β€” either with the message, or with the info that the message hasn't arrived at the local pvmd yet. you can call pvm_nrecv multiple times to check if a given message has arrived yet. and also, the blocking receive pvm_recv can be called for the same message if your app runs out of work it could do before the data arrives. so like, you're never stuck. 😌

and if pvm_nrecv does return with the message, then the data in that message can be unpacked into your memory using the unpack routines. slay. πŸ’–


🌸 EXAMPLES 🌸

C:

tid = pvm_parent();
msgtag = 4 ;
arrived = pvm_nrecv( tid, msgtag );
if ( arrived > 0)
     info = pvm_upkint( tid_array, 10, 1 );
else
     /* go do other computing */

Fortran:

CALL PVMFNRECV( -1, 4, ARRIVED )
IF ( ARRIVED .gt. 0 ) THEN
   CALL PVMFUNPACK( INTEGER4, TIDS, 25, 1, INFO )
   CALL PVMFUNPACK( REAL8, MATRIX, 100, 100, INFO )
ELSE
*       GO DO USEFUL WORK
ENDIF

😭 ERRORS 😭

these error conditions can be returned by pvm_nrecv. take notes bestie:

  • PvmBadParam β€” you gave an invalid tid value or msgtag. πŸ™ˆ
  • PvmSysErr β€” pvmd not responding. she's ghosting you. πŸ’€

πŸ¦‹ SEE ALSO πŸ¦‹

pvm_bufinfo(3PVM), pvm_getminfo(3PVM), pvm_recv(3PVM), pvm_unpack(3PVM), pvm_send(3PVM), pvm_mcast(3PVM)


k bye ily, go forth and receive non-blockingly πŸ’œ this whole thing is from PVM Version 3.4, dated 30 August, 1993 β€” yeah she's vintage, but vintage is just iconic with a timestamp. periodt. πŸ‘‘βœ¨

πŸ“¦ where this page comes from