TRECV(3PVM)

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

πŸ’– TRECV(3PVM) πŸ’–

okay bestie, welcome to TRECV from the PVM Version 3.4 manual set β€” yes, the 3PVM section, we're doing real parallel-computing lore today ✨


🌸 NAME 🌸

pvm_trecv β€” receive with a timeout, bestie. that's it, that's the whole vibe πŸŽ€


✨ SYNOPSIS ✨

C girlies:

#include <sys/time.h>
int bufid = pvm_trecv( int tid, int msgtag, struct timeval *tmout )

Fortran girlies:

call pvmftrecv( tid, msgtag, sec, usec, bufid )

πŸ¦‹ PARAMETERS πŸ¦‹

  • tid β€” an integer, matches the task identifier of whoever's sending you stuff πŸ‘€
  • msgtag β€” an integer that matches the message tag. should be >= 0, no cap πŸ’…
  • tmout β€” (or, in Fortran, sec and usec) how long you're willing to wait before just giving up and returning with no message. it's giving patience, but make it a limit πŸ•°οΈ
  • bufid β€” an integer that returns the value of the new active receive buffer identifier. anything less than zero means something went wrong 😭

πŸ’œ DESCRIPTION πŸ’œ

so like, pvm_trecv blocks the process until a message with the label msgtag shows up from tid. no message, no movement. it's main character energy, it waits 🌟

once that message arrives, pvm_trecv drops it into a new active receive buffer β€” and yes, it also clears the current receive buffer, out with the old 🧹

but if no matching message arrives within the waiting time you gave it? pvm_trecv just returns without a message. no drama, no message, we move 🫢

now the fun part: a -1 in msgtag or tid matches anything. wildcard queen πŸ‘‘ which gives you these options:

  • if tid = -1, then pvm_trecv will accept a message from any process which has a matching msgtag.
  • if msgtag = -1, then pvm_trecv will accept any message that is sent from process tid.
  • if tid and msgtag are both -1, then pvm_trecv will accept any message from any process. literally anything, we're not picky πŸ’€

in C, the tmout fields tv_sec and tv_usec specify how long pvm_trecv will wait without returning a matching message. in Fortran, two separate parameters, sec and usec, are passed instead. set both to zero and pvm_trecv behaves the same as pvm_nrecv β€” which is to probe for messages and return immediately even if none are matched. not me waiting zero seconds, respectfully πŸ™ˆ

in C, passing a null pointer in tmout makes pvm_trecv act like pvm_recv, that is, it will wait indefinitely. in Fortran, setting sec to -1 has the same effect. forever girlies, we ride at dawn 🌈


⭐ the message order tea ⭐

the PVM model guarantees the following about message order, and this is important so listen up:

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. first in, first out, we love a queue that respects itself πŸ’–

moreover, if both messages arrive before task 2 does a receive, then a wildcard receive will always return message A. no cap, that's guaranteed πŸ”₯


πŸŽ€ what you get back πŸŽ€

  • if pvm_trecv is successful, bufid will be the new active receive buffer identifier ✨
  • if no message is received, pvm_trecv returns 0 πŸ«₯
  • if some error occurs then bufid will be < 0 πŸ’€

once pvm_trecv returns, the data in the message can be unpacked into the user's memory using the unpack routines. go get your data bestie πŸ“


🌈 EXAMPLES 🌈

C:

struct timeval tmout;

tid = pvm_parent();
msgtag = 4 ;
tmout.tv_sec = 60;
tmout.tv_usec = 0;
if ((bufid = pvm_trecv( tid, msgtag, &tmout )) > 0) {
     pvm_upkint( tid_array, 10, 1 );
     pvm_upkint( problem_size, 1, 1 );
     pvm_upkfloat( input_array, 100, 1 );
}

Fortran:

CALL PVMFTRECV( -1, 4, 60, 0, BUFID )
IF (BUFID .EQ. 0) GO TO 666
CALL PVMFUNPACK( INTEGER4, TIDS, 25, 1, INFO )
CALL PVMFUNPACK( REAL8, MATRIX, 100, 100, INFO )
666  CONTINUE

😭 ERRORS 😭

these error conditions can be returned by pvm_trecv:

  • PvmBadParam β€” you gave an invalid tid value, or msgtag < -1. bestie. read the parameter list again πŸ™ˆ
  • PvmSysErr β€” pvmd not responding. it's not ghosting you, it's genuinely down πŸ’€

🧚 SEE ALSO 🧚

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

the whole friend group, go say hi 🫢


and that's the page, babes πŸ’… this was TRECV(3PVM) from PVM Version 3.4, dated 8 February, 1994 β€” an absolute icon of a date, obsessed ⭐ go forth and receive with a timeout, and remember: wildcards are valid, -1 is your friend, and if you set both sec and usec to zero you're basically speedrunning. mwah πŸŽ€

πŸ“¦ where this page comes from