Author: wozniak
Date: 2009-05-22 14:19:35 -0500 (Fri, 22 May 2009)
New Revision: 536
Modified:
trunk/code/Makefile.in
trunk/code/src/adts/itable.c
trunk/code/src/gum/gum.gs
trunk/code/src/gum/module.mk.in
trunk/code/src/include/disksim.h
trunk/code/src/include/gum.gsh
trunk/code/test/adts/module.mk.in
trunk/code/test/adts/test02.c
trunk/code/test/gum/module.mk.in
trunk/code/test/gum/test03.gs
Log:
Basic call/response paradigm works (test/gum/test03).
Modified: trunk/code/Makefile.in
===================================================================
--- trunk/code/Makefile.in 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/Makefile.in 2009-05-22 19:19:35 UTC (rev 536)
@@ -11,6 +11,7 @@
# INPUT CONTROL VARIABLES
# D : if 1, turn on debugging output in CMPI programs
# M : if 1, turn on malloc debugging output
+# P : if 1, turn on GSL pretty output
# T : if 1, turn on MPE printf debugging
# V : if 1, turn on normal make output
@@ -85,22 +86,25 @@
# which case QUIET_COMPILE will _not_ be defined. Further allow
# silence to be overriden with "make V=1".
QUIET_COMPILE = @QUIET_COMPILE@
-ifeq ($(V),1)
- QUIET_COMPILE = 0
-endif
ifeq ($(D),1)
DEBUG = 1
else
DEBUG = 0
endif
-ifeq ($(T),1)
- MPE =-mpe=mpitrace
-endif
ifeq ($(M),1)
DEBUG_MALLOC = 1
else
DEBUG_MALLOC = 0
endif
+ifeq ($(P),1)
+ GSLPRETTY = --pretty
+endif
+ifeq ($(T),1)
+ MPE =-mpe=mpitrace
+endif
+ifeq ($(V),1)
+ QUIET_COMPILE = 0
+endif
TEST_OPTIONS :=
ifeq ($(TEST01),1)
@@ -190,6 +194,7 @@
# turn on large file support by default
CFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
GSLFLAGS = $(CFLAGS) -Wno-unused-label -Wno-unused-variable
+GSLFLAGS += -Wno-parentheses $(GSLPRETTY)
# include current directory (for grayskull-config.h)
IFLAGS += -I .
# include gossip directory
Modified: trunk/code/src/adts/itable.c
===================================================================
--- trunk/code/src/adts/itable.c 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/src/adts/itable.c 2009-05-22 19:19:35 UTC (rev 536)
@@ -52,13 +52,10 @@
*/
bool
-itable_add(struct itable *table, int key, void* data)
+itable_add(struct itable* table, int key, void* data)
{
- // NOTE_F;
- int index = 0;
-
- index = hash_int(key, table->capacity);
-
+ int index = hash_int(key, table->capacity);
+
struct ilist_item* new_item =
ilist_add(table->array[index], key, data);
@@ -73,7 +70,7 @@
void*
itable_search(struct itable* table, int key)
{
- int index = hash_int(key, table->size);
+ int index = hash_int(key, table->capacity);
return ilist_search(table->array[index], key);
}
Modified: trunk/code/src/gum/gum.gs
===================================================================
--- trunk/code/src/gum/gum.gs 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/src/gum/gum.gs 2009-05-22 19:19:35 UTC (rev 536)
@@ -14,13 +14,13 @@
gum_running = true;
gum_unique_id = 0;
- gum_map = itable_create();
+ gum_map = itable_create(20);
return 0;
}
int
-gum_unique_id_create()
+gum_unique_id_create(void)
{
return ++gum_unique_id;
}
@@ -28,16 +28,20 @@
gum_proc_idx
gum_procedure_create(char* name)
{
+ gum_proc_idx result;
if (strcmp(name, "RESPONSE") == 0)
- return -1;
- return (gum_proc_idx) SHA1_mod(name);
+ result = (gum_proc_idx) -1;
+ else
+ result = (gum_proc_idx) SHA1_mod(name);
+ return result;
}
gum_msg*
-gum_msg_create()
+gum_msg_create(void)
{
gum_msg* msg = malloc(sizeof(gum_msg));
- msg->type = NULL;
+ msg->type = (MPI_Datatype) NULL;
+ return msg;
}
void
@@ -52,43 +56,69 @@
void
gum_pack(gum_msg* msg)
{
- int lengths = {sizeof(msg->procedure), sizeof(int), msg->length};
+ int lengths[3] = {sizeof(msg->procedure), sizeof(int), msg->length};
+ printf("gum_pack()...\n");
MPI_Datatype type[3] = {MPI_INT, MPI_INT, MPI_CHAR};
MPI_Datatype new_type;
- MPI_Aint address[2];
- MPI_Get_address(&msg->procedure, &(address[0]));
- MPI_Get_address(&msg->length, &(address[1]));
- MPI_Get_address(msg->data, &(address[2]));
+ MPI_Aint address[3];
+ MPI_Get_address(&(msg->procedure), &(address[0]));
+ MPI_Get_address(&(msg->length), &(address[1]));
+ MPI_Get_address(msg->data, &(address[2]));
+
+ printf("length[%i]: %i\n", 0, lengths[0]);
+ printf("length[%i]: %i\n", 1, lengths[1]);
+ printf("length[%i]: %i\n", 2, lengths[2]);
+
MPI_Type_create_struct(3, lengths, address, type, &new_type);
MPI_Type_commit(&new_type);
- msg->type = new_type;
+ msg->type = new_type;
}
void
gum_register(gum_proc_idx idx, gum_proc procedure)
{
+ printf("register: %i %p\n", idx, procedure);
itable_add(gum_map, idx, procedure);
}
+/**
+ @param target IN Node from which to recv.
+ @param idx OUT Procedure index.
+ @param length OUT Length of data.
+ @param data OUT Received data.
+ */
__blocking int
gum_recv(gum_node target, gum_proc_idx* idx, int* length, char* data)
{
int rank;
MPI_Status status;
- int lengths = {sizeof(msg->procedure), sizeof(int), msg->length};
- MPI_Datatype type[3] = {MPI_INT, MPI_INT, MPI_CHAR};
+ int size[3];
+ MPI_Datatype type[3];
MPI_Datatype new_type;
MPI_Aint address[2];
-
- MPI_Get_address(idx, &(address[0]));
- MPI_Get_address(length, &(address[1]));
- MPI_Get_address(data, &(address[2]));
- MPI_Type_create_struct(3, lengths, address, type, &new_type);
+ int tmp_idx;
+ int tmp_length;
+ char tmp_data[GUM_MSG_MAX];
+
+ type[0] = MPI_INT;
+ size[0] = sizeof(gum_proc_idx);
+ type[1] = MPI_INT;
+ size[1] = sizeof(int);
+ type[2] = MPI_CHAR;
+ size[2] = GUM_MSG_MAX;
+
+ MPI_Get_address(&tmp_idx, &(address[0]));
+ MPI_Get_address(&tmp_length, &(address[1]));
+ MPI_Get_address(data, &(address[2]));
+ MPI_Type_create_struct(3, size, address, type, &new_type);
MPI_Type_commit(&new_type);
error = gs_mpi_recv(MPI_BOTTOM, 1, new_type, target.rank,
10, target.comm, &status);
+ *idx = tmp_idx;
+ *length = tmp_length;
+
MPI_Type_free(&new_type);
return status.MPI_SOURCE;
@@ -99,19 +129,28 @@
{
int mpi_rank;
- gum_proc_idx response_idx;
- int response_length;
+ gum_msg* result;
+ // gum_proc_idx response_idx;
+ // int response_length;
char response_data[GUM_MSG_MAX];
+
+ result = gum_msg_create();
+ result->data = malloc(GUM_MSG_MAX);
MPI_Comm_rank(target.comm, &mpi_rank);
error = gs_mpi_send(MPI_BOTTOM, 1, msg->type, target.rank,
10, target.comm);
- gum_recv(target, &response_idx, &response_length, response_data);
+ gum_recv(target, &(result->procedure), &(result->length),
+ // result->data);
+ response_data);
printf("received response msg: %s size: %i\n",
- response_data, response_length);
+ response_data, result->length);
+
+ strcpy(result->data, response_data);
+ *response = result;
return 0;
}
@@ -121,30 +160,43 @@
{
int caller;
+ gum_proc_idx idx;
+ int length;
+ char data[GUM_MSG_MAX];
+ char result[32];
+
+ gum_msg call;
+ gum_msg response;
+ gum_node target;
+ gum_proc procedure;
+
printf("gum_response()...\n");
- gum_proc_idx response_idx;
- int response_length;
- char response_data[GUM_MSG_MAX];
-
- gum_node target;
target.rank = MPI_ANY_SOURCE;
target.comm = MPI_COMM_WORLD;
- int caller =
- gum_recv(target, &response_idx, &response_length, response_data);
+ caller = gum_recv(target, &idx, &length, data);
- printf("called by: %i msg: %s size: %i\n", source,
- response_data, response_length);
+ printf("called by: %i msg: %s size: %i\n", caller, data, length);
- if (strcmp(buffer, "quit") == 0)
+ call.source = caller;
+ call.length = length;
+ call.data = malloc(GUM_MSG_MAX);
+
+ procedure = itable_search(gum_map, idx);
+
+ printf("procedure: %i %p\n", idx, procedure);
+
+ procedure(&call, &response);
+
+ if (strcmp(data, "quit") == 0)
gum_running = false;
- gum_msg response;
- gum_init("RESPONSE", "", 1, &response);
- gum_pack(response);
+ strcpy(result, "OKEYDOKEY");
+ gum_msg_init("RESPONSE", result, strlen(result)+1, &response);
+ gum_pack(&response);
- error = gs_mpi_send(MPI_BOTTOM, 1, msg->type, caller,
+ error = gs_mpi_send(MPI_BOTTOM, 1, response.type, caller,
10, MPI_COMM_WORLD);
return 0;
Modified: trunk/code/src/gum/module.mk.in
===================================================================
--- trunk/code/src/gum/module.mk.in 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/src/gum/module.mk.in 2009-05-22 19:19:35 UTC (rev 536)
@@ -6,5 +6,6 @@
GUM_SRC += src/gum/gum.gs
src/gum/gum.o: src/gum/gum.gs src/include/gum.gsh $(GSCC)
- $(GSCC) $(GSLFLAGS) $(GSINCLUDES) $(<) --outfile $(@)
+ $(Q) " GSCC $(@)"
+ $(E)$(GSCC) $(GSLFLAGS) $(GSINCLUDES) $(<) --outfile $(@)
Modified: trunk/code/src/include/disksim.h
===================================================================
--- trunk/code/src/include/disksim.h 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/src/include/disksim.h 2009-05-22 19:19:35 UTC (rev 536)
@@ -19,8 +19,8 @@
//// Public API:
void disksim_init(void);
-void cmpi_disk_storepair(char* key, char* value);
-void cmpi_disk_loadpair(char* key, char** data);
+void cmpi_disk_storepair(char* key, char* value, int length);
+int cmpi_disk_loadpair(char* key, char** data);
void emulate_read(long block, char** data, int size);
void emulate_write(long block, char* data, int size);
Modified: trunk/code/src/include/gum.gsh
===================================================================
--- trunk/code/src/include/gum.gsh 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/src/include/gum.gsh 2009-05-22 19:19:35 UTC (rev 536)
@@ -3,12 +3,14 @@
GUM: Grayskull Underlying Messages
*/
-#include <stdbool.h>
+#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <include/gs.h>
#include <mpi/gs-mpi.gsh>
+#include <hashtable.h>
#include <itable.h>
typedef int gum_proc_idx;
@@ -16,17 +18,19 @@
extern bool gum_running;
extern int gum_unique_id;
-#define GUM_MSG_MAX 1024
+#define GUM_MSG_MAX (1*1024)
typedef struct
{
+ int unique;
gum_proc_idx procedure;
int source;
int length;
char* data;
+ MPI_Datatype type;
} gum_msg;
-typedef void (*gum_proc)(gum_msg*,gum_msg**);
+typedef void (*gum_proc)(gum_msg*,gum_msg*);
typedef struct
{
@@ -36,10 +40,14 @@
int gum_init(void);
+gum_msg* gum_msg_create(void);
+
+void gum_msg_init(char* name, char* data, int length, gum_msg* msg);
+
void gum_register(gum_proc_idx idx, gum_proc procedure);
gum_proc_idx gum_procedure_create(char* name);
-int gum_pack(gum_proc_idx idx, char* args, gum_msg** msg);
+void gum_pack(gum_msg* msg);
__blocking int gum_call(gum_node target,
gum_msg* msg, gum_msg** response);
Modified: trunk/code/test/adts/module.mk.in
===================================================================
--- trunk/code/test/adts/module.mk.in 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/test/adts/module.mk.in 2009-05-22 19:19:35 UTC (rev 536)
@@ -7,6 +7,6 @@
#TEST_PROGS += $(patsubst %.c, %.x, $(TEST_SRC))
#TEST_OUTPUT += $(patsubst %.c, %.out, $(TEST_SRC))
-test/adts/test%.x: test/adts/test%.o $(CMPI)
+test/adts/test%.x: test/adts/test%.o src/mpi_tools/mpi_tools.o
$(Q) " LINK $(@) "
- $(E)$(MPICC) $(MPE) $(<) $(CMPI) $(LIBS) -o $(@)
+ $(E)$(MPICC) $(MPE) $(<) $(LIBS) src/mpi_tools/mpi_tools.o t-o $(@)
Modified: trunk/code/test/adts/test02.c
===================================================================
--- trunk/code/test/adts/test02.c 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/test/adts/test02.c 2009-05-22 19:19:35 UTC (rev 536)
@@ -172,7 +172,7 @@
// lru_table_dump("%i", table);
- dmalloc_shutdown();
+ // dmalloc_shutdown();
MPI_Finalize();
return 0;
Modified: trunk/code/test/gum/module.mk.in
===================================================================
--- trunk/code/test/gum/module.mk.in 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/test/gum/module.mk.in 2009-05-22 19:19:35 UTC (rev 536)
@@ -22,8 +22,12 @@
test/gum/test02.x: test/gum/test02.o src/gum/gum.o
$(MPICC) -rdynamic $(<) src/gum/gum.o -L src/gsl/lib -l gs -l gstest -o $(@)
-test/gum/test03.o: test/gum/test03.gs
- $(GSCC) $(GSLFLAGS) --dontclean $(GSINCLUDES) --compiler $(MPICC) --outfile $(@) $(<)
+ADTS = src/adts/itable.o src/adts/hashtable.o src/adts/ilist.o src/adts/klist.o
-test/gum/test03.x: test/gum/test03.o src/gum/gum.o
- $(MPICC) -rdynamic $(<) src/gum/gum.o -L src/gsl/lib -l gs -l gstest -o $(@)
+test/gum/test03.o: test/gum/test03.gs $(ADTS)
+ $(Q) " GSCC $(@)"
+ $(E)$(GSCC) $(GSLFLAGS) --dontclean $(GSINCLUDES) --compiler $(MPICC) --outfile $(@) $(<)
+
+test/gum/test03.x: test/gum/test03.o src/gum/gum.o $(ADTS)
+ $(Q) " MPICC $(@)"
+ $(E)$(MPICC) -rdynamic $(<) src/gum/gum.o $(ADTS) -L src/gsl/lib -l gs -l gstest -l crypto -o $(@)
Modified: trunk/code/test/gum/test03.gs
===================================================================
--- trunk/code/test/gum/test03.gs 2009-05-22 18:02:47 UTC (rev 535)
+++ trunk/code/test/gum/test03.gs 2009-05-22 19:19:35 UTC (rev 536)
@@ -16,57 +16,66 @@
int mpi_size;
int mpi_rank;
-static void done_callback(void *user_ptr, int ret)
+static void
+done_callback(void *user_ptr, int ret)
{
done = 1;
}
-void handle_blah(gum_msg* msg, gum_msg** result)
+void
+handle_blah(gum_msg* msg, gum_msg* result)
{
printf("got: %s from: %i\n", msg->data, msg->source);
- *result = malloc(sizeof(gum_msg));
- *result->data = strdup("OK");
- *result->length = strlen(result->data);
+ result->data = strdup("OK");
+ result->length = strlen(result->data);
}
-void handle_quit(gum_msg* msg, gum_msg** result)
+void
+handle_quit(gum_msg* msg, gum_msg* result)
{
printf("got: %s from: %i\n", msg->data, msg->source);
gum_running = false;
}
-static __blocking int client(void)
+static __blocking int
+client(void)
{
- target.rank = 0;
- target.comm = MPI_COMM_WORLD;
gum_msg* msg = gum_msg_create();
gum_msg* result;
+ gum_node target;
- char* args = "args1";
+ char args[32];
+ strcpy(args, "args1");
gum_msg_init("blah", args, strlen(args)+1, msg);
- gum_pack();
+ gum_pack(msg);
printf("calling...\n");
+ target.rank = 0;
+ target.comm = MPI_COMM_WORLD;
gum_call(target, msg, &result);
+ printf("called\n");
printf("called blah got: %s\n", result->data);
- free(msg);
- free(result);
+ // free(msg);
+ // free(result);
- /*
- gum_procedure p = gum_procedure_create("quit");
- gum_pack(p, "", &msg);
+ strcpy(args, "now");
+ gum_msg_init("quit", args, strlen(args)+1, msg);
+ gum_pack(msg);
gum_call(target, msg, &result);
- printf("called blah got: %s\n", result->data);
- free(msg);
- free(result);
- */
+ printf("called quit got: %s\n", result->data);
+ // free(msg);
+ // free(result);
+
+ return 0;
}
-static __blocking int service(void)
+static __blocking int
+service(void)
{
while (gum_running)
{
+ printf("register\n");
gum_register(gum_procedure_create("blah"), handle_blah);
gum_register(gum_procedure_create("quit"), handle_quit);
gum_response();
@@ -75,7 +84,8 @@
return 0;
}
-static __blocking int bootstrap(void)
+static __blocking int
+bootstrap(void)
{
MPI_Status status;
gum_node target;
@@ -86,7 +96,7 @@
}
else
{
- calls();
+ client();
}
return 0;