Handle to most MPI services

Introduced properties

fun barrier(comm: Comm)

mpi :: MPI :: barrier

Synchronize all processors
fun finalize

mpi :: MPI :: finalize

Terminates the MPI execution environment
fun native_recv(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError

mpi :: MPI :: native_recv

Receive into a NativeCArray buffer with a given count of data_type
fun native_send(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: native_send

Send a NativeCArray buffer with a given count of data_type
fun probe(source: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError

mpi :: MPI :: probe

Probe for the next data to receive, store the result in status
fun processor_name: String

mpi :: MPI :: processor_name

Name of this processor, usually the hostname
fun recv(source: Rank, tag: Tag, comm: Comm): nullable Object

mpi :: MPI :: recv

Receive a complex object
fun recv_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: recv_empty

Receive an empty buffer, only for the tag
fun recv_fill(buffer: Receptacle, source: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: recv_fill

Efficiently receive data and fill an existing buffer
fun recv_into(buffer: Receptacle, at: Int, count: Int, source: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: recv_into

Efficiently receive data in an existing buffer
fun send(data: nullable Serializable, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send

Send a complex Serializable object
fun send_all(buffer: Sendable, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send_all

Send the full content of a buffer
fun send_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: send_empty

Send an empty buffer, only for the tag
fun send_from(buffer: Sendable, at: Int, count: Int, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send_from

Send the content of a buffer
fun wtime: Float

mpi :: MPI :: wtime

Seconds since some time in the past which does not change

Redefined properties

redef type SELF: MPI

mpi $ MPI :: SELF

Type of this instance, automatically specialized in every class
redef init init

mpi $ MPI :: init

Initialize the MPI execution environment

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun barrier(comm: Comm)

mpi :: MPI :: barrier

Synchronize all processors
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun finalize

mpi :: MPI :: finalize

Terminates the MPI execution environment
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun native_recv(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError

mpi :: MPI :: native_recv

Receive into a NativeCArray buffer with a given count of data_type
fun native_send(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: native_send

Send a NativeCArray buffer with a given count of data_type
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun probe(source: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError

mpi :: MPI :: probe

Probe for the next data to receive, store the result in status
fun processor_name: String

mpi :: MPI :: processor_name

Name of this processor, usually the hostname
fun recv(source: Rank, tag: Tag, comm: Comm): nullable Object

mpi :: MPI :: recv

Receive a complex object
fun recv_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: recv_empty

Receive an empty buffer, only for the tag
fun recv_fill(buffer: Receptacle, source: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: recv_fill

Efficiently receive data and fill an existing buffer
fun recv_into(buffer: Receptacle, at: Int, count: Int, source: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: recv_into

Efficiently receive data in an existing buffer
fun send(data: nullable Serializable, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send

Send a complex Serializable object
fun send_all(buffer: Sendable, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send_all

Send the full content of a buffer
fun send_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError

mpi :: MPI :: send_empty

Send an empty buffer, only for the tag
fun send_from(buffer: Sendable, at: Int, count: Int, dest: Rank, tag: Tag, comm: Comm)

mpi :: MPI :: send_from

Send the content of a buffer
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun wtime: Float

mpi :: MPI :: wtime

Seconds since some time in the past which does not change
package_diagram mpi::MPI MPI core::Object Object mpi::MPI->core::Object

Parents

interface Object

core :: Object

The root of the class hierarchy.

Class definitions

mpi $ MPI
# Handle to most MPI services
class MPI
	# Initialize the MPI execution environment
	init do native_init

	private fun native_init `{ MPI_Init(NULL, NULL); `}

	# Terminates the MPI execution environment
	fun finalize `{ MPI_Finalize(); `}

	# Name of this processor, usually the hostname
	fun processor_name: String import CString.to_s_with_length `{
		char *name = malloc(MPI_MAX_PROCESSOR_NAME);
		int size;
		MPI_Get_processor_name(name, &size);
		return CString_to_s_with_length(name, size);
	`}

	# Send the content of a buffer
	fun send_from(buffer: Sendable, at, count: Int, dest: Rank, tag: Tag, comm: Comm)
	do
		buffer.send(self, at, count, dest, tag, comm)
	end

	# Send the full content of a buffer
	fun send_all(buffer: Sendable, dest: Rank, tag: Tag, comm: Comm)
	do
		buffer.send_all(self, dest, tag, comm)
	end

	# Efficiently receive data in an existing buffer
	fun recv_into(buffer: Receptacle, at, count: Int, source: Rank, tag: Tag, comm: Comm)
	do
		buffer.recv(self, at, count, source, tag, comm)
	end

	# Efficiently receive data and fill an existing buffer
	fun recv_fill(buffer: Receptacle, source: Rank, tag: Tag, comm: Comm)
	do
		buffer.recv_fill(self, source, tag, comm)
	end

	# Send a complex `Serializable` object
	fun send(data: nullable Serializable, dest: Rank, tag: Tag, comm: Comm)
	do
		# Serialize data
		var stream = new StringWriter
		var serializer = new JsonSerializer(stream)
		serializer.serialize(data)

		# Send message
		var str = stream.to_s
		send_from(str, 0, str.length, dest, tag, comm)
	end

	# Receive a complex object
	fun recv(source: Rank, tag: Tag, comm: Comm): nullable Object
	do
		var status = new Status

		# Block until a message in in queue
		var err = probe(source, tag, comm, status)
		assert err.is_success else print err

		# Get message length
		var count = status.count(new DataType.char)
		assert not count.is_undefined

		# Receive message into buffer
		var buffer = new FlatBuffer.with_capacity(count)
		recv_into(buffer, 0, count, status.source, status.tag, comm)

		# Free our status
		status.free

		# Deserialize message
		var deserializer = new JsonDeserializer(buffer)
		var deserialized = deserializer.deserialize

		if deserialized == null then print "|{buffer}|{buffer.chars.join("-")}| {buffer.length}"

		return deserialized
	end

	# Send an empty buffer, only for the `tag`
	fun send_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError
	`{
		return MPI_Send(NULL, 0, MPI_CHAR, dest, tag, comm);
	`}

	# Receive an empty buffer, only for the `tag`
	fun recv_empty(dest: Rank, tag: Tag, comm: Comm): SuccessOrError
	`{
		return MPI_Recv(NULL, 0, MPI_CHAR, dest, tag, comm, MPI_STATUS_IGNORE);
	`}

	# Send a `NativeCArray` `buffer` with a given `count` of `data_type`
	fun native_send(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm): SuccessOrError
	`{
		return MPI_Send(buffer, count, data_type, dest, tag, comm);
	`}

	# Receive into a `NativeCArray` `buffer` with a given `count` of `data_type`
	fun native_recv(buffer: NativeCArray, count: Int, data_type: DataType, dest: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError
	`{
		return MPI_Recv(buffer, count, data_type, dest, tag, comm, status);
	`}

	# Probe for the next data to receive, store the result in `status`
	#
	# Note: If you encounter an error where the next receive does not correspond
	# to the last `probe`, call this method twice to ensure a correct result.
	fun probe(source: Rank, tag: Tag, comm: Comm, status: Status): SuccessOrError
	`{
		return MPI_Probe(source, tag, comm, status);
	`}

	# Synchronize all processors
	fun barrier(comm: Comm) `{ MPI_Barrier(comm); `}

	# Seconds since some time in the past which does not change
	fun wtime: Float `{ return MPI_Wtime(); `}
end
lib/mpi/mpi.nit:42,1--164,3