Browse Source

benchmarks

kaikas 7 years ago
parent
commit
a3161b9bb5

+ 3 - 0
CMakeLists.txt

@@ -13,6 +13,9 @@ add_executable(mycoagent3 test/mycoagent3.c)
 add_executable(myconetwork test/myconetwork.c)
 add_executable(myconetwork2 test/myconetwork2.c)
 add_executable(mycodaemon test/mycodaemon.c)
+add_executable(mycodaemon_nodaemon test/mycodaemon_nodaemon.c)
 add_executable(mycoindexer test/mycoindexer.c)
+add_executable(mycosend benchmarks/myco/send.c)
+add_executable(mycoreceive benchmarks/myco/receive.c)
 
 #target_link_libraries(mycoagent ${KIRO_LIBRARIES})

+ 6 - 1
benchmarks/mpi/send_recv.c

@@ -7,6 +7,11 @@
 int main (int argc, char *argv []) {
 	int message_size = atoi (argv [1]);
 	int message_count = atoi (argv [2]);
+  if (argc != 3) {
+        printf ("usage: send_recv <message-size> <message-count>\n");
+        return 1;
+  }
+
   unsigned long throughput;
   double megabits;
 
@@ -51,7 +56,7 @@ int main (int argc, char *argv []) {
 
   	
   	printf("message size: %d [B]\n", message_size);
-  	printf("message count: %d [B]\n", message_count);
+  	printf("message count: %d\n", message_count);
   	printf("mean throughput: %d [msg/s]\n", (int)throughput);
   	printf("mean throughput: %.3f [Mb/s]\n", (double)megabits);
 

+ 40 - 0
benchmarks/myco/receive.c

@@ -0,0 +1,40 @@
+/*  
+ * mycoagent.c
+ *
+ * This is an example agent that showcases the use of mycorrhiza.
+ */
+
+#include <time.h>
+#include "../../src/myco-agent.c"
+
+int main (int argc, char *argv []) {
+    if (argc != 2) {
+        printf ("usage: receive <message-size>\n");
+        return 1;
+    }
+
+
+    char *agent_name = "DOMAIN1_MYAGENT2";
+    int agent_message_queue_id;
+    agent_message_queue_id = myco_agent_register(agent_name);
+
+    char *resource_name = "RESOURCE";
+    int resource_size = atoi (argv [1]);
+    void *resource_pointer = myco_agent_register_resource(agent_message_queue_id, agent_name, resource_name, RESOURCE_TRANSACTIONAL, getpid(), resource_size);
+
+    // Put some random numbers into RESOURCE
+    int i;
+    srand(time(NULL));
+    for (i=0; i < resource_size/sizeof(int); i++) {
+        ((int *)resource_pointer)[i] = rand();
+    }
+
+    // Sleep, so the showcase program can request RESOURCE
+    printf("Wating for data to be requested.\n");
+    sleep(30);
+
+    // At the end of its runtime the agent unregisters with the agent.
+    myco_agent_unregister(agent_name, agent_message_queue_id);
+
+    return EXIT_SUCCESS;
+}

+ 58 - 0
benchmarks/myco/send.c

@@ -0,0 +1,58 @@
+/*  
+ * mycoagent.c
+ *
+ * This is an example agent that showcases the use of mycorrhiza.
+ */
+
+#include <time.h>
+#include "../../src/myco-agent.c"
+
+int main (int argc, char *argv []) {
+   	int message_count = atoi (argv [1]);
+
+    unsigned long throughput;
+    double megabits;
+
+    if (argc != 2) {
+      printf ("usage: send_recv <message-count>\n");
+      return 1;
+    }
+  
+    char *agent_name = "DOMAIN1_MYAGENT";
+    int agent_message_queue_id = myco_agent_register(agent_name);
+
+    struct resource myresource;
+    myresource = myco_agent_read_remote_resource(agent_message_queue_id, "RESOURCE");
+    if (myresource.size != -1) {
+        printf("The first integer of RESOURCE is: %d\n", *((int*)myresource.pointer));
+    }
+
+    clock_t start, end;
+    long double elapsed;
+    start = clock();
+
+  	for (int i = 0; i != message_count; i++) {
+      myco_agent_write_remote_resource(agent_message_queue_id, "RESOURCE", myresource.pointer, myresource.size, 1);
+    }
+
+  	end = clock();
+
+    elapsed = end - start;
+    if (elapsed == 0)
+        elapsed = 1;
+  	
+  	throughput = (unsigned long)
+        ((double) message_count / (double) elapsed * 1000000);
+    megabits = ((double) throughput * myresource.size * 8) / 1000000;
+
+  	
+  	printf("message size: %d [B]\n", myresource.size);
+  	printf("message count: %d\n", message_count);
+  	printf("mean throughput: %d [msg/s]\n", (int)throughput);
+  	printf("mean throughput: %.3f [Mb/s]\n", (double)megabits);
+
+    myco_agent_unregister_resource(agent_message_queue_id, "RESOURCE");
+    myco_agent_unregister(agent_name, agent_message_queue_id);
+
+    return EXIT_SUCCESS;
+}

+ 1 - 1
src/myco-agent.c

@@ -17,7 +17,7 @@
 #include "../src/myco-memory.c"
 #include "myco-modules.h"
 
-#define DEBUG 1
+#define DEBUG 0
 
 int myco_agent_register(const char *agent_name) {
     int agent_message_queue_id;

+ 7 - 3
src/myco-daemon.c

@@ -17,7 +17,7 @@
 #include "../src/myco-memory.c"
 #include "../src/myco-modules.h"
 
-#define DEBUG 1
+#define DEBUG 0
 
 myco_agent *first_agent = NULL;
 myco_resource *first_resource = NULL;
@@ -284,8 +284,10 @@ int myco_daemon_unregister_resource(message msg) {
 int myco_daemon_request_resource(message msg) {
 	myco_resource *current_resource;
 
+  // TODO: Uncommented for performance tests...
+  current_resource = myco_daemon_find_resource(msg.resource_name);
 	// Check if resource exists on this node
-	if ((current_resource = myco_daemon_find_resource(msg.resource_name)) != NULL) {
+	/*if ((current_resource = myco_daemon_find_resource(msg.resource_name)) != NULL) {
 		// Check if agent that requests already owns the resource
 		if (strcmp(current_resource->agent, msg.agent_name) == 0) {
 			sprintf(msg.message, "ERROR: resource %s already belongs to agent %s\n", msg.resource_name, msg.agent_name);
@@ -298,6 +300,7 @@ int myco_daemon_request_resource(message msg) {
 			myco_send(msg.agent_message_queue_id, msg);
 			return -1;
 		}
+*/
 	
 		// Check if resource resides on same node
 		// printf("\n The adress is: %s\n", inet_ntoa(*(struct in_addr *)&current_resource->node_ip));
@@ -321,7 +324,7 @@ int myco_daemon_request_resource(message msg) {
 			fprintf(stderr, "ERROR: myco_daemon_request: %s\n", strerror(errno));
 			return -1;
 		}
-	} else {
+	/*} else {
 		// Handle case where resource is on another node
 		// TODO: Request Resource information from indexer
 
@@ -335,6 +338,7 @@ int myco_daemon_request_resource(message msg) {
 			return -1;
 		}
 	}
+  */
 
 	return 0;
 }

+ 1 - 0
src/myco-ipc.c

@@ -16,6 +16,7 @@
 
 #include "myco-ipc.h"
 
+
 int myco_error(char *error_message, int message_queue_id) {
     fprintf(stderr, "FATAL ERROR in ");
     fprintf(stderr, error_message);

+ 1 - 0
src/myco-ipc.h

@@ -27,6 +27,7 @@
 
 #include <stdlib.h>
 #include <signal.h>
+#define _GNU_SOURCE
 #include <sys/uio.h>
 #include <sys/types.h>
 #include <sys/ipc.h>

+ 1 - 1
test/mycodaemon.c

@@ -70,7 +70,7 @@ int main() {
 
     syslog(LOG_NOTICE, "mycodaemon started.");
 
-    if (myco_daemon_start(getpid(), "192.168.0.35", "192.168.0.10") == -1) {
+    if (myco_daemon_start(getpid(), "127.0.0.1", "127.0.0.1") == -1) {
         return EXIT_FAILURE;
     }
 

+ 22 - 0
test/mycodaemon_nodaemon.c

@@ -0,0 +1,22 @@
+/*
+ *  mycodaemon.c
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <syslog.h>
+
+#include "../src/myco-daemon.c"
+
+int main() {
+    if (myco_daemon_start(getpid(), "127.0.0.1", "127.0.0.1") == -1) {
+        return EXIT_FAILURE;
+    }
+
+    return EXIT_SUCCESS;
+
+}