A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Stupid bug
[simgrid.git]
/
examples
/
gras
/
all2all
/
all2all.c
diff --git
a/examples/gras/all2all/all2all.c
b/examples/gras/all2all/all2all.c
index
fadca1c
..
5c029da
100644
(file)
--- a/
examples/gras/all2all/all2all.c
+++ b/
examples/gras/all2all/all2all.c
@@
-28,7
+28,7
@@
int receiver (int argc,char *argv[]) {
int myport; /* port on which I receive stuff */
int todo; /* amount of messages I should get */
int myport; /* port on which I receive stuff */
int todo; /* amount of messages I should get */
-
int
data; /* message content */
+
char *
data; /* message content */
gras_socket_t mysock; /* socket on which other people contact me */
gras_socket_t expeditor; /* to notice who wrote me */
gras_socket_t mysock; /* socket on which other people contact me */
gras_socket_t expeditor; /* to notice who wrote me */
@@
-44,7
+44,7
@@
int receiver (int argc,char *argv[]) {
mysock = gras_socket_server(myport);
/* Register the known messages */
mysock = gras_socket_server(myport);
/* Register the known messages */
- gras_msgtype_declare("data", gras_datadesc_by_name("
int
"));
+ gras_msgtype_declare("data", gras_datadesc_by_name("
string
"));
/* Get the data */
/* Get the data */
@@
-58,16
+58,15
@@
int receiver (int argc,char *argv[]) {
&data);
todo--;
&data);
todo--;
- INFO4("Got Data(%d) from %s:%d (still %d to go)",
- data,
+ INFO3("Got Data from %s:%d (still %d to go)",
gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
todo);
}
gras_socket_peer_name(expeditor), gras_socket_peer_port(expeditor),
todo);
}
-
+
/* Free the allocated resources, and shut GRAS down */
gras_socket_close(mysock);
/* Free the allocated resources, and shut GRAS down */
gras_socket_close(mysock);
-
+
gras_exit();
return 0;
} /* end_of_receiver */
gras_exit();
return 0;
} /* end_of_receiver */
@@
-79,45
+78,52
@@
int receiver (int argc,char *argv[]) {
int sender (int argc,char *argv[]) {
int i; /* iterator */
int sender (int argc,char *argv[]) {
int i; /* iterator */
-
int
data; /* data exchanged */
-
- xbt_
host
_t h; /* iterator */
+
char *
data; /* data exchanged */
+ int datasize; /* size of message */
+ xbt_
peer
_t h; /* iterator */
gras_socket_t peer; /* socket to node */
gras_socket_t peer; /* socket to node */
+
- /* xbt_dynar for
host
s */
- xbt_dynar_t
hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host
_free_voidp);
+ /* xbt_dynar for
peer
s */
+ xbt_dynar_t
peers = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer
_free_voidp);
/* Init the GRAS infrastructure and declare my globals */
gras_init(&argc,argv);
/* Get the node location from argc/argv */
/* Init the GRAS infrastructure and declare my globals */
gras_init(&argc,argv);
/* Get the node location from argc/argv */
- for (i=
2; i<argc
; i++){
- xbt_
host_t host = xbt_host_new(argv[i],atoi(argv[1])
);
- xbt_dynar_push(
hosts,&host
);
+ for (i=
1; i<argc-1
; i++){
+ xbt_
peer_t peer = xbt_peer_from_string(argv[i]
);
+ xbt_dynar_push(
peers,&peer
);
}
}
+
+ datasize=atoi(argv[argc-1]);
+
+ data=(char *) malloc(datasize+1); // allocation of datasize octets
+ memset(data, 32, datasize);
+ data[datasize] = '\0';
INFO0("Launch current node");
/* Register the known messages */
INFO0("Launch current node");
/* Register the known messages */
- gras_msgtype_declare("data", gras_datadesc_by_name("int"));
+ gras_msgtype_declare("data", gras_datadesc_by_name("string"));
+
/* Wait for receivers to startup */
gras_os_sleep(1);
/* write 'em */
/* Wait for receivers to startup */
gras_os_sleep(1);
/* write 'em */
- data =1000;
- xbt_dynar_foreach(hosts,i,h) {
+ xbt_dynar_foreach(peers,i,h) {
peer = gras_socket_client(h->name,h->port);
gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
peer = gras_socket_client(h->name,h->port);
gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
- INFO
3(" Sent Data (%d)
from %s to %s",
-
data,
gras_os_myname(),h->name);
+ INFO
2(" Sent Data
from %s to %s",
+ gras_os_myname(),h->name);
gras_socket_close(peer);
}
/* Free the allocated resources, and shut GRAS down */
gras_socket_close(peer);
}
/* Free the allocated resources, and shut GRAS down */
- xbt_dynar_free(&
host
s);
+ xbt_dynar_free(&
peer
s);
gras_exit();
return 0;
gras_exit();
return 0;