[C-MPI-commits] SF.net SVN: c-mpi:[165] src
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2011-04-14 14:30:17
|
Revision: 165
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=165&view=rev
Author: jmwozniak
Date: 2011-04-14 14:30:08 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
Code cleanups, more notes...
Modified Paths:
--------------
Makefile.in
include/kda-2.h
include/mpirpc.h
src/kda-2/kademlia.c
src/mpi_tools/mpi_tools.c
src/mpirpc/module.mk.in
src/mpirpc/mpirpc.c
Modified: Makefile.in
===================================================================
--- Makefile.in 2011-03-03 23:13:44 UTC (rev 164)
+++ Makefile.in 2011-04-14 14:30:08 UTC (rev 165)
@@ -109,11 +109,11 @@
endif
ifeq ($(QUIET_COMPILE),1)
- # say a one-line description of the action, do not echo the command
+ # Prints a short description of the action, does not show command
Q=@echo
E=@
else
- # do not say the short Q lines, but do echo the entire command
+ # Just echo the entire command
Q=@echo >/dev/null
E=
endif
@@ -292,7 +292,7 @@
$(E)echo CFLAGS: $(CFLAGS)
$(E)echo IFLAGS: $(IFLAGS)
$(E)echo LIBS: $(LIBS)
- $(E)echo DEPENDS: $(DEPENDS)
+ $(E)echo CMPI_DEPS: $(CMPI_DEPS)
$(E)echo OPENSSL: $(OPENSSL_LOCATION)
$(E)echo GOSSIP_OBJS: $(GOSSIP_OBJS)
$(E)echo ADTS_OBJS: $(ADTS_OBJS)
@@ -351,8 +351,11 @@
CMPI_OBJS := $(TABLE_OBJS) $(MPIRPC_OBJS) $(CMPI_OBJS)
# $(DISKSIM_OBJS)
-CMPI_DEPS := $(patsubst %.o,%.d,$(CMPI_OBJS))
+MPIRPC_DEPS := $(patsubst %.o,%.d,$(MPIRPC_OBJS))
+CMPI_DEPS := $(patsubst %.o,%.d,$(CMPI_OBJS))
+deps: $(CMPI_DEPS)
+
################################################################
# Test cases
# Test rules are heavily based on the definitions above
@@ -397,7 +400,8 @@
# Grab any CFLAGS defined by the make stub for a particular file, and
# for the directory in which the source resides.
# modcflags = $(MODCFLAGS_$(call canonname,$(1))) \
-# $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1))) # -I$(srcdir)/$(call dirname,$(1))
+# $(MODCFLAGS_$(patsubst $(srcdir)/%,%,$(1)))
+# -I$(srcdir)/$(call dirname,$(1))
# modldflags = $(MODLDFLAGS_$(call canonname,$(1))) \
# $(MODLDFLAGS_$(patsubst $(srcdir)/%,%,$(1)))
@@ -548,9 +552,9 @@
# NOTE: we wrap this in ifneq's in order to prevent the
# dependencies from being generated for special targets that don't
# require them
-ifeq (,$(filter clean distclean dist docs cscope tags nodep,$(MAKECMDGOALS)))
--include $(DEPENDS)
-endif
+#ifeq (,$(filter clean distclean dist docs cscope tags nodep,$(MAKECMDGOALS)))
+ include $(CMPI_DEPS)
+#endif
# add this as a make goal to disable rebuilding dependencies
.PHONY: nodep clean
@@ -571,9 +575,9 @@
$(Q) " SPLINT splint.out"
$(E) splint $(SPLINTOPTS) $(IFLAGS) -I $(MPI)/include $(CMPI_SRC) > splint.out
-%.p: %.c
- $(Q) " CPP $@"
- $(E) cpp $(IFLAGS) -I $(MPI)/include $(<) > $(@) # || rm -v $(@)
+#%.p: %.c
+# $(Q) " CPP $@"
+# $(E) cpp $(IFLAGS) -I $(MPI)/include $(<) > $(@) # || rm -v $(@)
install:: all install_doc
install -d $(prefix)/include
Modified: include/kda-2.h
===================================================================
--- include/kda-2.h 2011-03-03 23:13:44 UTC (rev 164)
+++ include/kda-2.h 2011-04-14 14:30:08 UTC (rev 165)
@@ -144,114 +144,8 @@
MPIRPC* KDA_Store(KDA_Neighbor* neighbor, char* key, char* value, int length);
-/**
- Instruct a node to retrieve a value.
-*/
MPIRPC* KDA_Retrieve(KDA_Neighbor* neighbor, char* key);
-//// Convenience prototypes to keep functions in decent order...
-KDA_ID make_id(int salt);
-// void join(MPIRPC_Node* node);
-char* id_tostring(void);
-void listen_loop(void);
-void bootstrap(MPIRPC_Node node);
-KDA_Neighbor* random_neighbor(void);
-int KDA_Neighbor_table_size(void);
-//// Neighbor management...
-
-/**
- Add neighbor to the neighbor table.
- @return false iff n is already in the neighbor table.
-*/
-bool neighbor_add(KDA_Neighbor* neighbor);
-
-/**
- Add neighbor to the client list.
-*/
-void client_add(KDA_Neighbor* client);
-
-/**
- Find neighbor in buckets and set its comm.
-*/
-void neighbor_set_node(KDA_Neighbor* neighbor, MPIRPC_Node node);
-
-/**
- Translate a dummy neighbor that is set to MPI_COMM_NULL to
- a good one in a bucket.
- TODO: Speed this up with an index or something.
-*/
-KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
-
-/**
- Use node to connect to neighbor.
-*/
-KDA_Neighbor* check_neighbor(MPIRPC_Node node, KDA_Neighbor* neighbor);
-
-/**
- Add neighbor to the neighbor table.
- Use node to link to the neighbor.
-*/
-void connect_neighbor(MPIRPC_Node* node, KDA_Neighbor* neighbor);
-
-void dump_bucket_ids(void);
-char* bucket_ids_tostring(void);
-void dump_buckets(void);
-char* buckets_tostring(void);
-
-//// Handlers...
-
-/**
- Generate info string for debugging
-*/
-void handle_info(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_join(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-void handle_link(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-void handle_find_node(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_neighbor(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_ping(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_query_id(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_query_id_k(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_store(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_retrieve(MPIRPC_Node node, int unique, char* args,
- char* blob, int blob_length);
-void handle_shutdown(MPIRPC_Node caller, int unique, char* args,
- char* blob, int blob_length);
-
-/* SPECIFIC TO CONN TYPE
- void handle_accept(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
- void handle_connect(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
-*/
-
-// Synchronous methods...
-struct ilist* find_node(KDA_ID id);
-
-// Asynchronous methods and return services...
-void query_id(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id(KDA_Operation* op);
-void query_id_k(MPIRPC_Node node, int unique, KDA_ID id);
-void return_query_id_k(KDA_Operation* op);
-
-// RPCs...
-
-void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
-
-// Proceeds...
-void proceed_find(MPIRPC* rpc);
-void proceed_ping(MPIRPC* rpc);
-void proceed_link(MPIRPC* rpc);
-
-
-// void proceed_
-
#endif
Modified: include/mpirpc.h
===================================================================
--- include/mpirpc.h 2011-03-03 23:13:44 UTC (rev 164)
+++ include/mpirpc.h 2011-04-14 14:30:08 UTC (rev 165)
@@ -2,24 +2,8 @@
#ifndef MPIRPC_H
#define MPIRPC_H
-#define _XOPEN_SOURCE 500
-
-#include <stdbool.h>
-#include <sys/types.h>
-#include <unistd.h>
-
#include <cmpi-config.h>
-#include <list.h>
-#include <itable.h>
-#include <hashtable.h>
-
-#include <mpi_tools.h>
-
-extern int unique;
-
-extern useconds_t snooze_max;
-
#define MPIRPC_MAX_NAME 128
#define MPIRPC_MAX_ARGS 256
#define MPIRPC_PROCEED_NULL ((void (*)(MPIRPC*)) 1)
Modified: src/kda-2/kademlia.c
===================================================================
--- src/kda-2/kademlia.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/kda-2/kademlia.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -3,6 +3,11 @@
#include <strings.h>
+/**
+ Uniquify KDA_Operations
+ */
+static int unique = 0;
+
KDA_ID id;
K_BUCKET k_bucket[KDA_SPACE_SIZE];
@@ -53,6 +58,101 @@
*/
int unique_client = 1;
+/**
+ Use node to connect to neighbor.
+*/
+KDA_Neighbor* check_neighbor(MPIRPC_Node node, KDA_Neighbor* neighbor);
+
+
+//// Neighbor management...
+
+/**
+ Add neighbor to the neighbor table.
+ @return false iff n is already in the neighbor table.
+*/
+bool neighbor_add(KDA_Neighbor* neighbor);
+
+/**
+ Add neighbor to the client list.
+*/
+void client_add(KDA_Neighbor* client);
+
+/**
+ Find neighbor in buckets and set its comm.
+*/
+void neighbor_set_node(KDA_Neighbor* neighbor, MPIRPC_Node node);
+
+/**
+ Translate a dummy neighbor that is set to MPI_COMM_NULL to
+ a good one in a bucket.
+ TODO: Speed this up with an index or something.
+*/
+KDA_Neighbor* neighbor_lookup(KDA_Neighbor* neighbor);
+
+void dump_bucket_ids(void);
+char* bucket_ids_tostring(void);
+void dump_buckets(void);
+char* buckets_tostring(void);
+
+static KDA_ID make_id(int salt);
+static char* id_tostring(void);
+static void listen_loop(void);
+static void bootstrap(MPIRPC_Node node);
+KDA_Neighbor* random_neighbor(void);
+
+int KDA_Neighbor_table_size(void);
+
+//// Handlers...
+
+/**
+ Generate info string for debugging
+*/
+void handle_info(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_join(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_link(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+void handle_find_node(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_neighbor(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_ping(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_query_id_k(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_store(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_retrieve(MPIRPC_Node node, int unique, char* args,
+ char* blob, int blob_length);
+void handle_shutdown(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length);
+
+/* SPECIFIC TO CONN TYPE
+ void handle_accept(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
+ void handle_connect(MPIRPC_Node* caller, int unique, char* args, char* blob, int blob_length);
+*/
+
+// Synchronous methods...
+struct ilist* find_node(KDA_ID id);
+
+// Asynchronous methods and return services...
+void query_id(MPIRPC_Node node, int unique, KDA_ID id);
+void return_query_id(KDA_Operation* op);
+void query_id_k(MPIRPC_Node node, int unique, KDA_ID id);
+void return_query_id_k(KDA_Operation* op);
+
+// RPCs...
+
+void rpc_find_node(KDA_Neighbor* neighbor, KDA_Operation* op);
+
+// Proceeds...
+void proceed_find(MPIRPC* rpc);
+void proceed_ping(MPIRPC* rpc);
+void proceed_link(MPIRPC* rpc);
+
void
KDA_Data(int alpha_in, int k_in)
{
@@ -371,7 +471,7 @@
NOTE_F;
KDA_Query* query = (KDA_Query*) malloc(sizeof(KDA_Query));
query->caller = caller;
- query->unique = unique;
+ query->unique = unique++;
query->service = service;
return query;
}
@@ -432,7 +532,8 @@
}
void
-handle_shutdown(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_shutdown(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
NOTE_F;
cmpi_quitting = true;
@@ -448,7 +549,8 @@
}
void
-handle_find_node(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_find_node(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
struct ilist_item* item;
NOTE_FS(args);
@@ -472,7 +574,8 @@
}
void
-handle_query_id(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_query_id(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
int object_id;
sscanf(args, "%X", &object_id);
@@ -498,7 +601,8 @@
}
void
-handle_query_id_k(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_query_id_k(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
int object_id;
sscanf(args, "%X", &object_id);
@@ -732,7 +836,7 @@
(KDA_Operation*) malloc(sizeof(KDA_Operation));
op->object_id = object_id;
- op->unique = ++unique;
+ op->unique = unique++;
op->name = name;
op->args = args;
op->k_closest = NULL;
@@ -858,7 +962,8 @@
No native method. Simply return.
*/
void
-handle_ping(MPIRPC_Node caller, int unique, char* args, char* blob, int blob_length)
+handle_ping(MPIRPC_Node caller, int unique, char* args,
+ char* blob, int blob_length)
{
MPIRPC_Null(caller, unique);
}
Modified: src/mpi_tools/mpi_tools.c
===================================================================
--- src/mpi_tools/mpi_tools.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpi_tools/mpi_tools.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -79,6 +79,10 @@
}
*/
+/**
+ Print possibly binary data with nice handling of newline, tab,
+ NULL characters, and misc. non-printing characters
+ */
void
fprintdata(FILE* file, char* tag, char* data, int length)
{
@@ -102,12 +106,19 @@
fprintf(file, "]");
}
+/**
+ Print possibly binary data with nice handling of newline, tab,
+ NULL characters, and misc. non-printing characters
+ */
void
printdata(char* tag, char* data, int length)
{
fprintdata(stdout, tag, data, length);
}
+/**
+ Print the bits of a binary number
+ */
void
printbinary(unsigned int number)
{
@@ -135,10 +146,10 @@
unsigned int
ilog2(unsigned int j)
{
- int r = 0;
+ unsigned int r = 0;
while (j >>= 1)
r++;
- return (unsigned int) r;
+ return r;
}
unsigned int
Modified: src/mpirpc/module.mk.in
===================================================================
--- src/mpirpc/module.mk.in 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpirpc/module.mk.in 2011-04-14 14:30:08 UTC (rev 165)
@@ -3,8 +3,8 @@
MPIRPC_SRC := $(DIR)/mpirpc.c
-MPIRPC_OBJS := $(patsubst %.c, %.o, $(MPIRPC_SRC))
-MPIRPC_OBJS += $(ADTS_OBJS)
+MPIRPC_OBJS := $(patsubst %.c, %.o, $(MPIRPC_SRC))
+MPIRPC_OBJS += $(ADTS_OBJS)
MPIRPC = lib/libmpirpc.a
Modified: src/mpirpc/mpirpc.c
===================================================================
--- src/mpirpc/mpirpc.c 2011-03-03 23:13:44 UTC (rev 164)
+++ src/mpirpc/mpirpc.c 2011-04-14 14:30:08 UTC (rev 165)
@@ -1,82 +1,87 @@
+#include <mpi_tools.h>
+
+#include <stdbool.h>
+#include <unistd.h>
+
+#include <itable.h>
+#include <hashtable.h>
+#include <list.h>
+
#include <mpirpc.h>
/**
- Functions MPIRPC_* may be exported at some point.
-*/
-
-/**
Counter to uniquify RPC calls.
*/
-int unique = 0;
+static int unique = 0;
/**
For MPIRPC_Check() : Irecv()...
*/
-MPI_Request check_request = MPI_REQUEST_NULL;
+static MPI_Request check_request = MPI_REQUEST_NULL;
/**
For MPIRPC_Check() : Irecv()...
*/
-int check_msg;
+static int check_msg;
-// Internal prototypes (just a convenience):
-void* MPIRPC_Remove(int index);
-void MPIRPC_Handle(int msg, MPIRPC_Node caller);
+// Internal prototypes:
+static void* MPIRPC_Remove(int index);
+static void MPIRPC_Handle(int msg, MPIRPC_Node caller);
/**
Sendable call control code.
*/
-int mpirpc_msg_call;
+static int mpirpc_msg_call;
/**
Sendable return control code.
*/
-int mpirpc_msg_return;
+static int mpirpc_msg_return;
/**
Sendable shutdown control code.
*/
-int mpirpc_msg_disconnect;
+static int mpirpc_msg_disconnect;
/**
Sendable OK control code.
*/
-int mpirpc_msg_ok;
+static int mpirpc_msg_ok;
/**
Sendable failure control code.
*/
-int mpirpc_msg_fail;
+static int mpirpc_msg_fail;
/**
Table of registered functions that may be called.
*/
-struct hashtable* portmap;
+static struct hashtable* portmap;
/**
Table of outstanding RPCs.
*/
-struct itable* rpctable;
+static struct itable* rpctable;
/**
Table of known channels.
*/
-struct list* channels;
+static struct list* channels;
/**
Return values to be garbage collected by MPIRPC_Check().
*/
-struct list* garbage_values;
+static struct list* garbage_values;
/**
Time in microseconds to snooze when MPIRPC_Check() finds nothing.
snooze() & reset_snooze() are called by MPIRPC_Wait().
*/
-unsigned int snooze_amount_reset = 0;
-unsigned int snooze_amount = 0;
+static unsigned int snooze_amount_reset = 0;
+static unsigned int snooze_amount = 0;
/**
The maximum amount of time to snooze in microseconds.
Default 500000us.
*/
-useconds_t snooze_max = 500000;
+static useconds_t snooze_max = 500000;
void
MPIRPC_Init()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|