X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/1eb32ca7e4d755fec407842b7c879499e2034136..994908f535190638662797b1215506fc0664bd37:/src/smpi/private.h diff --git a/src/smpi/private.h b/src/smpi/private.h index fa42b5c5cf..f3e8515c8f 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -1,84 +1,154 @@ -#include "smpi.h" +#ifndef SMPI_PRIVATE_H +#define SMPI_PRIVATE_H + #include "xbt/mallocator.h" #include "xbt/xbt_os_time.h" +#include "simix/simix.h" + +#include "smpi/smpi.h" + #define SMPI_DEFAULT_SPEED 100 #define SMPI_REQUEST_MALLOCATOR_SIZE 100 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100 -typedef struct SMPI_Global { +// smpi mpi communicator +typedef struct smpi_mpi_communicator_t { + int size; + int barrier_count; + smx_mutex_t barrier_mutex; + smx_cond_t barrier_cond; + + int *rank_to_index_map; + int *index_to_rank_map; + +} s_smpi_mpi_communicator_t; + +// smpi mpi datatype +typedef struct smpi_mpi_datatype_t { + size_t size; +} s_smpi_mpi_datatype_t; + +// smpi mpi request +typedef struct smpi_mpi_request_t { + smpi_mpi_communicator_t comm; + int src; + int dst; + int tag; + + void *buf; + int count; + smpi_mpi_datatype_t datatype; + + short int completed:1; + + smx_mutex_t mutex; + smx_cond_t cond; + + void *data; + int forward; + +} s_smpi_mpi_request_t; + +// smpi mpi op +typedef struct smpi_mpi_op_t { + void (*func) (void *a, void *b, int *length, MPI_Datatype * datatype); +} s_smpi_mpi_op_t; + +// smpi received message +typedef struct smpi_received_message_t { + smpi_mpi_communicator_t comm; + int src; + int tag; + + void *buf; - // config vars - double reference_speed; + void *data; + int forward; - // state vars - int root_ready:1; - int ready_process_count; - smx_mutex_t start_stop_mutex; - smx_cond_t start_stop_cond; +} s_smpi_received_message_t; +typedef struct smpi_received_message_t *smpi_received_message_t; - xbt_mallocator_t request_mallocator; - xbt_mallocator_t message_mallocator; +typedef struct smpi_do_once_duration_node_t { + char *file; + int line; + double duration; + struct smpi_do_once_duration_node_t *next; +} s_smpi_do_once_duration_node_t; +typedef struct smpi_do_once_duration_node_t *smpi_do_once_duration_node_t; - xbt_fifo_t *pending_send_request_queues; - smx_mutex_t *pending_send_request_queues_mutexes; +typedef struct smpi_global_t { - xbt_fifo_t *pending_recv_request_queues; - smx_mutex_t *pending_recv_request_queues_mutexes; + // config vars + double reference_speed; - xbt_fifo_t *received_message_queues; - smx_mutex_t *received_message_queues_mutexes; + // state vars - smx_process_t *sender_processes; - smx_process_t *receiver_processes; + smx_host_t *hosts; + int host_count; + xbt_mallocator_t request_mallocator; + xbt_mallocator_t message_mallocator; - int running_hosts_count; - smx_mutex_t running_hosts_count_mutex; + // FIXME: request queues should be moved to host data... + xbt_fifo_t *pending_send_request_queues; + xbt_fifo_t *pending_recv_request_queues; + xbt_fifo_t *received_message_queues; - xbt_os_timer_t *timers; - smx_mutex_t *timers_mutexes; + smx_process_t *sender_processes; + smx_process_t *receiver_processes; + int running_hosts_count; -} s_SMPI_Global_t, *SMPI_Global_t; + xbt_os_timer_t timer; + smx_mutex_t timer_mutex; + smx_cond_t timer_cond; -extern SMPI_Global_t smpi_global; + // keeps track of previous times + smpi_do_once_duration_node_t do_once_duration_nodes; + smx_mutex_t do_once_mutex; + double *do_once_duration; -struct smpi_received_message_t { - smpi_mpi_communicator_t *comm; - int src; - int dst; - int tag; - void *buf; -}; +} s_smpi_global_t; +typedef struct smpi_global_t *smpi_global_t; +extern smpi_global_t smpi_global; -typedef struct smpi_received_message_t smpi_received_message_t; +typedef struct smpi_host_data_t { + int index; + smx_mutex_t mutex; + smx_cond_t cond; +} s_smpi_host_data_t; +typedef struct smpi_host_data_t *smpi_host_data_t; // function prototypes -int smpi_mpi_comm_size(smpi_mpi_communicator_t *comm); -int smpi_mpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host); -int smpi_mpi_comm_rank_self(smpi_mpi_communicator_t *comm); -int smpi_mpi_comm_world_rank_self(void); -int smpi_sender(int argc, char **argv); -int smpi_receiver(int argc, char **argv); -void *smpi_request_new(void); -void smpi_request_free(void *pointer); -void smpi_request_reset(void *pointer); -void *smpi_message_new(void); -void smpi_message_free(void *pointer); -void smpi_message_reset(void *pointer); -void smpi_global_init(void); -void smpi_global_destroy(void); -int smpi_run_simulation(int argc, char **argv); -void smpi_mpi_land_func(void *x, void *y, void *z); -void smpi_mpi_sum_func(void *x, void *y, void *z); -void smpi_mpi_init(void); +void smpi_init_process(void); void smpi_mpi_finalize(void); +int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm); + +int smpi_mpi_barrier(smpi_mpi_communicator_t comm); +int smpi_mpi_isend(smpi_mpi_request_t request); +int smpi_mpi_irecv(smpi_mpi_request_t request); +int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t * status); + +void smpi_execute(double duration); +void smpi_start_timer(void); +double smpi_stop_timer(void); void smpi_bench_begin(void); void smpi_bench_end(void); -void smpi_barrier(smpi_mpi_communicator_t *comm); -int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host); -int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t *datatype, - int src, int dst, int tag, smpi_mpi_communicator_t *comm, smpi_mpi_request_t **request); -int smpi_isend(smpi_mpi_request_t *request); -int smpi_irecv(smpi_mpi_request_t *request); -void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status); +void smpi_bench_skip(void); + +void smpi_global_init(void); +void smpi_global_destroy(void); +int smpi_host_index(void); +smx_mutex_t smpi_host_mutex(void); +smx_cond_t smpi_host_cond(void); +int smpi_run_simulation(int *argc, char **argv); +int smpi_create_request(void *buf, int count, smpi_mpi_datatype_t datatype, + int src, int dst, int tag, + smpi_mpi_communicator_t comm, + smpi_mpi_request_t * request); + +int smpi_sender(int argc, char **argv); + +int smpi_receiver(int argc, char **argv); + +#endif