MPI_Type_contiguous(3)

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

πŸ’– MPI_Type_contiguous(3) πŸ’–

okay bestie, welcome to the MPI manual, and today's main character is MPI_Type_contiguous β€” she's giving "make me a brand new datatype that's just a bunch of the old one, back to back, no gaps, no drama" πŸ’…


✨ NAME ✨

MPI_Type_contiguous β€” Creates a contiguous datatype 🧚


🌸 SYNOPSIS 🌸

int MPI_Type_contiguous(int count, MPI_Datatype oldtype, MPI_Datatype *newtype)

int MPI_Type_contiguous_c(MPI_Count count, MPI_Datatype oldtype,
MPI_Datatype *newtype)

two flavours, same energy, pick ur fighter 🫢


πŸŽ€ INPUT PARAMETERS πŸŽ€

  • count β€” the replication count, aka how many times we're copying the vibe. must be a non-negative integer fr fr, don't try to be quirky with negatives πŸ’€
  • oldtype β€” the old datatype (a handle). the original icon we're duplicating πŸ‘‘

πŸ¦‹ OUTPUT PARAMETERS πŸ¦‹

  • newtype β€” the new datatype (a handle). the glow-up, freshly baked, all yours ✨

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

This routine is thread-safe πŸ’– which literally means multiple threads can use it at the same time with zero user-provided thread locks needed. no babysitting, no gatekeeping, just vibes 🌈

BUT β€” and this is the plot twist β€” the routine is not interrupt safe 😭 Typically this is because of memory allocation routines like malloc or other non-MPICH runtime routines that are themselves not interrupt-safe. so like, thread-safe yes, interrupt-safe no, we contain multitudes.


πŸ“ NOTES FOR FORTRAN πŸ“

All MPI routines in Fortran (except for MPI_WTIME and MPI_WTICK) have an additional argument ierr at the end of the argument list. ierr is an integer and has the same meaning as the return value of the routine in C. iykyk ✨

In Fortran, MPI routines are subroutines, and they're invoked with the call statement.

All MPI objects (e.g., MPI_Datatype, MPI_Comm) are of type INTEGER in Fortran. periodt πŸ’…


πŸ’€ ERRORS πŸ’€

All MPI routines (except MPI_Wtime and MPI_Wtick) return an error value; C routines as the value of the function and Fortran routines in the last argument. Before the value is returned, the current MPI error handler is called. By default, this error handler aborts the MPI job 😭 so like, pay attention bestie.

The error handler may be changed with:

  • MPI_Comm_set_errhandler (for communicators)
  • MPI_File_set_errhandler (for files)
  • MPI_Win_set_errhandler (for RMA windows)

The MPI-1 routine MPI_Errhandler_set may be used but its use is deprecated 🚩 (we don't do that anymore, it's giving legacy).

The predefined error handler MPI_ERRORS_RETURN may be used to cause error values to be returned.

Note that MPI does not guarantee that an MPI program can continue past an error; however, MPI implementations will attempt to continue whenever possible. so, like, fingers crossed 🀞

here's the error roster:

  • MPI_SUCCESS β€” No error; MPI routine completed successfully. ate and left no crumbs πŸŽ‰
  • MPI_ERR_ARG β€” Invalid argument. Some argument is invalid and is not identified by a specific error class (e.g., MPI_ERR_RANK). πŸ™ˆ
  • MPI_ERR_COUNT β€” Invalid count argument. Count arguments must be non-negative; a count of zero is often valid. (yes zero counts, she's 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 ur datatypes bestie, don't be that girl
  • MPI_ERR_OTHER β€” Other error; use MPI_Error_string to get more information about this error code. the mysterious one 🌫️

and that's the whole page, no notes, we ate πŸ’–βœ¨πŸŽ€

this lil love letter came from the MPI manual, dated 4/10/2026, and it's filed under MPI_Type_contiguous(3) β€” go forth and build contiguous datatypes, my gorgeous little parallel-computing genius πŸ‘‘πŸ¦‹

πŸ“¦ where this page comes from