Class
NumCosmoMathMPIJob
Description [src]
abstract class NumCosmoMath.MPIJob : GObject.Object
{
/* No available fields */
}
Abstract class to implement MPI jobs.
This abstract class simplifies the implementation of MPI jobs through a master/slave model. Subclasses must implement virtual methods. The master dispatches jobs to the slaves, awaits results, and slaves execute the job, sending results back to the master.
For example, NcmMPIJobMCMC is a specific subclass that implements an MCMC job. Each
slave creates an instance of NcmLikelihood, evaluating the likelihood function for
samples received from the master.
The master/slave model leverages MPI. The subclass is responsible for implementing virtual methods for packing/unpacking input and return objects into/from MPI buffers.
When NumCosmo is compiled with MPI support, the rank 0 process executes normally,
while other ranks wait for commands from the master. The method
ncm_mpi_job_init_all_slaves() sends a serialized version of itself to all slaves.
Slaves deserialize it and wait for commands.
Each call to ncm_mpi_job_run_array() sends an array of inputs to the slaves in a
round-robin fashion. Slaves execute the job and return results to the master,
maintaining the input order. This method uses rank 0 to control the slaves, so the
master isn’t involved in computations.
Conversely, ncm_mpi_job_run_array_async() sends inputs to the slaves and creates a
lightweight thread to receive results while the master concurrently executes the job.
After job completion, the master calls ncm_mpi_job_free_all_slaves() to release the
slaves. It’s an error to use two or more instances of any subclass of NcmMPIJob
simultaneously.
Functions
ncm_mpi_job_clear
Decrease the reference count of mpi_job by one, and sets the pointer *mpi_job to
NULL.
Instance methods
ncm_mpi_job_destroy_input_buffer
Destroy buf created with ncm_mpi_job_get_input_buffer()
or ncm_mpi_job_pack_input().
ncm_mpi_job_destroy_return_buffer
Destroy buf created with ncm_mpi_job_get_return_buffer()
or ncm_mpi_job_pack_return().
ncm_mpi_job_get_input_buffer
Creates a buffer from input compatible with ncm_mpi_job_input_datatype().
ncm_mpi_job_get_return_buffer
Creates a buffer from ret compatible with ncm_mpi_job_return_datatype().
ncm_mpi_job_run_array
Send work to all slaves in a round-robin fashion. Both arrays input_array and ret_array
must have the same length and should be filled with the appropriated pointers.
ncm_mpi_job_run_array_async
Send work to all slaves using an additional thread to control the slaves work.
The main execution thread runs jobs in parallel while it waits for the slaves to finish.
Both arrays input_array and ret_array must have the same length and should be
filled with the appropriated pointers.
ncm_mpi_job_work_clear
Method called during the working phase of mpi_job and in the
end before object destruction. This method can be called multiple
times during the work phase.
ncm_mpi_job_work_init
Method called after mpi_job is initialized at the slave
and before start working.
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.
Class structure
struct NumCosmoMathMPIJobClass {
void (* work_init) (
NcmMPIJob* mpi_job
);
void (* work_clear) (
NcmMPIJob* mpi_job
);
NcmMPIDatatype (* input_datatype) (
NcmMPIJob* mpi_job,
gint* len,
gint* size
);
NcmMPIDatatype (* return_datatype) (
NcmMPIJob* mpi_job,
gint* len,
gint* size
);
gpointer (* create_input) (
NcmMPIJob* mpi_job
);
gpointer (* create_return) (
NcmMPIJob* mpi_job
);
void (* destroy_input) (
NcmMPIJob* mpi_job,
gpointer input
);
void (* destroy_return) (
NcmMPIJob* mpi_job,
gpointer ret
);
gpointer (* get_input_buffer) (
NcmMPIJob* mpi_job,
gpointer input
);
gpointer (* get_return_buffer) (
NcmMPIJob* mpi_job,
gpointer ret
);
void (* destroy_input_buffer) (
NcmMPIJob* mpi_job,
gpointer input,
gpointer buf
);
void (* destroy_return_buffer) (
NcmMPIJob* mpi_job,
gpointer ret,
gpointer buf
);
gpointer (* pack_input) (
NcmMPIJob* mpi_job,
gpointer input
);
gpointer (* pack_return) (
NcmMPIJob* mpi_job,
gpointer ret
);
void (* unpack_input) (
NcmMPIJob* mpi_job,
gpointer buf,
gpointer input
);
void (* unpack_return) (
NcmMPIJob* mpi_job,
gpointer buf,
gpointer ret
);
void (* run) (
NcmMPIJob* mpi_job,
gpointer input,
gpointer ret
);
}
No description available.
Class members
work_init: void (* work_init) ( NcmMPIJob* mpi_job )No description available.
work_clear: void (* work_clear) ( NcmMPIJob* mpi_job )No description available.
input_datatype: NcmMPIDatatype (* input_datatype) ( NcmMPIJob* mpi_job, gint* len, gint* size )No description available.
return_datatype: NcmMPIDatatype (* return_datatype) ( NcmMPIJob* mpi_job, gint* len, gint* size )No description available.
create_input: gpointer (* create_input) ( NcmMPIJob* mpi_job )No description available.
create_return: gpointer (* create_return) ( NcmMPIJob* mpi_job )No description available.
destroy_input: void (* destroy_input) ( NcmMPIJob* mpi_job, gpointer input )No description available.
destroy_return: void (* destroy_return) ( NcmMPIJob* mpi_job, gpointer ret )No description available.
get_input_buffer: gpointer (* get_input_buffer) ( NcmMPIJob* mpi_job, gpointer input )No description available.
get_return_buffer: gpointer (* get_return_buffer) ( NcmMPIJob* mpi_job, gpointer ret )No description available.
destroy_input_buffer: void (* destroy_input_buffer) ( NcmMPIJob* mpi_job, gpointer input, gpointer buf )No description available.
destroy_return_buffer: void (* destroy_return_buffer) ( NcmMPIJob* mpi_job, gpointer ret, gpointer buf )No description available.
pack_input: gpointer (* pack_input) ( NcmMPIJob* mpi_job, gpointer input )No description available.
pack_return: gpointer (* pack_return) ( NcmMPIJob* mpi_job, gpointer ret )No description available.
unpack_input: void (* unpack_input) ( NcmMPIJob* mpi_job, gpointer buf, gpointer input )No description available.
unpack_return: void (* unpack_return) ( NcmMPIJob* mpi_job, gpointer buf, gpointer ret )No description available.
run: void (* run) ( NcmMPIJob* mpi_job, gpointer input, gpointer ret )No description available.
Virtual methods
NumCosmoMath.MPIJobClass.destroy_input
Destroy the input object created with ncm_mpi_job_create_input().
NumCosmoMath.MPIJobClass.destroy_input_buffer
Destroy buf created with ncm_mpi_job_get_input_buffer()
or ncm_mpi_job_pack_input().
NumCosmoMath.MPIJobClass.destroy_return
Destroy the return object created with ncm_mpi_job_create_return().
NumCosmoMath.MPIJobClass.destroy_return_buffer
Destroy buf created with ncm_mpi_job_get_return_buffer()
or ncm_mpi_job_pack_return().
NumCosmoMath.MPIJobClass.get_input_buffer
Creates a buffer from input compatible with ncm_mpi_job_input_datatype().
NumCosmoMath.MPIJobClass.get_return_buffer
Creates a buffer from ret compatible with ncm_mpi_job_return_datatype().
NumCosmoMath.MPIJobClass.unpack_input
Unpacks (when necessary) the buffer buf into the input pointer input.
NumCosmoMath.MPIJobClass.unpack_return
Unpacks (when necessary) the buffer buf into the return pointer return.
NumCosmoMath.MPIJobClass.work_clear
Method called during the working phase of mpi_job and in the
end before object destruction. This method can be called multiple
times during the work phase.
NumCosmoMath.MPIJobClass.work_init
Method called after mpi_job is initialized at the slave
and before start working.