[C-mpi-commits] SF.net SVN: c-mpi:[3]
Status: Pre-Alpha
Brought to you by:
jmwozniak
|
From: <jmw...@us...> - 2010-04-19 22:37:41
|
Revision: 3
http://c-mpi.svn.sourceforge.net/c-mpi/?rev=3&view=rev
Author: jmwozniak
Date: 2010-04-19 22:37:35 +0000 (Mon, 19 Apr 2010)
Log Message:
-----------
More fixes.
Modified Paths:
--------------
src/cmpi/cmpi.c
src/dense-1/cmpi_dense.c
test/cmpi/test01.c
test/cmpi/test02.c
test/cmpi/test03.c
Modified: src/cmpi/cmpi.c
===================================================================
--- src/cmpi/cmpi.c 2010-04-19 19:54:23 UTC (rev 2)
+++ src/cmpi/cmpi.c 2010-04-19 22:37:35 UTC (rev 3)
@@ -1,42 +1,42 @@
-#include <cmpi.h>
+#include <cmpi.h>
#include <keyvalue.h>
-int cmpi_status;
+int cmpi_status;
int cmpi_cache_limit;
-struct lru_table* cmpi_cache = NULL;
+struct lru_table* cmpi_cache = NULL;
/**
- Used to store values from cmpi_impl_parameter().
+ Used to store values from cmpi_impl_parameter().
*/
-struct hashtable* cmpi_params = NULL;
+struct hashtable* cmpi_params = NULL;
int cmpi_msg_join;
-int cmpi_msg_neighbor;
-int cmpi_msg_sendnode;
-int cmpi_msg_sendkey;
+int cmpi_msg_neighbor;
+int cmpi_msg_sendnode;
+int cmpi_msg_sendkey;
int cmpi_msg_sendblob;
int cmpi_msg_lookupkey;
int cmpi_msg_getblob;
-int cmpi_msg_shutdown;
+int cmpi_msg_shutdown;
/**
True when quitting
*/
-bool cmpi_quitting = false;
+bool cmpi_quitting = false;
void
cmpi_params_init()
{
- // NOTE_F;
+ // NOTE_F;
cmpi_params = hashtable_create(10);
}
/**
- Add copy of key/value pair to cmpi_params table.
-*/
+ Add copy of key/value pair to cmpi_params table.
+*/
void
cmpi_params_add(char* key, char* value)
{
@@ -45,48 +45,48 @@
}
/**
- Returns a copy of the matching value or NULL if not found.
+ Returns a copy of the matching value or NULL if not found.
*/
-char*
+char*
cmpi_params_search(char* key)
{
char* result;
result = hashtable_search(cmpi_params, key);
if (result)
return heap(result);
- return NULL;
+ return NULL;
}
void
cmpi_basics(void)
{
- cmpi_status = CMPI_STATUS_PROTO;
-
- MPIRPC_Init();
-
+ cmpi_status = CMPI_STATUS_PROTO;
+
+ MPIRPC_Init();
+
cmpi_msg_join = CMPI_MSG_JOIN;
- cmpi_msg_neighbor = CMPI_MSG_NEIGHBOR;
- cmpi_msg_sendnode = CMPI_MSG_SENDNODE;
+ cmpi_msg_neighbor = CMPI_MSG_NEIGHBOR;
+ cmpi_msg_sendnode = CMPI_MSG_SENDNODE;
cmpi_msg_sendkey = CMPI_MSG_SENDKEY;
cmpi_msg_sendblob = CMPI_MSG_SENDBLOB;
cmpi_msg_lookupkey = CMPI_MSG_LOOKUPKEY;
cmpi_msg_getblob = CMPI_MSG_GETBLOB;
- cmpi_msg_shutdown = CMPI_MSG_SHUTDOWN;
+ cmpi_msg_shutdown = CMPI_MSG_SHUTDOWN;
}
/**
Must be called after MPI_Init()
*/
-CMPI_RETURN
+CMPI_RETURN
cmpi_init()
{
- cmpi_basics();
+ cmpi_basics();
- cmpi_cache = lru_table_create(cmpi_cache_limit, cmpi_cache_limit);
+ cmpi_cache = lru_table_create(cmpi_cache_limit, cmpi_cache_limit);
cmpi_init_impl();
-
- return 0;
+
+ return 0;
}
CMPI_RETURN
@@ -94,41 +94,41 @@
{
cmpi_basics();
cmpi_init_impl_client();
-
+
#ifdef USE_CMPI_IO
- NOTE("USING CMPI-IO \n");
+ NOTE("USING CMPI-IO \n");
cmpi_io_init();
#endif
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
/**
-
+
*/
-int
+int
cmpi_cached_retrieve(char* key, char** data)
{
- int result;
+ int result;
NOTE_F;
-
+
DEBUG(lru_table_fprintf(debug_file, "%s", cmpi_cache));
struct keyvalue* found = lru_table_search(cmpi_cache, key);
if (found)
{
- printdata("found: ", found->data, found->length);
+ printdata("found: ", found->data, found->length);
*data = found->data;
- SHOW_P(*data);
+ SHOW_P(*data);
result = found->length;
- printf("length: %i\n", result);
- // free(found->key);
+ printf("length: %i\n", result);
+ // free(found->key);
// free(found);
}
else
{
result = cmpi_disk_loadpair(key, data);
-
+
if (*data != NULL)
{
struct keyvalue* kv = lru_table_add(cmpi_cache, key,
@@ -142,11 +142,11 @@
else
{
result = 0;
- *data = NULL;
+ *data = NULL;
}
}
- return result;
+ return result;
}
/**
@@ -154,20 +154,20 @@
void
cmpi_cached_store(char* key, char* data, int length)
{
- struct keyvalue* kv;
- SHOW_FS(key);
+ struct keyvalue* kv;
+ SHOW_FS(key);
kv = lru_table_add(cmpi_cache, key, data, length);
if (kv)
{
cmpi_disk_storepair(kv->key, kv->data, length);
- printf("CACHE_DROP: %s\n", kv->key);
+ printf("CACHE_DROP: %s\n", kv->key);
free(kv->key);
- free(kv);
+ free(kv);
}
}
/**
- Does not use cmpi_disk.
+ Does not use cmpi_disk.
*/
void
cmpi_cached_update(char* key, char* data, int offset, int length)
@@ -190,42 +190,42 @@
}
else
{
- lru_table_add(cmpi_cache, key, data, length);
+ lru_table_add(cmpi_cache, key, data, length);
}
}
- // DEBUG(lru_table_fprintf(debug_file, "%s", cmpi_cache));
+ // DEBUG(lru_table_fprintf(debug_file, "%s", cmpi_cache));
- DONE;
+ DONE;
}
/**
- Free up our resources.
+ Free up our resources.
*/
void
cmpi_cleanup()
{
- // NOTE_F;
+ // NOTE_F;
MPIRPC_Finalize();
- // struct keyvalue* kv;
- /*
+ // struct keyvalue* kv;
+ /*
while ((kv = lru_table_poll(cmpi_cache)))
{
;// free(kv->key);
- // free(kv);
+ // free(kv);
}
*/
// lru_table_free(cmpi_cache);
- // NOTE("free cmpi_params");
+ // NOTE("free cmpi_params");
hashtable_free(cmpi_params);
}
/**
- Free up our resources.
+ Free up our resources.
*/
void
cmpi_client_cleanup()
{
- // NOTE_F;
+ // NOTE_F;
hashtable_free(cmpi_params);
MPIRPC_Finalize();
}
Modified: src/dense-1/cmpi_dense.c
===================================================================
--- src/dense-1/cmpi_dense.c 2010-04-19 19:54:23 UTC (rev 2)
+++ src/dense-1/cmpi_dense.c 2010-04-19 22:37:35 UTC (rev 3)
@@ -1,39 +1,39 @@
-#include "cmpi_dense-1.h"
+#include "cmpi_dense-1.h"
/**
- List of node ranks to contact for DENSE routines.
+ List of node ranks to contact for DENSE routines.
*/
-struct inlist* contacts;
+struct inlist* contacts;
CMPI_RETURN
cmpi_init_impl()
{
// NOTE_F;
- DENSE_Read_params();
-
+ DENSE_Read_params();
+
DENSE_Init(3, 3);
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
cmpi_init_impl_client()
{
int i;
- DENSE_Read_params();
+ DENSE_Read_params();
- DENSE_Init_client();
-
+ DENSE_Init_client();
+
contacts = inlist_create();
-
+
for (i = 0; i < dense_nodes; i++)
{
- gossip_debug(MASK_DHT, "contact: %i\n", i);
+ gossip_debug(MASK_DHT, "contact: %i\n", i);
inlist_add(contacts, i);
}
-
- return CMPI_SUCCESS;
+
+ return CMPI_SUCCESS;
}
CMPI_RETURN
@@ -46,44 +46,44 @@
dense_nodes = n;
}
- return CMPI_SUCCESS;
+ return CMPI_SUCCESS;
}
char*
cmpi_info(CMPI_ID key)
{
char* result = NULL;
- int i = inlist_random(contacts);
+ int i = inlist_random(contacts);
MPIRPC_Node node;
- MPIRPC_Node_make(i, MPI_COMM_WORLD, &node);
-
- result = MPIRPC_Block(node, "info", xheap(key));
+ MPIRPC_Node_make(i, MPI_COMM_WORLD, &node);
- return result;
+ result = MPIRPC_Block(node, "info", xheap(key));
+
+ return result;
}
/**
Ex-DHT search.
- @return The MPI rank closest to the given key.
+ @return The MPI rank closest to the given key.
*/
CMPI_ID
cmpi_lookup(char* key)
{
- int i = inlist_random(contacts);
-
- NOTE_FS(key);
+ int i = inlist_random(contacts);
+ NOTE_FS(key);
+
i = inlist_random(contacts);
MPIRPC_Node node;
- MPIRPC_Node_make(i, MPI_COMM_WORLD, &node);
-
- MPIRPC* rpc = DENSE_Lookup(node, key);
+ MPIRPC_Node_make(i, MPI_COMM_WORLD, &node);
+
+ MPIRPC* rpc = DENSE_Lookup(node, key);
MPIRPC_Wait(rpc);
- // printf("cmpi_lookup()@%i -> %s \n", i, rpc->result);
-
+ // printf("cmpi_lookup()@%i -> %s \n", i, rpc->result);
+
return 0;
}
@@ -98,23 +98,23 @@
MPIRPC* rpc = DENSE_Translate(node, (DENSE_ID) id);
MPIRPC_Wait(rpc);
- int result = 0;
+ int result = 0;
sscanf(rpc->result, "%X", &result);
- return result;
+ return result;
}
/**
- Blocking call.
+ Blocking call.
*/
CMPI_RETURN
cmpi_put(char* key, char* value, int length)
{
struct inlist_item* item;
- MPIRPC_Node node;
- SHOW_FS(key);
+ MPIRPC_Node node;
+ SHOW_FS(key);
int i = inlist_random(contacts);
- MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
+ MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
MPIRPC* lookup = DENSE_Lookup_k(node, key);
MPIRPC_Wait(lookup);
@@ -123,30 +123,30 @@
for (item = ranks->head;
item; item = item->next)
{
- SHOW_I(item->data);
- MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
+ SHOW_I(item->data);
+ MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
MPIRPC* rpc = DENSE_Store(node, key, value, length);
MPIRPC_Wait(rpc);
MPIRPC_Free(rpc);
}
- inlist_free(ranks);
+ inlist_free(ranks);
- DONE;
- return CMPI_SUCCESS;
+ DONE;
+ return CMPI_SUCCESS;
}
/**
- Blocking call.
+ Blocking call.
*/
CMPI_RETURN
cmpi_update(char* key, char* value, int length, int offset)
{
struct inlist_item* item;
- MPIRPC_Node node;
- SHOW_FS(key);
+ MPIRPC_Node node;
+ SHOW_FS(key);
int i = inlist_random(contacts);
- MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
+ MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
MPIRPC* lookup = DENSE_Lookup_k(node, key);
MPIRPC_Wait(lookup);
@@ -155,16 +155,16 @@
for (item = ranks->head;
item; item = item->next)
{
- SHOW_I(item->data);
- MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
+ SHOW_I(item->data);
+ MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
MPIRPC* rpc = DENSE_Update(node, key, value, length, offset);
MPIRPC_Wait(rpc);
MPIRPC_Free(rpc);
}
- inlist_free(ranks);
+ inlist_free(ranks);
- DONE;
- return CMPI_SUCCESS;
+ DONE;
+ return CMPI_SUCCESS;
}
CMPI_RETURN
@@ -174,27 +174,27 @@
MPIRPC_Node node;
NOTE_FS(key);
-
- MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
+ MPIRPC_Node_make(MPI_COMM_WORLD, i, &node);
+
MPIRPC* lookup = DENSE_Lookup_k(node, key);
MPIRPC_Wait(lookup);
- struct inlist* ranks = inlist_parse(lookup->result);
- int rank = inlist_random(ranks);
+ struct inlist* ranks = inlist_parse(lookup->result);
+ int rank = inlist_random(ranks);
inlist_free(ranks);
-
- MPIRPC_Node_make(MPI_COMM_WORLD, rank, &node);
+
+ MPIRPC_Node_make(MPI_COMM_WORLD, rank, &node);
MPIRPC* rpc = DENSE_Retrieve(node, key);
MPIRPC_Wait(rpc);
*value = rpc->result;
*length = rpc->result_length;
- SHOW_I(rpc->result_length);
-
+ SHOW_I(rpc->result_length);
+
MPIRPC_Free(rpc);
-
- DONE;
+
+ DONE;
return CMPI_SUCCESS;
}
@@ -202,15 +202,15 @@
cmpi_shutdown()
{
struct inlist_item* item;
- NOTE_F;
+ NOTE_F;
- MPIRPC_Node node;
+ MPIRPC_Node node;
for (item = contacts->head; item; item = item->next)
{
- MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
+ MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
DENSE_Shutdown(node);
}
- DONE;
+ DONE;
}
void
@@ -221,10 +221,10 @@
cmpi_debug_caches()
{
struct inlist_item* item;
- MPIRPC_Node node;
+ MPIRPC_Node node;
for (item = contacts->head; item; item = item->next)
{
- MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
+ MPIRPC_Node_make(MPI_COMM_WORLD, item->data, &node);
DENSE_Debug_cache(node);
}
}
@@ -232,17 +232,17 @@
void
DENSE_Read_params(void)
{
- // NOTE_F;
+ // NOTE_F;
char* nodes_msg = cmpi_params_search("nodes");
if (nodes_msg)
{
int n = sscanf(nodes_msg, "%i", &dense_nodes);
- // SHOW_I(dense_nodes);
+ // SHOW_I(dense_nodes);
assert(n == 1);
free(nodes_msg);
}
else
{
- dense_nodes = mpi_size;
+ dense_nodes = mpi_size;
}
}
Modified: test/cmpi/test01.c
===================================================================
--- test/cmpi/test01.c 2010-04-19 19:54:23 UTC (rev 2)
+++ test/cmpi/test01.c 2010-04-19 22:37:35 UTC (rev 3)
@@ -2,19 +2,19 @@
/**
Simply build DHT and shutdown.
Be sure to pass -n <nodes> !
-*/
+*/
-#include "test_helpers.h"
+#include "test_helpers.h"
void
cmpi_client_code()
{
- NOTE_F;
+ NOTE_F;
gossip_set_debug_mask(1, MASK_MPIRPC);
-
+
wait_for_notification();
- notify_next();
+ notify_next();
- cmpi_shutdown();
+ cmpi_shutdown();
}
Modified: test/cmpi/test02.c
===================================================================
--- test/cmpi/test02.c 2010-04-19 19:54:23 UTC (rev 2)
+++ test/cmpi/test02.c 2010-04-19 22:37:35 UTC (rev 3)
@@ -1,21 +1,21 @@
/**
- Assemble and debug tables.
+ Assemble and debug tables.
*/
-#include "test_helpers.h"
+#include "test_helpers.h"
void
cmpi_client_code()
{
- NOTE_F;
+ NOTE_F;
wait_for_notification();
- notify_next();
+ notify_next();
cmpi_debug_tables();
- sleep(mpi_rank);
-
- cmpi_shutdown();
+ sleep(mpi_rank);
+
+ cmpi_shutdown();
}
Modified: test/cmpi/test03.c
===================================================================
--- test/cmpi/test03.c 2010-04-19 19:54:23 UTC (rev 2)
+++ test/cmpi/test03.c 2010-04-19 22:37:35 UTC (rev 3)
@@ -1,39 +1,39 @@
/**
- Put two keys and get one of them.
+ Put two keys and get one of them.
*/
-#include "test_helpers.h"
+#include "test_helpers.h"
void
cmpi_client_code()
{
char key1[10];
- char key2[10];
+ char key2[10];
sprintf(key1, "key1_%i", mpi_rank);
sprintf(key2, "key2_%i", mpi_rank);
wait_for_notification();
- notify_next();
+ notify_next();
char value[30];
- strcpy(value, "value1");
- cmpi_put(key1, value, strlen(value)+1);
- strcpy(value, "value2");
+ strcpy(value, "value1");
+ cmpi_put(key1, value, strlen(value)+1);
+ strcpy(value, "value2");
cmpi_put(key2, value, strlen(value)+1);
-
+
sleep(2);
-
- cmpi_debug_caches();
- sleep(2);
-
- int length;
- char* result;
+ cmpi_debug_caches();
+
+ sleep(2);
+
+ int length;
+ char* result;
cmpi_get(key1, &result, &length);
- printf("result(%i): %s\n", result, length);
-
- sleep(3);
-
- cmpi_shutdown();
+ printf("result(%i): %s\n", result, length);
+
+ sleep(3);
+
+ cmpi_shutdown();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|