MPI_Type_vector(3)

πŸ“¦
version 5.0.1 Β· 5 versions
, in nixos 26.05, ubuntu stonking

πŸ’– MPI_Type_vector πŸ’–

okay bestie, welcome to the MPI_Type_vector(3) page from the MPI manual, and no cap this one is a banger. it creates a vector (strided) datatype ✨ like literally, you're building a custom datatype that's a bunch of blocks with gaps between them. it's giving ✨fashion✨ for your memory layout.


πŸŽ€ SYNOPSIS πŸŽ€

int MPI_Type_vector(int count, int blocklength, int stride,
MPI_Datatype oldtype, MPI_Datatype *newtype)

int MPI_Type_vector_c(MPI_Count count, MPI_Count blocklength, MPI_Count stride,
MPI_Datatype oldtype, MPI_Datatype *newtype)

two flavours, bestie: the classic int one and the _c one that takes MPI_Count for when your numbers are Big πŸ’…


🌸 INPUT PARAMETERS 🌸

  • count β€” the number of blocks, and it's a non-negative integer. like how many little chunks you're making 🧩
  • blocklength β€” the number of elements in each block, also a non-negative integer. so each chunk is this thicc πŸ’ƒ
  • stride β€” the number of elements between the start of each block, and this one is just an integer (yes it can be negative, she's flexible like that πŸ™ˆ). the gap-energia between your blocks ✨
  • oldtype β€” the old datatype (handle). your starting material, babes.

🫢 OUTPUT PARAMETERS 🫢

  • newtype β€” the new datatype (handle). the glow-up result, the slay, the main character πŸ‘‘

πŸ”₯ THREAD AND INTERRUPT SAFETY πŸ”₯

okay so this routine is thread-safe. what that means: multiple threads can use it at the same time and you don't need to bring your own thread locks. no user-provided locks required, she handles herself πŸ’…

however β€” and this is the important part β€” the routine is not interrupt safe 😭. typically that's because it uses memory allocation routines like malloc or other non-MPICH runtime routines, and those lil guys are themselves not interrupt-safe. so like, don't interrupt her mid-alloc, bestie, she's busy 🚫


⭐ NOTES FOR FORTRAN ⭐

  • every MPI routine in Fortran (except for MPI_WTIME and MPI_WTICK) has an extra argument ierr tacked on at the end of the argument list. ierr is an integer and it means the exact same thing as the return value of the routine in C. periodt.
  • in Fortran, MPI routines are subroutines and you invoke them with the call statement. so like call MPI_Type_vector(...), iykyk πŸ›
  • all MPI objects (for example MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. iconic, honestly.

πŸ’€ ERRORS πŸ’€

so every MPI routine (except MPI_Wtime and MPI_Wtick) returns an error value β€” C routines as the value of the function, and Fortran routines in that last argument. before that value comes back, the current MPI error handler gets called. and by default, this error handler aborts the MPI job πŸ’€ like, whole thing, gone, rip.

the error handler can be changed 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 its use is deprecated β€” don't, bestie, she's old news.

the predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned instead. also heads up: 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 try, they really do 🫢

here's the error code rundown:

  • MPI_SUCCESS β€” no error; MPI routine completed successfully. we love a clean run ✨
  • MPI_ERR_ARG β€” invalid argument. some argument is invalid and it's not identified by a specific error class (for example MPI_ERR_RANK). she's vague on purpose πŸ™ˆ
  • MPI_ERR_COUNT β€” invalid count argument. count arguments must be non-negative; but psst, a count of zero is often valid πŸŽ€
  • MPI_ERR_TYPE β€” invalid datatype argument. additionally, this error can occur if an uncommitted MPI_Datatype (see MPI_Type_commit) is used in a communication call. commit your types first, babes πŸ”₯
  • MPI_ERR_OTHER β€” other error; use MPI_Error_string to get more information about this error code. the catch-all, the mystery, the unexplainable 🌈

ok that's the whole page bestie, every flag, every error code, every vibe πŸ’– go build those strided datatypes and eat, no crumbs πŸ‘‘

✿ this has been MPI_Type_vector(3) from the MPI manual, dated 4/10/2026, sourced from MPI ✿ bye ily, go compile something gorgeous πŸ’œπŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from