MPI_Type_vector(3)
π 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_WTIMEandMPI_WTICK) has an extra argumentierrtacked on at the end of the argument list.ierris 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
callstatement. so likecall MPI_Type_vector(...), iykyk π - all MPI objects (for example
MPI_Datatype,MPI_Comm) are of typeINTEGERin 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 exampleMPI_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 uncommittedMPI_Datatype(seeMPI_Type_commit) is used in a communication call. commit your types first, babes π₯MPI_ERR_OTHERβ other error; useMPI_Error_stringto 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
- nixos 26.05: mpich 5.0.1
- ubuntu stonking: mpich-doc 5.0.1-9 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms