MPI_T_source_get_num(3)

πŸ’– MPI_T_source_get_num(3) πŸ’–

okay bestie, welcome to the MPI manual, page for MPI_T_source_get_num 🫢 this one's short and sweet, we love a low-effort bop.


✨ NAME ✨

MPI_T_source_get_num β€” bestie, this one queries the number of event sources πŸ¦‹ it's literally just a headcount. a census. a roll call for event sources.


✨ SYNOPSIS ✨

int MPI_T_source_get_num(int *num_sources)

that's it, that's the whole signature, she's compact πŸ‘‘


✨ OUTPUT PARAMETERS ✨

  • num_sources β€” returns number of event sources (integer) πŸŽ€ so you hand her a pointer and she fills it with how many event sources there are. iconic behavior.

✨ THREAD AND INTERRUPT SAFETY ✨

okay so, the tea β˜•: this routine is thread-safe. that means multiple threads can all use this routine at the same time, and you do not need to bring your own user-provided thread locks. no gatekeeping, she's fine with the whole group chat showing up at once πŸ’…

BUT. and it's a big but 😭 β€” she is NOT interrupt safe. typically this is because of memory allocation routines like malloc or other non-MPICH runtime routines, which are themselves not interrupt-safe. so like, don't interrupt her mid-glow-up, she will not recover gracefully. βœ‹


✨ ERRORS ✨

so like, every single MPI routine (except MPI_Wtime and MPI_Wtick, they're the rebels πŸ™ˆ) returns an error value. C routines return it as the value of the function, and Fortran routines put it in the last argument. before that value comes back to you, the current MPI error handler gets called. by default, that error handler aborts the MPI job β€” not a drill, the whole thing goes down πŸ’€

you can swap the error handler out with MPI_Comm_set_errhandler (for communicators), MPI_File_set_errhandler (for files), and MPI_Win_set_errhandler (for RMA windows). the MPI-1 routine MPI_Errhandler_set may be used, but ngl, its use is deprecated β€” it's giving legacy, we don't stan 🚩

if you want errors to come back as error values instead of nuking your job, use the predefined error handler MPI_ERRORS_RETURN. also important: MPI does not guarantee that an MPI program can continue past an error 🌸 however, MPI implementations will attempt to continue whenever possible. so like, they'll try their best, but no promises, bestie.

The error codes, get ready:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. ate and left no crumbs βœ…
  • MPI_T_ERR_INVALID β€” Invalid use of the interface or bad parameter values(s). πŸ™ˆ
  • MPI_T_ERR_NOT_INITIALIZED β€” The MPI tool information interface is not initialized. you forgot to turn her on, bestie πŸ”Œ
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code. mystery vibe, go read up πŸ”

and that's the whole page, periodt πŸ’œ

sign-off time: this lil masterpiece is dated 4/10/2026, from the MPI manual family, and she's filed under MPI_T_source_get_num(3) πŸŽ€ mwah, go forth and count your event sources. iykyk πŸ’–βœ¨

πŸ“¦ where this page comes from