X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2f2f00652fd75c462b2cb832358e7b66c72c8e07..99e8fb90a14e543c1a4b2feaf22a5c0670c2951a:/src/smpi/private.h diff --git a/src/smpi/private.h b/src/smpi/private.h index 8e215a6d0f..e01c62461c 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -11,19 +11,16 @@ #define SMPI_DEFAULT_SPEED 100 #define SMPI_REQUEST_MALLOCATOR_SIZE 100 #define SMPI_MESSAGE_MALLOCATOR_SIZE 100 -// FIXME: should probably be dynamic datatype... -// or could include code to dynamically expand when full -#define SMPI_MAX_TIMES 10 // 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 size; + int barrier_count; + smx_mutex_t barrier_mutex; + smx_cond_t barrier_cond; - int *rank_to_index_map; - int *index_to_rank_map; + int *rank_to_index_map; + int *index_to_rank_map; } s_smpi_mpi_communicator_t; @@ -34,114 +31,133 @@ typedef struct smpi_mpi_datatype_t { // smpi mpi request typedef struct smpi_mpi_request_t { - smpi_mpi_communicator_t comm; - int src; - int dst; - int tag; + smpi_mpi_communicator_t comm; + int src; + int dst; + int tag; - void *buf; - int count; - smpi_mpi_datatype_t datatype; + void *buf; + int count; + smpi_mpi_datatype_t datatype; - short int completed :1; + short int completed:1; + short int consumed:1; /* for waitany */ - smx_mutex_t mutex; - smx_cond_t cond; + smx_mutex_t mutex; + smx_cond_t cond; - void *data; - int forward; + 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); + 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; + smpi_mpi_communicator_t comm; + int src; + int tag; - void *buf; + void *buf; - void *data; - int forward; + void *data; + int forward; } s_smpi_received_message_t; typedef struct smpi_received_message_t *smpi_received_message_t; -typedef struct smpi_global_t { - - // config vars - double reference_speed; - - // state vars - int root_ready:1; - int ready_process_count; - smx_mutex_t start_stop_mutex; - smx_cond_t start_stop_cond; +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; - smx_host_t *hosts; - int host_count; - xbt_mallocator_t request_mallocator; - xbt_mallocator_t message_mallocator; - - 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 + int process_count; + xbt_mallocator_t request_mallocator; + xbt_mallocator_t message_mallocator; - smx_process_t *sender_processes; - smx_process_t *receiver_processes; + smx_process_t *main_processes; - int running_hosts_count; - smx_mutex_t running_hosts_count_mutex; + xbt_os_timer_t timer; + smx_cond_t timer_cond; - xbt_os_timer_t timer; - smx_mutex_t timer_mutex; - smx_cond_t timer_cond; - double times[SMPI_MAX_TIMES]; - int times_max; - smx_mutex_t times_mutex; + // 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; } s_smpi_global_t; typedef struct smpi_global_t *smpi_global_t; extern smpi_global_t smpi_global; typedef struct smpi_host_data_t { - int index; -} s_smpi_host_data_t; -typedef struct smpi_host_data_t *smpi_host_data_t; + int index; + smx_mutex_t mutex; + smx_cond_t cond; + + smx_process_t main; + smx_process_t sender; + smx_process_t receiver; + + int finalize; /* so that main process stops its sender&receiver */ + + xbt_fifo_t pending_recv_request_queue; + xbt_fifo_t pending_send_request_queue; + xbt_fifo_t received_message_queue; +} s_smpi_process_data_t; +typedef struct smpi_host_data_t *smpi_process_data_t; // function prototypes -void smpi_mpi_init(void); -void smpi_mpi_finalize(void); +void smpi_process_init(int *argc, char ***argv); +void smpi_process_finalize(void); int smpi_mpi_comm_rank(smpi_mpi_communicator_t comm); +int smpi_mpi_bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm 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); - +int smpi_mpi_reduce(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, int root, MPI_Comm comm); +int smpi_mpi_sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int dest, int sendtag, + void *recvbuf, int recvcount, MPI_Datatype recvtype, int source, int recvtag, + MPI_Comm comm, MPI_Status *status); +int smpi_mpi_wait(smpi_mpi_request_t request, smpi_mpi_status_t * status); +int smpi_mpi_waitall(int count, smpi_mpi_request_t requests[], smpi_mpi_status_t status[]); +int smpi_mpi_waitany(int count, smpi_mpi_request_t requests[], int *index, smpi_mpi_status_t status[]); + + +// utilities +void smpi_execute(double duration); +void smpi_start_timer(void); +double smpi_stop_timer(void); void smpi_bench_begin(void); -double smpi_bench_end(void); +void smpi_bench_end(void); void smpi_bench_skip(void); void smpi_global_init(void); void smpi_global_destroy(void); -int smpi_host_index(void); +int smpi_process_index(void); +smx_mutex_t smpi_process_mutex(void); +smx_cond_t smpi_process_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 src, int dst, int tag, + smpi_mpi_communicator_t comm, + smpi_mpi_request_t * request); -int smpi_receiver(int argc, char **argv); +int smpi_sender(int argc, char *argv[]); +int smpi_receiver(int argc, char *argv[]); #endif