From: markls Date: Tue, 3 Jul 2007 05:35:31 +0000 (+0000) Subject: re-start smpi from scratch to use SIMIX. X-Git-Tag: v3.3~1714 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4e44cf2b94eb0e3c0afeb511d20c8daf2218db7a re-start smpi from scratch to use SIMIX. git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@3646 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index a35a9923e4..f2affd4a4e 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -12,7 +12,7 @@ #include "xbt/dynar.h" #include "xbt/dict.h" #include "xbt/misc.h" -#include "gras_config.h" +//#include "gras_config.h" SG_BEGIN_DECL() diff --git a/src/smpi/include/smpi.h b/src/smpi/include/smpi.h index 9f67528043..3a7426d8a3 100644 --- a/src/smpi/include/smpi.h +++ b/src/smpi/include/smpi.h @@ -1,4 +1,6 @@ -#define DEFAULT_POWER 100 +#define SMPI_DEFAULT_SPEED 100 + +#define SMPI_RAND_SEED 5 #define MPI_ANY_SOURCE -1 @@ -14,13 +16,11 @@ #define MPI_ERR_TAG 8 #include -#include -typedef enum { MPI_PORT = 0, SEND_SYNC_PORT, RECV_SYNC_PORT, MAX_CHANNEL } channel_t; +#include // MPI_Comm struct smpi_mpi_communicator_t { - int id; int size; int barrier; smx_host_t *hosts; @@ -42,7 +42,6 @@ extern smpi_mpi_status_t smpi_mpi_status_ignore; // MPI_Datatype struct smpi_mpi_datatype_t { -// int type; size_t size; }; typedef struct smpi_mpi_datatype_t smpi_mpi_datatype_t; @@ -55,13 +54,6 @@ extern smpi_mpi_datatype_t smpi_mpi_int; extern smpi_mpi_datatype_t smpi_mpi_double; #define MPI_DOUBLE (&smpi_mpi_double) -struct smpi_waitlist_node_t { - smx_process_t process; - struct smpi_waitlist_node_t *next; -}; -typedef struct smpi_waitlist_node_t smpi_waitlist_node_t; - -// FIXME: maybe it isn't appropriate to have the next pointer inside // MPI_Request struct smpi_mpi_request_t { void *buf; @@ -72,9 +64,7 @@ struct smpi_mpi_request_t { int tag; smpi_mpi_communicator_t *comm; short int completed; - smpi_waitlist_node_t *waitlist; - struct smpi_mpi_request_t *next; - int fwdthrough; + xbt_fifo_t waitlist; }; typedef struct smpi_mpi_request_t smpi_mpi_request_t; typedef smpi_mpi_request_t *MPI_Request; @@ -90,32 +80,18 @@ extern smpi_mpi_op_t smpi_mpi_land; extern smpi_mpi_op_t smpi_mpi_sum; #define MPI_SUM (&smpi_mpi_sum) -// smpi_received_t -struct smpi_received_t { - int commid; - int src; - int dst; - int tag; - int fwdthrough; - void *data; - struct smpi_received_t *next; +// smpi_received_message_t +struct smpi_received_message_t { + smpi_mpi_communicator_t *comm; + int src; + int dst; + int tag; + void *data; + int fwdthrough; }; -typedef struct smpi_received_t smpi_received_t; - -// sender/receiver (called by main routine) -int smpi_sender(int argc, char *argv[]); -int smpi_receiver(int argc, char *argv[]); +typedef struct smpi_received_message_t smpi_received_message_t; // smpi functions -int smpi_comm_rank(smpi_mpi_communicator_t *comm, smx_host_t host); -void smpi_isend(smpi_mpi_request_t*); -void smpi_irecv(smpi_mpi_request_t*); -void smpi_barrier(smpi_mpi_communicator_t *comm); -void smpi_wait(smpi_mpi_request_t *request, smpi_mpi_status_t *status); -void smpi_wait_all(int count, smpi_mpi_request_t **requests, smpi_mpi_status_t *statuses); -void smpi_wait_all_nostatus(int count, smpi_mpi_request_t **requests); -void smpi_bench_begin(); -void smpi_bench_end(); -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); +extern int smpi_simulated_main(int argc, char **argv); unsigned int smpi_sleep(unsigned int); void smpi_exit(int); diff --git a/src/smpi/sample/first.c b/src/smpi/sample/first.c index d78aeac026..e37fe80cd7 100644 --- a/src/smpi/sample/first.c +++ b/src/smpi/sample/first.c @@ -1,56 +1,30 @@ -/* A first simple SPMD example program using MPI */ +#include +#include -/* The program consists of on receiver process and N-1 sender */ -/* processes. The sender processes send a message consisting */ -/* of their process identifier (id) and the total number of */ -/* processes (ntasks) to the receiver. The receiver process */ -/* prints out the values it receives in the messeges from the */ -/* senders. */ +int main(int argc, char *argv[]) +{ + int rank, size, err; -/* Compile the program with 'mpicc first.c -o first' */ -/* To run the program, using four of the computers specified in */ -/* your hostfile, do 'mpirun -machinefile hostfile -np 4 first */ + err = MPI_Init(&argc, &argv); /* Initialize MPI */ + if (err != MPI_SUCCESS) { + printf("MPI initialization failed!\n"); + exit(1); + } -#include -#include -main(int argc, char *argv[]) { - const int tag = 42; /* Message tag */ - int id, ntasks, source_id, dest_id, err, i; - MPI_Status status; - int msg[2]; /* Message array */ - - err = MPI_Init(&argc, &argv); /* Initialize MPI */ - if (err != MPI_SUCCESS) { - printf("MPI initialization failed!\n"); - exit(1); - } - err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); /* Get nr of tasks */ - err = MPI_Comm_rank(MPI_COMM_WORLD, &id); /* Get id of this process */ - if (ntasks < 2) { - printf("You have to use at least 2 processors to run this program\n"); - MPI_Finalize(); /* Quit if there is only one processor */ - exit(0); - } - - if (id == 0) { /* Process 0 (the receiver) does this */ - for (i=1; i +#include +main(int argc, char *argv[]) { + const int tag = 42; /* Message tag */ + int id, ntasks, source_id, dest_id, err, i; + MPI_Status status; + int msg[2]; /* Message array */ + + err = MPI_Init(&argc, &argv); /* Initialize MPI */ + if (err != MPI_SUCCESS) { + printf("MPI initialization failed!\n"); + exit(1); + } + err = MPI_Comm_size(MPI_COMM_WORLD, &ntasks); /* Get nr of tasks */ + err = MPI_Comm_rank(MPI_COMM_WORLD, &id); /* Get id of this process */ + if (ntasks < 2) { + printf("You have to use at least 2 processors to run this program\n"); + MPI_Finalize(); /* Quit if there is only one processor */ + exit(0); + } + + if (id == 0) { /* Process 0 (the receiver) does this */ + for (i=1; i> ${TMPSOURCE} - grep -q "smpi_main" ${TMPSOURCE} + grep -v "mpi.h" < ${SOURCE} | perl -pe 's/main/smpi_simulated_main/;' >> ${TMPSOURCE} + grep -q "smpi_simulated_main" ${TMPSOURCE} if [ $? -eq 0 ]; then cat >> ${TMPSOURCE} <