Triton-commits
Threads by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
April 2012
- 1 participants
- 64 discussions
C-Utils Repository branch, master, updated. 6bc8c1c32a4a0c777847e44d4e0bf12e2b38d20a
by noreply@mcs.anl.gov 30 Apr '12
by noreply@mcs.anl.gov 30 Apr '12
30 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "C-Utils Repository".
The branch, master has been updated
via 6bc8c1c32a4a0c777847e44d4e0bf12e2b38d20a (commit)
via fc2e4560cfc9b4e64f547592adefe56d65714533 (commit)
from 0b44e7c171fb51ae67a05c1c429dc1e2d80680dc (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6bc8c1c32a4a0c777847e44d4e0bf12e2b38d20a
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Mon Apr 30 13:53:35 2012 -0500
Add libev patch
commit fc2e4560cfc9b4e64f547592adefe56d65714533
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Mon Apr 30 13:52:01 2012 -0500
Make libev use free instead of realloc(ptr,0)
- valgrind treats realloc(ptr,0) as memory leaks...
-----------------------------------------------------------------------
Summary of changes:
libev/ev.c | 4 --
...e-libev-use-free-instead-of-realloc-ptr-0.patch | 35 ++++++++++++++++++++
2 files changed, 35 insertions(+), 4 deletions(-)
create mode 100644 libev/patches/0002-Make-libev-use-free-instead-of-realloc-ptr-0.patch
Diff of changes:
diff --git a/libev/ev.c b/libev/ev.c
index 4187b18..36134b7 100644
--- a/libev/ev.c
+++ b/libev/ev.c
@@ -608,9 +608,6 @@ ev_syserr (const char *msg)
static void *
ev_realloc_emul (void *ptr, long size)
{
-#if __GLIBC__
- return realloc (ptr, size);
-#else
/* some systems, notably openbsd and darwin, fail to properly
* implement realloc (x, 0) (as required by both ansi c-89 and
* the single unix specification, so work around them here.
@@ -621,7 +618,6 @@ ev_realloc_emul (void *ptr, long size)
free (ptr);
return 0;
-#endif
}
static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
diff --git a/libev/patches/0002-Make-libev-use-free-instead-of-realloc-ptr-0.patch b/libev/patches/0002-Make-libev-use-free-instead-of-realloc-ptr-0.patch
new file mode 100644
index 0000000..f5609f1
--- /dev/null
+++ b/libev/patches/0002-Make-libev-use-free-instead-of-realloc-ptr-0.patch
@@ -0,0 +1,35 @@
+From fc2e4560cfc9b4e64f547592adefe56d65714533 Mon Sep 17 00:00:00 2001
+From: Dries Kimpe <dkimpe(a)mcs.anl.gov>
+Date: Mon, 30 Apr 2012 13:52:01 -0500
+Subject: [PATCH] Make libev use free instead of realloc(ptr,0)
+
+- valgrind treats realloc(ptr,0) as memory leaks...
+---
+ libev/ev.c | 4 ----
+ 1 files changed, 0 insertions(+), 4 deletions(-)
+
+diff --git a/libev/ev.c b/libev/ev.c
+index 4187b18..36134b7 100644
+--- a/libev/ev.c
++++ b/libev/ev.c
+@@ -608,9 +608,6 @@ ev_syserr (const char *msg)
+ static void *
+ ev_realloc_emul (void *ptr, long size)
+ {
+-#if __GLIBC__
+- return realloc (ptr, size);
+-#else
+ /* some systems, notably openbsd and darwin, fail to properly
+ * implement realloc (x, 0) (as required by both ansi c-89 and
+ * the single unix specification, so work around them here.
+@@ -621,7 +618,6 @@ ev_realloc_emul (void *ptr, long size)
+
+ free (ptr);
+ return 0;
+-#endif
+ }
+
+ static void *(*alloc)(void *ptr, long size) = ev_realloc_emul;
+--
+1.7.3.4
+
hooks/post-receive
--
C-Utils Repository
1
0
C-Utils Repository branch, master, updated. 0b44e7c171fb51ae67a05c1c429dc1e2d80680dc
by noreply@mcs.anl.gov 27 Apr '12
by noreply@mcs.anl.gov 27 Apr '12
27 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "C-Utils Repository".
The branch, master has been updated
via 0b44e7c171fb51ae67a05c1c429dc1e2d80680dc (commit)
from 523bdd75c9c61d123e942d861eaa8207e78a9a55 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 0b44e7c171fb51ae67a05c1c429dc1e2d80680dc
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Fri Apr 27 17:16:02 2012 -0500
Add triton_list_is_linked() function
Function to test if a triton_list_link is part of a list or not.
-----------------------------------------------------------------------
Summary of changes:
triton-list.h | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
Diff of changes:
diff --git a/triton-list.h b/triton-list.h
index ed46e54..51c220b 100644
--- a/triton-list.h
+++ b/triton-list.h
@@ -100,6 +100,15 @@ static inline void triton_list_del(struct triton_list_link *entry)
entry->inlist = NULL;
}
+/**
+ * Returns non-zero if the given link is in a linked list.
+ * Returns 0 if the link is not linked in a list.
+ */
+static inline int triton_list_is_linked (struct triton_list_link * e)
+{
+ return e->inlist != NULL;
+}
+
static inline int triton_list_empty(triton_list_t *list)
{
return list->count == 0;
hooks/post-receive
--
C-Utils Repository
1
0
27 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 15812c7954aaf50059dbb9772a5608bc3582948c (commit)
via 3e2ee257e4c23baba88ef0581478cca19e3e6ffc (commit)
via 78e396161a4061408899bcbb834ffbf99008b07c (commit)
via 503ea21f4ce83292c5f4075b3f0e504f159a636c (commit)
via 0300dc6995b8fc6ea4be927018fd671081531331 (commit)
from 4f7bc63830a6ed1b29e8a107e131623199316076 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 15812c7954aaf50059dbb9772a5608bc3582948c
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 27 13:34:21 2012 -0400
headers that should have been in previous commits
commit 3e2ee257e4c23baba88ef0581478cca19e3e6ffc
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 27 13:32:55 2012 -0400
update state component to use string values
- turn off some state rpc tests for now until rpc's are updated
commit 78e396161a4061408899bcbb834ffbf99008b07c
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 27 13:32:19 2012 -0400
fix missing header
commit 503ea21f4ce83292c5f4075b3f0e504f159a636c
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 27 13:31:34 2012 -0400
fix ref counting on triton_string_destroy()
commit 0300dc6995b8fc6ea4be927018fd671081531331
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Fri Apr 27 11:44:11 2012 -0400
fix triton-string bug
-----------------------------------------------------------------------
Summary of changes:
code/src/common/triton-string.h | 36 +++++--
code/src/fakess/fakess.ae | 41 +++-----
code/src/fakess/fakess.hae | 5 +-
code/src/placement/placement-nearest.ae | 1 +
code/src/state/sc.aer | 28 +++---
code/src/state/sc.haer | 4 +
code/src/state/state-cache-access.hae | 34 ++++++
code/src/state/state-cache-update.hae | 27 +++++
code/src/state/state.ae | 175 +++++++++++++++----------------
code/src/state/state.hae | 25 ++---
code/src/state/tests/engine1.ae | 14 +--
code/src/state/tests/local.ae | 21 ++---
code/src/state/tests/post-global.ae | 17 ++--
code/src/state/tests/rpc-global.ae | 18 ++-
code/src/state/tests/rpc-global.sh | 3 +
code/src/state/tests/rpc-list.ae | 16 ++-
code/src/state/tests/rpc-list.sh | 3 +
code/src/state/tests/state-client.ae | 2 +
18 files changed, 272 insertions(+), 198 deletions(-)
create mode 100644 code/src/state/state-cache-access.hae
create mode 100644 code/src/state/state-cache-update.hae
Diff of changes:
diff --git a/code/src/common/triton-string.h b/code/src/common/triton-string.h
index 1998023..4ed7ac5 100644
--- a/code/src/common/triton-string.h
+++ b/code/src/common/triton-string.h
@@ -111,7 +111,16 @@ static inline void triton_string_init_inplace_size(triton_string_t *s, char *val
}
}
+static inline const char* triton_string_get(triton_string_t* str)
+{
+ while(str->parent)
+ str = str->parent;
+
+ return(str->const_string ? str->const_string : str->string);
+}
+#if 0
#define triton_string_get(__str__) ((__str__)->const_string ? (__str__)->const_string : (__str__)->string)
+#endif
#define triton_string_set_null(__val) do { \
(__val)->parent = NULL; \
@@ -122,19 +131,30 @@ static inline void triton_string_init_inplace_size(triton_string_t *s, char *val
(__val)->const_string = NULL; \
} while(0)
+static inline void triton_string_decrement(triton_string_t *s)
+{
+ triton_mutex_lock(&s->reflock);
+ s->refcount--;
+ triton_mutex_unlock(&s->reflock);
+
+ if(s->parent)
+ triton_string_decrement(s->parent);
+}
+
static inline void triton_string_destroy(triton_string_t *s)
{
if(s->parent)
+ triton_string_decrement(s->parent);
+
+ triton_mutex_lock(&s->reflock);
+ if(s->refcount == 0)
{
- assert(s->string == NULL && s->const_string == NULL);
- triton_string_destroy(s->parent);
- }
- else if(s->string)
- {
- free(s->string);
+ if(s->string)
+ free(s->string);
+ triton_mutex_destroy(&s->reflock);
+ triton_string_set_null(s);
}
- triton_mutex_destroy(&s->reflock);
- triton_string_set_null(s);
+ triton_mutex_unlock(&s->reflock);
}
static inline void triton_string_copy(triton_string_t *to, triton_string_t *from)
diff --git a/code/src/fakess/fakess.ae b/code/src/fakess/fakess.ae
index 3f7e04c..22961ad 100644
--- a/code/src/fakess/fakess.ae
+++ b/code/src/fakess/fakess.ae
@@ -162,12 +162,12 @@ __blocking triton_ret_t triton_fakess_shutdown()
static int serialize_post(triton_node_t node,
triton_string_t *key,
- int length,
- char *buffer)
+ triton_string_t *value,
+ char* buffer)
{
int result;
- result = sprintf(buffer, "POST: %llu %llu %s %i\n",
- llu(node.u), llu(node.l), key->string, length);
+ result = sprintf(buffer, "POST: %llu %llu %s %s\n",
+ llu(node.u), llu(node.l), triton_string_get(key), triton_string_get(value));
return result;
}
@@ -175,14 +175,11 @@ static int serialize_post(triton_node_t node,
/**
Post a change in addr/key (updates local data structure and then transmits
update to the other servers). The key does not have to exist ahead of time.
- Will call free(value) when value is reset and on finalize().
*/
__blocking triton_ret_t triton_fakess_post(triton_node_t node,
triton_string_t *key,
- void *value,
- int value_length)
+ triton_string_t *value)
{
- int header_length;
triton_state_data_t *data;
char buffer[TRITON_FAKESS_SIZE_MESSAGE];
uint32_t buffer_length;
@@ -204,12 +201,10 @@ __blocking triton_ret_t triton_fakess_post(triton_node_t node,
}
/* do local update (adding key if needed) */
- triton_state_cache_update(node, key, value, value_length);
+ triton_state_cache_update(node, key, value);
/* set up message to send to other servers */
- header_length = serialize_post(node, key, value_length, buffer);
- memcpy(buffer+header_length, value, value_length);
- buffer_length = header_length+value_length;
+ buffer_length = serialize_post(node, key, value, buffer);
/* broadcast update message to other servers */
triton_fakess_broadcast(tag, buffer, buffer_length);
@@ -230,32 +225,28 @@ static void process_post(char *buffer, int p, triton_addr_t from)
char *args = buffer+p;
triton_node_t node;
char keystring[TRITON_FAKESS_SIZE_KEY];
+ char valstring[TRITON_FAKESS_SIZE_VALUE];
triton_string_t key;
- int length;
- char *value;
+ triton_string_t value;
triton_state_data_t *data;
int n;
char *q;
#if SIZEOF_LONG_INT == 4
- n = sscanf(args, "%llu %llu %s %i",
- &node.u, &node.l, keystring, &length);
+ n = sscanf(args, "%llu %llu %s %s",
+ &node.u, &node.l, keystring, valstring);
#else
- n = sscanf(args, "%lu %lu %s %i",
- &node.u, &node.l, keystring, &length);
+ n = sscanf(args, "%lu %lu %s %s",
+ &node.u, &node.l, keystring, valstring);
#endif
assert(n == 4);
- // key = triton_string_malloc(keystring);
triton_string_init(&key, "%s", keystring);
+ triton_string_init(&value, "%s", valstring);
- value = malloc(length);
- assert(length < TRITON_FAKESS_SIZE_MESSAGE);
- q = strchr(args, '\n');
- memcpy(value, q+1, length);
-
- triton_state_cache_update(node, &key, value, length);
+ triton_state_cache_update(node, &key, &value);
triton_string_destroy(&key);
+ triton_string_destroy(&value);
}
static void process_buffer(char *buffer, triton_addr_t from)
diff --git a/code/src/fakess/fakess.hae b/code/src/fakess/fakess.hae
index 6735a66..1a36caa 100644
--- a/code/src/fakess/fakess.hae
+++ b/code/src/fakess/fakess.hae
@@ -21,8 +21,6 @@
#define TRITON_FAKESS_SIZE_VALUE 4096
#define TRITON_TAG_FAKESS 47
-#define TRITON_FAKESS_UNSET ((void *)1)
-
struct triton_state_engine_funcs* triton_fakess_state_install(void);
triton_ret_t triton_fakess_list(triton_node_t *list);
@@ -34,8 +32,7 @@ triton_state_data_t *triton_fakess_lookup(triton_node_t node,
__blocking triton_ret_t triton_fakess_post(triton_node_t node,
triton_string_t *key,
- void *value,
- int value_length);
+ triton_string_t *value);
struct triton_state_table;
diff --git a/code/src/placement/placement-nearest.ae b/code/src/placement/placement-nearest.ae
index f9ba53e..d9712ad 100644
--- a/code/src/placement/placement-nearest.ae
+++ b/code/src/placement/placement-nearest.ae
@@ -8,6 +8,7 @@
#include "src/mapping/mapping.hae"
#include "src/state/state.hae"
+#include "src/state/state-cache-access.hae"
#include "src/placement/placement.hae"
uint128_t triton_uint128_diff(uint128_t a, uint128_t b);
diff --git a/code/src/state/sc.aer b/code/src/state/sc.aer
index 889c143..aadf98f 100644
--- a/code/src/state/sc.aer
+++ b/code/src/state/sc.aer
@@ -46,7 +46,7 @@ __attribute__((constructor)) void triton_state_client_init_register(void)
"triton.state_client",
state_client_init, state_client_finalize, NULL);
}
-
+#if 0
__remote __blocking triton_ret_t state_client_list(
int32_t* in_nothing,
struct sc_list *list)
@@ -65,6 +65,7 @@ __remote __blocking triton_ret_t state_client_list(
return TRITON_SUCCESS;
}
+#endif
__remote __blocking triton_ret_t state_client_size(
int32_t* in_nothing,
@@ -74,6 +75,7 @@ __remote __blocking triton_ret_t state_client_size(
return TRITON_SUCCESS;
}
+#if 0
__remote __blocking triton_ret_t state_client_lookup(
struct sc_lookup_pair *pair,
struct sc_lookup_value *value)
@@ -101,6 +103,7 @@ __remote __blocking triton_ret_t state_client_lookup(
return TRITON_SUCCESS;
}
+#endif
__remote __blocking triton_ret_t state_client_propagation(
int32_t *in_nothing,
@@ -120,11 +123,9 @@ static void inject_local_fault()
static void handle_state_change(triton_status_t *status)
{
- triton_string_t state;
- triton_status_tostring(&state, *status);
- // triton_debug(debug, "new state: %s\n", triton_string_get(&state));
- printf("handle_state_change(): new state: %s\n", triton_string_get(&state));
- triton_string_destroy(&state);
+ const char* state_str;
+ state_str = status_to_string(*status);
+ printf("handle_state_change(): new state: %s\n", state_str);
if (*status == TRITON_STATUS_INJECTED)
{
@@ -144,22 +145,21 @@ __remote __blocking triton_ret_t state_client_admin_status_set(
{
triton_node_t self;
triton_string_t key;
- triton_status_t *copy;
+ triton_string_t value;
triton_ret_t ret;
- copy = malloc(sizeof(triton_status_t));
- *copy = *status;
-
/* Local handling */
- handle_state_change(copy);
+ handle_state_change(*status);
/* Propagate into state system */
self = triton_map_self();
triton_string_init(&key, "triton.state");
- ret = triton_state_engine_post(self, &key,
- copy, sizeof(triton_status_t));
- /* triton_string_destroy(&key); */
+ triton_string_init(&value, status_to_string(*status));
+
+ ret = triton_state_engine_post(self, &key, &value);
+ triton_string_destroy(&key);
+ triton_string_destroy(&value);
ret = TRITON_SUCCESS;
return(ret);
diff --git a/code/src/state/sc.haer b/code/src/state/sc.haer
index bb9aed9..206c83a 100644
--- a/code/src/state/sc.haer
+++ b/code/src/state/sc.haer
@@ -10,6 +10,7 @@
#include "src/net/triton-addr.h"
#include "src/remote/encoding.h"
+#if 0
__remote struct sc_list
{
triton_buffer_t buffer;
@@ -34,14 +35,17 @@ __remote struct sc_lookup_value
__remote __blocking triton_ret_t state_client_list(
int32_t* in_nothing,
struct sc_list* list);
+#endif
__remote __blocking triton_ret_t state_client_size(
int32_t* in_nothing,
int32_t* out_size);
+#if 0
__remote __blocking triton_ret_t state_client_lookup(
struct sc_lookup_pair *pair,
struct sc_lookup_value *value);
+#endif
/**
* Obtain the upper bound on the state propagation time
diff --git a/code/src/state/state-cache-access.hae b/code/src/state/state-cache-access.hae
new file mode 100644
index 0000000..e47fbf0
--- /dev/null
+++ b/code/src/state/state-cache-access.hae
@@ -0,0 +1,34 @@
+#ifndef __TRITON_STATE_CACHE_ACCESS_HAE__
+#define __TRITON_STATE_CACHE_ACCESS_HAE__
+
+#include "src/aesop/aesop.h"
+#include "src/state/state.hae"
+
+/* These are functions that can be used for read-only access to locally
+ * cached data that is held in the state component
+ */
+
+triton_state_data_t *triton_state_cache_lookup(
+ triton_node_t,
+ triton_string_t *key);
+
+int triton_state_cache_count_nodes(void);
+
+/* TODO: what if node list grew since you retrieved the count/size?
+ * There is some danger of overflow here...
+ */
+triton_ret_t triton_state_cache_list_nodes(triton_node_t *list);
+
+triton_ret_t triton_state_cache_get_propagation(int *result_time);
+
+#endif
+
+/*
+ * Local variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/code/src/state/state-cache-update.hae b/code/src/state/state-cache-update.hae
new file mode 100644
index 0000000..4e870fb
--- /dev/null
+++ b/code/src/state/state-cache-update.hae
@@ -0,0 +1,27 @@
+#ifndef __TRITON_STATE_CACHE_UPDATE_HAE__
+#define __TRITON_STATE_CACHE_UPDATE_HAE__
+
+#include "src/aesop/aesop.h"
+
+/* These are functions that can be used to update locally cached data that
+ * is held in the state component
+ */
+
+triton_ret_t triton_state_cache_node_add(triton_node_t);
+
+void triton_state_cache_update(triton_node_t node, triton_string_t *key,
+ triton_string_t *value);
+
+triton_ret_t triton_state_cache_update_propagation(int prop_time);
+
+#endif
+
+/*
+ * Local variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/code/src/state/state.ae b/code/src/state/state.ae
index 0fb466a..824c131 100644
--- a/code/src/state/state.ae
+++ b/code/src/state/state.ae
@@ -19,6 +19,18 @@ static struct triton_hash_table *node_hash;
static triton_list_t node_list;
static int propagation = 1;
+/* NOTE: if you change the string table, please update the enum in state.hae! */
+static const char *triton_status_strings[] = {
+ "TRITON_STATUS_PROTO",
+ "TRITON_STATUS_NOMINAL",
+ "TRITON_STATUS_NOMINAL_REBUILD",
+ "TRITON_STATUS_RECOVERY",
+ "TRITON_STATUS_MAINTENANCE",
+ "TRITON_STATUS_INJECTED",
+ "TRITON_STATUS_UNREACHABLE",
+ "TRITON_STATUS_INVALID",
+};
+
/* TODO: mutex to protect the data structures as a whole? */
/* TODO: add some assertions to make sure that non-server nodes don't call
@@ -51,8 +63,7 @@ static triton_state_data_t *lookup_data(
static triton_ret_t item_add(triton_node_t node,
triton_string_t *key);
static triton_ret_t item_set(triton_state_data_t *data,
- void *value,
- int value_length);
+ triton_string_t *value);
static int node_compare(const void *key, struct triton_hash_link *link);
static void data_destroy(triton_state_data_t *data);
@@ -90,7 +101,7 @@ triton_ret_t triton_status_get(triton_node_t node,
return TRITON_ERR_NOTFOUND;
triton_mutex_lock(&data->mutex);
- memcpy(status, data->value, sizeof(triton_status_t));
+ *status = string_to_status(triton_string_get(&data->value));
triton_mutex_unlock(&data->mutex);
return TRITON_SUCCESS;
@@ -98,18 +109,21 @@ triton_ret_t triton_status_get(triton_node_t node,
__blocking triton_ret_t triton_status_set(triton_status_t status)
{
- triton_status_t *copy;
- triton_node_t self;
triton_string_t key;
+ triton_string_t value;
+ triton_node_t self;
triton_ret_t ret;
- self = triton_map_self();
- triton_status = status;
- copy = malloc(sizeof(triton_status_t));
- *copy = status;
+
triton_string_init(&key, "triton.state");
- ret = triton_state_engine_post(self, &key, copy,
- sizeof(triton_status_t));
+ triton_string_init(&value, status_to_string(status));
+
+ self = triton_map_self();
+
+ ret = triton_state_engine_post(self, &key, &value);
+
triton_string_destroy(&key);
+ triton_string_destroy(&value);
+
return ret;
}
@@ -121,20 +135,19 @@ static triton_ret_t __blocking check_state(triton_node_t peer,
__blocking void triton_state_monitor_self()
{
triton_string_t key;
+ triton_string_t value;
triton_node_t self;
triton_ret_t ret;
triton_state_data_t *data;
triton_status_t status = TRITON_STATUS_PROTO;
triton_status_t status_previous = TRITON_STATUS_PROTO;
- triton_status_t *self_status;
/* TODO: why are the following calls needed? */
self = triton_map_self();
triton_string_init(&key, "triton.state");
- self_status = malloc(sizeof(triton_status_t));
- *self_status = triton_status;
- ret = triton_state_engine_post(self, &key,
- self_status, sizeof(triton_status_t));
+ triton_string_init(&value, status_to_string(triton_status));
+
+ ret = triton_state_engine_post(self, &key, &value);
triton_error_assert(ret);
/* wait for all nodes to post status=NOMINAL */
@@ -175,7 +188,8 @@ __blocking void triton_state_monitor_self()
}
}
-
+ triton_string_destroy(&key);
+ triton_string_destroy(&value);
return;
}
@@ -231,8 +245,8 @@ static __blocking void watch_peers(void)
__blocking void triton_state_monitor()
{
triton_string_t key;
+ triton_string_t value;
triton_node_t self;
- triton_status_t *status;
triton_ret_t ret;
bool running;
triton_string_t s;
@@ -241,10 +255,8 @@ __blocking void triton_state_monitor()
self = triton_map_self();
triton_string_init(&key, "triton.state");
- status = malloc(sizeof(triton_status_t));
- *status = triton_status;
- ret = triton_state_engine_post(self, &key,
- status, sizeof(triton_status_t));
+ triton_string_init(&value, status_to_string(triton_status));
+ ret = triton_state_engine_post(self, &key, &value);
triton_error_assert(ret);
/* wait for all nodes to post status=NOMINAL */
@@ -267,6 +279,7 @@ __blocking void triton_state_monitor()
}
triton_string_destroy(&key);
+ triton_string_destroy(&value);
return;
}
@@ -278,7 +291,7 @@ static triton_ret_t __blocking check_state_self(triton_node_t peer,
triton_ret_t pret = TRITON_SUCCESS;
triton_mutex_lock(&data->mutex);
- *peer_status = *(triton_status_t *)(data->value);
+ *peer_status = string_to_status(triton_string_get(&data->value));
if (*peer_status == *peer_status_previous)
{
pret = triton_sched_wait(data->sched,
@@ -286,7 +299,7 @@ static triton_ret_t __blocking check_state_self(triton_node_t peer,
}
triton_mutex_unlock(&data->mutex);
- *peer_status = *(triton_status_t *)(data->value);
+ *peer_status = string_to_status(triton_string_get(&data->value));
if (pret == TRITON_SUCCESS && *peer_status != *peer_status_previous)
{
triton_status_change_self(peer, peer_status,
@@ -301,22 +314,20 @@ static __blocking void triton_status_change_self(triton_node_t node,
triton_status_t *status_previous)
{
triton_ret_t ret;
- triton_string_t status_string_current;
- triton_string_t status_string_previous;
+ const char* string_current;
+ const char* string_previous;
triton_addr_t addr;
ret = triton_map_lookup_node(node, &addr);
/* TODO: error handling */
triton_error_assert(ret);
- triton_status_tostring(&status_string_current, *status_current);
- triton_status_tostring(&status_string_previous, *status_previous);
+ string_current = status_to_string(*status_current);
+ string_previous = status_to_string(*status_previous);
printf("handle local status change: from: %s to: %s\n",
- triton_string_get(&status_string_previous),
- triton_string_get(&status_string_current));
- triton_string_destroy(&status_string_current);
- triton_string_destroy(&status_string_previous);
+ string_previous,
+ string_current);
if (! triton_status_is_failed(*status_previous) ||
triton_status_is_failed(*status_current))
@@ -342,7 +353,7 @@ static triton_ret_t __blocking check_state(triton_node_t peer,
triton_ret_t pret = TRITON_SUCCESS;
triton_mutex_lock(&data->mutex);
- *peer_status = *(triton_status_t *)(data->value);
+ *peer_status = string_to_status(triton_string_get(&data->value));
if (*peer_status == *peer_status_previous)
{
pret = triton_sched_wait(data->sched,
@@ -350,7 +361,7 @@ static triton_ret_t __blocking check_state(triton_node_t peer,
}
triton_mutex_unlock(&data->mutex);
- *peer_status = *(triton_status_t *)(data->value);
+ *peer_status = string_to_status(triton_string_get(&data->value));
if (pret == TRITON_SUCCESS && *peer_status != *peer_status_previous)
{
triton_status_change(peer, peer_status,
@@ -365,19 +376,17 @@ __blocking void triton_status_change(triton_node_t node,
triton_status_t *status_previous)
{
char node_string[128];
- triton_string_t status_string_current;
- triton_string_t status_string_previous;
+ const char* string_current;
+ const char* string_previous;
triton_uint128_to_string(node_string, 128, node);
- triton_status_tostring(&status_string_current, *status_current);
- triton_status_tostring(&status_string_previous, *status_previous);
+ string_current = status_to_string(*status_current);
+ string_previous = status_to_string(*status_previous);
printf("handle status change: node: %s from: %s to: %s\n",
node_string,
- triton_string_get(&status_string_previous),
- triton_string_get(&status_string_current));
- triton_string_destroy(&status_string_current);
- triton_string_destroy(&status_string_previous);
+ string_previous,
+ string_current);
if (! triton_status_is_failed(*status_previous) &&
triton_status_is_failed(*status_current))
@@ -389,39 +398,6 @@ __blocking void triton_status_change(triton_node_t node,
*status_previous = *status_current;
}
-triton_ret_t triton_status_tostring(triton_string_t *result,
- triton_status_t status)
-{
- switch (status)
- {
- case TRITON_STATUS_PROTO:
- triton_string_init(result, "PROTO");
- break;
- case TRITON_STATUS_NOMINAL:
- triton_string_init(result, "NOMINAL");
- break;
- case TRITON_STATUS_NOMINAL_REBUILD:
- triton_string_init(result, "NOMINAL_REBUILD");
- break;
- case TRITON_STATUS_RECOVERY:
- triton_string_init(result, "RECOVERY");
- break;
- case TRITON_STATUS_MAINTENANCE:
- triton_string_init(result, "MAINTENANCE");
- break;
- case TRITON_STATUS_INJECTED:
- triton_string_init(result, "INJECTED");
- break;
- case TRITON_STATUS_UNREACHABLE:
- triton_string_init(result, "UNREACHABLE");
- break;
- default:
- return TRITON_ERR_INVAL;
- }
-
- return TRITON_SUCCESS;
-}
-
static int initialized = 0;
static triton_ret_t backend_updater(const char *key, const char *value)
@@ -674,8 +650,7 @@ triton_ret_t triton_state_cache_list_nodes(triton_node_t *list)
}
-void triton_state_cache_update(triton_node_t node, triton_string_t *key,
- void *value, int size)
+void triton_state_cache_update(triton_node_t node, triton_string_t *key, triton_string_t* value)
{
triton_state_data_t *data = triton_state_cache_lookup(node, key);
triton_ret_t error;
@@ -697,7 +672,7 @@ void triton_state_cache_update(triton_node_t node, triton_string_t *key,
data = triton_state_cache_lookup(node, key);
assert(data);
}
- item_set(data, value, size);
+ item_set(data, value);
}
/**
@@ -725,7 +700,7 @@ static triton_ret_t item_add(triton_node_t node,
return(TRITON_ERR_NOMEM);
triton_string_init(&data->key, "%s", key->string);
- data->value = TRITON_STATE_UNSET;
+ triton_string_init(&data->value, "");
triton_sched_init(&data->sched);
triton_mutex_init(&data->mutex, NULL);
triton_list_link_clear(&data->link);
@@ -740,16 +715,12 @@ static triton_ret_t item_add(triton_node_t node,
Should be private, exposed for local.ae test
*/
static triton_ret_t item_set(triton_state_data_t *data,
- void *value,
- int value_length)
+ triton_string_t *value)
{
triton_mutex_lock(&data->mutex);
- if (data->value &&
- data->value != TRITON_STATE_UNSET)
- free(data->value);
- data->value = value;
- data->size = value_length;
+ triton_string_destroy(&data->value);
+ triton_string_clone(&data->value, value);
triton_sched_notify_all(data->sched);
triton_mutex_unlock(&data->mutex);
@@ -778,12 +749,11 @@ triton_ret_t triton_state_cache_get_propagation(int *result_time)
__blocking triton_ret_t triton_state_engine_post(triton_node_t node,
triton_string_t *key,
- void *value,
- int value_length)
+ triton_string_t *value)
{
triton_ret_t ret;
- ret = engine_funcs->post(node, key, value, value_length);
+ ret = engine_funcs->post(node, key, value);
return(ret);
}
@@ -832,11 +802,34 @@ static void data_destroy(triton_state_data_t *data)
triton_mutex_destroy(&data->mutex);
triton_sched_destroy(data->sched);
triton_string_destroy(&data->key);
- if (data->value != TRITON_FAKESS_UNSET)
- free(data->value);
+ triton_string_destroy(&data->value);
free(data);
}
+triton_status_t string_to_status(const char* string)
+{
+ int i;
+
+ for(i=0; i<TRITON_STATUS_INVALID; i++)
+ {
+ if(strcmp(string, triton_status_strings[i]) == 0)
+ {
+ return(i);
+ }
+ }
+
+ return(TRITON_STATUS_INVALID);
+}
+
+const char* status_to_string(triton_status_t status)
+{
+ if(status >= TRITON_STATUS_INVALID)
+ {
+ return(triton_status_strings[TRITON_STATUS_INVALID]);
+ }
+
+ return(triton_status_strings[status]);
+}
/*
* Local variables:
diff --git a/code/src/state/state.hae b/code/src/state/state.hae
index ac6d0b7..06b0c57 100644
--- a/code/src/state/state.hae
+++ b/code/src/state/state.hae
@@ -15,16 +15,13 @@
#include "src/mapping/node.h"
-#define TRITON_STATE_UNSET ((void *)1)
-
/**
The data items stored in the state state tables.
*/
typedef struct
{
triton_string_t key;
- void *value;
- int size;
+ triton_string_t value;
triton_mutex_t mutex;
triton_sched_t sched;
struct triton_hash_link link;
@@ -42,8 +39,7 @@ void triton_state_finalize(void);
__blocking triton_ret_t triton_state_engine_post(triton_node_t node,
triton_string_t *key,
- void *value,
- int value_length);
+ triton_string_t *value);
__blocking triton_ret_t triton_state_engine_start(void);
@@ -56,10 +52,11 @@ bool triton_state_engine_running(void);
*/
__blocking triton_ret_t triton_state_engine_shutdown_all(void);
+/* NOTE: if you change the enum, please update the string table in state.ae! */
typedef enum
{
/** The node is joining the system */
- TRITON_STATUS_PROTO = 1,
+ TRITON_STATUS_PROTO = 0,
/** The node is healthy */
TRITON_STATUS_NOMINAL,
/** The node is healthy but is participating in a rebuild */
@@ -71,9 +68,15 @@ typedef enum
/** The node is in a simulated FAILED state */
TRITON_STATUS_INJECTED,
/** The node is out of the system */
- TRITON_STATUS_UNREACHABLE
+ TRITON_STATUS_UNREACHABLE,
+ /** Sentinal value, not used by system */
+ /* NOTE: make sure this is the last value in the enum */
+ TRITON_STATUS_INVALID
} triton_status_t;
+triton_status_t string_to_status(const char* string);
+const char* status_to_string(triton_status_t status);
+
/* TODO: who uses this variable? */
extern triton_status_t triton_status;
@@ -98,15 +101,11 @@ __blocking void triton_status_change(triton_node_t node,
triton_status_t *status_current,
triton_status_t *status_previous);
-triton_ret_t triton_status_tostring(triton_string_t *result,
- triton_status_t status);
-
struct triton_state_engine_funcs
{
__blocking triton_ret_t (*post)(triton_node_t node,
triton_string_t *key,
- void *value,
- int value_length);
+ triton_string_t *value);
__blocking triton_ret_t (*engine_start)(void);
triton_ret_t (*engine_stop)(void);
bool (*running)(void);
diff --git a/code/src/state/tests/engine1.ae b/code/src/state/tests/engine1.ae
index 081dc2b..f2f4535 100644
--- a/code/src/state/tests/engine1.ae
+++ b/code/src/state/tests/engine1.ae
@@ -26,30 +26,28 @@ int numprocs, rank;
static __blocking void sender()
{
triton_string_t key;
- void *value;
+ triton_string_t value;
triton_string_init(&key, "K1");
- value = malloc(128);
- sprintf(value, "V1");
+ triton_string_init(&value, "V1");
- triton_state_engine_post(triton_node_null, &key,
- value, strlen(value)+1);
+ triton_state_engine_post(triton_node_null, &key, &value);
triton_string_destroy(&key);
+ triton_string_destroy(&value);
}
static __blocking void receiver()
{
triton_state_data_t *data;
triton_string_t key;
- char *value;
triton_timer(1000);
triton_string_init(&key, "K1");
data = triton_state_cache_lookup(triton_node_null, &key);
triton_string_destroy(&key);
- value = (char *)(data->value);
- printf("receiver: value: %s\n", value);
+
+ printf("receiver: value: %s\n", triton_string_get(&data->value));
}
static __blocking void doservertest(void)
diff --git a/code/src/state/tests/local.ae b/code/src/state/tests/local.ae
index 6ac304e..3bdd2da 100644
--- a/code/src/state/tests/local.ae
+++ b/code/src/state/tests/local.ae
@@ -14,20 +14,16 @@ static __blocking int dostuff(void)
{
triton_ret_t error;
triton_string_t key;
- void *initial_value;
- void *value;
+ triton_string_t value;
+ triton_string_t initial_value;
triton_state_data_t *data;
- char *output;
-
- initial_value = malloc(128);
- sprintf(initial_value, "initial_value");
+ triton_string_init(&value, "sample_value");
+ triton_string_init(&initial_value, "initial_value");
triton_string_init(&key, "sample_key");
- value = malloc(128);
- sprintf(value, "sample_value");
/* put starting value into system */
- error = triton_state_engine_post(triton_node_null, &key, initial_value, 128);
+ error = triton_state_engine_post(triton_node_null, &key, &initial_value);
triton_error_assert(error);
pwait
@@ -43,7 +39,7 @@ static __blocking int dostuff(void)
printf("setter: sleeping...\n");
triton_timer(1000);
printf("setter: setting...\n");
- error = triton_state_engine_post(triton_node_null, &key, value, 128);
+ error = triton_state_engine_post(triton_node_null, &key, &value);
triton_error_assert(error);
printf("setter: set.\n");
}
@@ -52,14 +48,13 @@ static __blocking int dostuff(void)
printf("waiter: waiting...\n");
data = triton_state_cache_lookup(triton_node_null, &key);
triton_mutex_lock(&data->mutex);
- assert(strcmp((char*)data->value, "initial_value") == 0);
+ assert(strcmp(triton_string_get(&data->value), "initial_value") == 0);
triton_mutex_unlock(&data->mutex);
triton_mutex_lock(&data->mutex);
triton_sched_wait(data->sched, &data->mutex);
printf("waiter: notified.\n");
- output = (char *)(data->value);
- printf("waiter: got: %s\n", output);
+ printf("waiter: got: %s\n", triton_string_get(&data->value));
triton_mutex_unlock(&data->mutex);
}
}
diff --git a/code/src/state/tests/post-global.ae b/code/src/state/tests/post-global.ae
index 47e99d3..eb434f3 100644
--- a/code/src/state/tests/post-global.ae
+++ b/code/src/state/tests/post-global.ae
@@ -26,20 +26,18 @@ int numprocs, rank;
static __blocking void sender()
{
triton_string_t key;
- void *value;
+ triton_string_t value;
triton_ret_t tret;
triton_string_init(&key, "K1");
- value = malloc(128);
- sprintf(value, "V1");
-
+ triton_string_init(&value, "V1");
printf("posting: %s %s\n",
- triton_string_get(&key), (char *)value);
+ triton_string_get(&key), triton_string_get(&value));
- triton_state_engine_post(triton_node_null, &key,
- value, strlen(value)+1);
+ triton_state_engine_post(triton_node_null, &key, &value);
triton_string_destroy(&key);
+ triton_string_destroy(&value);
triton_state_engine_shutdown_all();
}
@@ -47,7 +45,6 @@ static __blocking void receiver()
{
triton_state_data_t *data;
triton_string_t key;
- char *value;
triton_ret_t tret;
printf("receiver\n");
@@ -57,8 +54,8 @@ static __blocking void receiver()
triton_string_init(&key, "K1");
data = triton_state_cache_lookup(triton_node_null, &key);
triton_string_destroy(&key);
- value = (char *)(data->value);
- printf("value of K1 is: %s\n", value);
+
+ printf("value of K1 is: %s\n", triton_string_get(&data->value));
}
static __blocking int dostuff(char *filename, int mpi_rank)
diff --git a/code/src/state/tests/rpc-global.ae b/code/src/state/tests/rpc-global.ae
index b3c1626..db21058 100644
--- a/code/src/state/tests/rpc-global.ae
+++ b/code/src/state/tests/rpc-global.ae
@@ -33,11 +33,13 @@ static __blocking void doclienttest(void)
int size = 0;
int *t;
- struct sc_lookup_pair pair;
triton_string_t key;
triton_buffer_t buffer;
+#if 0
struct sc_lookup_value value;
+ struct sc_lookup_pair pair;
+#endif
triton_addr_lookup("mpi://0", &server);
@@ -49,6 +51,7 @@ static __blocking void doclienttest(void)
printf("client: size: %i\n", size);
+#if 0
pair.node_u = &triton_node_null.u;
pair.node_l = &triton_node_null.l;
triton_string_init(&pair.key, "sample");
@@ -57,12 +60,15 @@ static __blocking void doclienttest(void)
t = (int *)value.buffer.buffer;
printf("client: value: %i\n", *t);
+#endif
remote_state_client_size(AER_DEFAULT_CTX, server, &dummy, &size);
printf("client: size: %i\n", size);
+#if 0
triton_string_destroy(&pair.key);
+#endif
return;
}
@@ -75,18 +81,18 @@ static __blocking void receiver(triton_string_t *key)
data = triton_state_cache_lookup(triton_node_null, key);
- printf("value: %i\n", *(int *)data->value);
+ printf("value: %s\n", triton_string_get(&data->value));
}
static __blocking void sender(triton_string_t *key)
{
- int *value;
+ triton_string_t value;
triton_timer(1000);
- value = malloc(sizeof(int));
- *value = 34;
- triton_state_engine_post(triton_node_null, key, value, sizeof(int));
+ triton_string_init(&value, "34");
+ triton_state_engine_post(triton_node_null, key, &value);
+ triton_string_destroy(&value);
}
static __blocking void doservertest(void)
diff --git a/code/src/state/tests/rpc-global.sh b/code/src/state/tests/rpc-global.sh
index e3e16ff..2aef4eb 100755
--- a/code/src/state/tests/rpc-global.sh
+++ b/code/src/state/tests/rpc-global.sh
@@ -7,6 +7,9 @@ SCRIPT=$0
BIN=${SCRIPT//+(${SRCDIR}\/|.sh)}
OUT=${BIN}.out
+echo SKIPPING: test broken as of 2012-04-27
+exit 0
+
mpiexec -l -n 4 ${BIN} ${SRCDIR}/src/mapping/tests/hosts2.txt > ${OUT} 2>&1
[[ $? == 0 ]] || exit 1
diff --git a/code/src/state/tests/rpc-list.ae b/code/src/state/tests/rpc-list.ae
index cf3ab8e..8729ea9 100644
--- a/code/src/state/tests/rpc-list.ae
+++ b/code/src/state/tests/rpc-list.ae
@@ -33,11 +33,13 @@ static __blocking void doclienttest(void)
int size = 0;
triton_node_t *nodes;
- struct sc_lookup_pair pair;
triton_string_t key;
triton_buffer_t buffer;
+#if 0
+ struct sc_lookup_pair pair;
struct sc_list value;
+#endif
triton_addr_lookup("mpi://0", &server);
@@ -50,11 +52,13 @@ static __blocking void doclienttest(void)
printf("size: %i\n", size);
+#if 0
remote_state_client_list(AER_DEFAULT_CTX, server,
&dummy, &value);
nodes = (triton_node_t *)(value.buffer.buffer);
triton_map_debug_nodes(2, nodes);
+#endif
return;
}
@@ -68,18 +72,18 @@ static __blocking void receiver(triton_string_t *key)
data = triton_state_cache_lookup(triton_node_null, key);
- printf("value: %i\n", *(int *)data->value);
+ printf("value: %s\n", triton_string_get(&data->value));
}
static __blocking void sender(triton_string_t *key)
{
- int *value;
+ triton_string_t value;
triton_timer(1000);
- value = malloc(sizeof(int));
- *value = 34;
- triton_state_engine_post(triton_node_null, key, value, sizeof(int));
+ triton_string_init(&value, "34");
+ triton_state_engine_post(triton_node_null, key, &value);
+ triton_string_destroy(&value);
}
static __blocking void doservertest(void)
diff --git a/code/src/state/tests/rpc-list.sh b/code/src/state/tests/rpc-list.sh
index 72eedb7..06f2390 100755
--- a/code/src/state/tests/rpc-list.sh
+++ b/code/src/state/tests/rpc-list.sh
@@ -7,6 +7,9 @@ SCRIPT=$0
BIN=${SCRIPT//+(${SRCDIR}\/|.sh)}
OUT=${BIN}.out
+echo SKIPPING: test broken as of 2012-04-27
+exit 0
+
triton_debug_masks=triton.mapping triton_debug_file=/dev/stderr \
mpiexec -l -n 4 ${BIN} ${SRCDIR}/src/mapping/tests/hosts2.txt > ${OUT} 2>&1
[[ $? == 0 ]] || exit 1
diff --git a/code/src/state/tests/state-client.ae b/code/src/state/tests/state-client.ae
index a75f3ed..fbc4fbf 100644
--- a/code/src/state/tests/state-client.ae
+++ b/code/src/state/tests/state-client.ae
@@ -85,7 +85,9 @@ __blocking void do_remote_query(void)
printf("do_remote_query(): %i\n", rank);
+#if 0
remote_state_client_list(rctx, svr_addr, ¬hing, resp);
+#endif
}
static int done = 0;
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 4f7bc63830a6ed1b29e8a107e131623199316076 (commit)
from 45e7ac5dd1fdfb5baea98acd2ea264d7ff1cd5e7 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4f7bc63830a6ed1b29e8a107e131623199316076
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 20:15:22 2012 -0400
test script for remote list encoder test
-----------------------------------------------------------------------
Summary of changes:
code/src/aesop/parser/tests/remote/module.mk.in | 2 ++
.../parser/tests/remote/test-remote-list.sh} | 2 +-
2 files changed, 3 insertions(+), 1 deletions(-)
copy code/src/{transactional-osd/tests/tosd1.sh => aesop/parser/tests/remote/test-remote-list.sh} (77%)
Diff of changes:
diff --git a/code/src/aesop/parser/tests/remote/module.mk.in b/code/src/aesop/parser/tests/remote/module.mk.in
index d22e048..919d069 100644
--- a/code/src/aesop/parser/tests/remote/module.mk.in
+++ b/code/src/aesop/parser/tests/remote/module.mk.in
@@ -11,6 +11,8 @@ AERTESTSRC += $(DIR_TESTREMOTE)/test-remote-fault-injector.aer \
$(DIR_TESTREMOTE)/test-remote-buffer-response.aer \
$(DIR_TESTREMOTE)/test-remote-list.aer
+TEST_RESULTS += $(DIR_TESTREMOTE)/test-remote-list.sh
+
#AERTESTSRC += $(DIR_TESTREMOTE)/test-remote-mpi.aer
endif # BUILD_MPI
diff --git a/code/src/transactional-osd/tests/tosd1.sh b/code/src/aesop/parser/tests/remote/test-remote-list.sh
similarity index 77%
copy from code/src/transactional-osd/tests/tosd1.sh
copy to code/src/aesop/parser/tests/remote/test-remote-list.sh
index c365fdc..07cfa5e 100755
--- a/code/src/transactional-osd/tests/tosd1.sh
+++ b/code/src/aesop/parser/tests/remote/test-remote-list.sh
@@ -7,7 +7,7 @@ SCRIPT=$0
BIN=${SCRIPT//+(${SRCDIR}\/|.sh)}
OUT=${BIN}.out
-${VALGRIND} ${BIN} > ${OUT} 2>&1
+mpiexec -l -n 2 ${VALGRIND} ${BIN} > ${OUT} 2>&1
[[ $? == 0 ]] || exit 1
echo OK
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 523bdd75c9c61d123e942d861eaa8207e78a9a55 (commit)
from 162c381ef9987a71134c6f21748cec9da183971b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 523bdd75c9c61d123e942d861eaa8207e78a9a55
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Thu Apr 26 15:56:37 2012 -0500
Add workqueue
-----------------------------------------------------------------------
Summary of changes:
module.mk.in | 3 +-
workqueue.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
workqueue.h | 21 ++++++++++++++++
3 files changed, 97 insertions(+), 1 deletions(-)
create mode 100644 workqueue.c
create mode 100644 workqueue.h
Diff of changes:
diff --git a/module.mk.in b/module.mk.in
index 77ed362..f2664ff 100644
--- a/module.mk.in
+++ b/module.mk.in
@@ -1,3 +1,4 @@
LIBSRC += triton-string.c \
- lookup3.c
+ lookup3.c \
+ workqueue.c
diff --git a/workqueue.c b/workqueue.c
new file mode 100644
index 0000000..893b50a
--- /dev/null
+++ b/workqueue.c
@@ -0,0 +1,74 @@
+#include "workqueue.h"
+#include "triton-list.h"
+#include <assert.h>
+#include "triton-thread.h"
+#include <stdlib.h>
+
+typedef struct
+{
+ triton_list_link_t link;
+ workqueue_function_t * function;
+ void * data;
+} workentry_t;
+
+struct workqueue_t
+{
+ triton_mutex_t lock;
+ triton_list_t list;
+};
+
+int workqueue_create (workqueue_t * q)
+{
+ triton_mutex_init (&q->lock, 0);
+ triton_list_init (&q->list);
+ return 1;
+}
+
+int workqueue_destroy (workqueue_t * q)
+{
+ triton_mutex_lock (&q->lock);
+ assert (triton_list_empty (&q->list));
+ triton_list_destroy (&q->list);
+ triton_mutex_unlock (&q->lock);
+ triton_mutex_destroy (&q->lock);
+ return 1;
+}
+
+
+int workqueue_push (workqueue_t * q, workqueue_function_t * f, void * data)
+{
+ workentry_t * n = malloc (sizeof (workentry_t));
+ n->function = f;
+ n->data = data;
+
+ triton_mutex_lock (&q->lock);
+ triton_list_add_back (&n->link, &q->list);
+ triton_mutex_unlock (&q->lock);
+ return 1;
+}
+
+int workqueue_pop (workqueue_t * q, workqueue_function_t ** f, void ** data)
+{
+ workentry_t * n;
+ int ret = 1;
+
+ triton_mutex_lock (&q->lock);
+
+ if (triton_list_empty (&q->list))
+ {
+ ret = 0;
+ }
+ else
+ {
+ n = triton_list_get_entry (triton_list_peek_front (&q->list),
+ workentry_t, link);
+ *f = n->function;
+ *data = n->data;
+ triton_list_del_front (&q->list);
+ }
+
+ triton_mutex_unlock (&q->lock);
+ return ret;
+}
+
+
diff --git a/workqueue.h b/workqueue.h
new file mode 100644
index 0000000..1332420
--- /dev/null
+++ b/workqueue.h
@@ -0,0 +1,21 @@
+#ifndef C_UTILS_WORKQUEUE_H
+#define C_UTILS_WORKQUEUE_H
+
+typedef struct workqueue_t workqueue_t;
+
+typedef int (*workqueue_function_t) (void * data);
+
+int workqueue_create (workqueue_t * q);
+int workqueue_destroy (workqueue_t * q);
+
+/**
+ * Put an entry on the workqueue.
+ * Returns non-zero for success, zero otherwise.
+ */
+int workqueue_push (workqueue_t * q, workqueue_function_t * f, void * data);
+
+/** Remove an entry from the workqueue; Returns 1 if success, 0 if the queue
+ * was empty or other error */
+int workqueue_pop (workqueue_t * q, workqueue_function_t ** f, void ** data);
+
+#endif
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 162c381ef9987a71134c6f21748cec9da183971b (commit)
via b90676d3123b3fbfcad6a0618f0e69626fe53747 (commit)
from d907964b6074e401fa34635e956141e26b391087 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 162c381ef9987a71134c6f21748cec9da183971b
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Thu Apr 26 15:40:52 2012 -0500
Expose list_del_front
commit b90676d3123b3fbfcad6a0618f0e69626fe53747
Author: Dries Kimpe <dkimpe(a)mcs.anl.gov>
Date: Thu Apr 26 15:37:33 2012 -0500
Include stddef.h for NULL definition
-----------------------------------------------------------------------
Summary of changes:
triton-list.h | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
Diff of changes:
diff --git a/triton-list.h b/triton-list.h
index 30f689f..ed46e54 100644
--- a/triton-list.h
+++ b/triton-list.h
@@ -9,6 +9,7 @@
#include <stdint.h>
#include <assert.h>
+#include <stddef.h>
typedef struct triton_list triton_list_t;
@@ -272,6 +273,7 @@ static inline void triton_list_insert_before(
list->count++;
}
+
static inline struct triton_list_link * __triton_list_del_front(triton_list_t *list)
{
struct triton_list_link *entry = list->entries.next;
@@ -281,6 +283,11 @@ static inline struct triton_list_link * __triton_list_del_front(triton_list_t *l
return entry;
}
+static inline struct triton_list_link * triton_list_del_front(triton_list_t *list)
+{
+ return __triton_list_del_front (list);
+}
+
static inline struct triton_list_link *__triton_list_peek_front(triton_list_t *list)
{
if(triton_list_empty(list)) return NULL;
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 45e7ac5dd1fdfb5baea98acd2ea264d7ff1cd5e7 (commit)
via 3cd9685c77a891dea386fb9b2c6f7fd93a5e45e3 (commit)
via b793ffe06000d19b7a18dc43dfb83f248db7763f (commit)
via c3abfb3c0fd87df6e52da3bedb02dcc081977783 (commit)
via 113b601d66bd82f730ed1d9710a5f4aa8b040622 (commit)
from 15052777b2dab1c1c73026da42155d58bd4f0e8b (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 45e7ac5dd1fdfb5baea98acd2ea264d7ff1cd5e7
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 15:30:05 2012 -0400
warn future generations
- the array encoding macros don't appear to be tested/used either
commit 3cd9685c77a891dea386fb9b2c6f7fd93a5e45e3
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 15:23:05 2012 -0400
add triton_string_t to list encoder test case
commit b793ffe06000d19b7a18dc43dfb83f248db7763f
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 15:22:50 2012 -0400
fix triton_string_t encoder bug
commit c3abfb3c0fd87df6e52da3bedb02dcc081977783
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 15:22:20 2012 -0400
fix various initialization bugs in triton_string_t
commit 113b601d66bd82f730ed1d9710a5f4aa8b040622
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 14:05:00 2012 -0400
fix aer_init_null function, untested
-----------------------------------------------------------------------
Summary of changes:
.../aesop/parser/tests/remote/test-remote-list.aer | 10 ++++--
code/src/common/triton-string.h | 25 ++++++++--------
code/src/remote/encoding-pw.h | 30 ++++++++++++++-----
3 files changed, 41 insertions(+), 24 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/parser/tests/remote/test-remote-list.aer b/code/src/aesop/parser/tests/remote/test-remote-list.aer
index d3de01d..4942e63 100644
--- a/code/src/aesop/parser/tests/remote/test-remote-list.aer
+++ b/code/src/aesop/parser/tests/remote/test-remote-list.aer
@@ -39,6 +39,7 @@ triton_ret_t aer_remote_register_test_remote_list(void);
__remote struct item
{
int32_t x;
+ triton_string_t key;
triton_list_link_t list_link;
};
@@ -88,8 +89,7 @@ static inline triton_ret_t aer_decode_test_remote_list_t(
}
static inline triton_ret_t aer_init_null_test_remote_list_t(void *x)
{
- /* TODO: implement this */
- assert(0);
+ assert(x);
triton_list_t* tmp_list = *(triton_list_t**)x;
triton_list_init(tmp_list);
return TRITON_SUCCESS;
@@ -193,7 +193,8 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
triton_list_for_each_entry(tmp_item, scratch_item, resp.resp_list,
struct item, list_link)
{
- printf("client got: %d\n", (int)tmp_item->x);
+ printf("client got x value: %d\n", (int)tmp_item->x);
+ printf("client got key: %s\n", triton_string_get(&tmp_item->key));
}
/* NOTE: the client must make a copy of the data (or do whatever
@@ -214,6 +215,8 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
tmp_item = malloc(sizeof(*tmp_item));
assert(tmp_item);
tmp_item->x = i;
+ triton_string_init(&tmp_item->key, "String key: %d", i);
+ printf("server sending key: %s\n", triton_string_get(&tmp_item->key));
triton_list_link_clear(&tmp_item->list_link);
triton_list_add_back(&tmp_item->list_link, &test_list);
}
@@ -227,6 +230,7 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
struct item, list_link)
{
triton_list_del(&tmp_item->list_link);
+ triton_string_destroy(&tmp_item->key);
free(tmp_item);
}
triton_list_destroy(&test_list);
diff --git a/code/src/common/triton-string.h b/code/src/common/triton-string.h
index 30cd0c0..1998023 100644
--- a/code/src/common/triton-string.h
+++ b/code/src/common/triton-string.h
@@ -20,14 +20,19 @@ typedef struct triton_string
triton_mutex_t reflock;
} triton_string_t;
+static inline void __triton_string_init_internal(triton_string_t *s)
+{
+ memset(s, 0, sizeof(*s));
+ triton_mutex_init(&s->reflock, NULL);
+
+ return;
+}
+
static inline void triton_string_init_va(triton_string_t *s, const char *format, va_list ap)
{
va_list aap;
int err;
- s->const_string = NULL;
- s->parent = NULL;
- s->refcount = 0;
- triton_mutex_init(&s->reflock, NULL);
+ __triton_string_init_internal(s);
if(format)
{
@@ -58,9 +63,7 @@ static inline void triton_string_init(triton_string_t *s, const char *format, ..
static inline void triton_string_init_size(triton_string_t *s, const char *value, uint32_t len)
{
- s->parent = NULL;
- s->refcount = 0;
- triton_mutex_init(&s->reflock, NULL);
+ __triton_string_init_internal(s);
if(len > 0)
{
@@ -79,9 +82,7 @@ static inline void triton_string_init_size(triton_string_t *s, const char *value
/* does not copy the passed in string */
static inline void triton_string_init_inplace(triton_string_t *s, char *value)
{
- s->parent = NULL;
- s->refcount = 0;
- triton_mutex_init(&s->reflock, NULL);
+ __triton_string_init_internal(s);
if(value)
{
@@ -97,9 +98,7 @@ static inline void triton_string_init_inplace(triton_string_t *s, char *value)
static inline void triton_string_init_inplace_size(triton_string_t *s, char *value, int len)
{
- s->parent = NULL;
- s->refcount = 0;
- triton_mutex_init(&s->reflock, NULL);
+ __triton_string_init_internal(s);
s->size = len;
if(len > 0)
diff --git a/code/src/remote/encoding-pw.h b/code/src/remote/encoding-pw.h
index b38181b..d0ec1c8 100644
--- a/code/src/remote/encoding-pw.h
+++ b/code/src/remote/encoding-pw.h
@@ -527,22 +527,30 @@ static inline triton_ret_t aer_encode_triton_string_t(
{
assert(buf);
assert(x);
+
+ triton_string_t* tmp_str = (triton_string_t *)x;
+ /* walk the chain to find the upmost parent (where the actual string
+ * buffer resides). That is the one that needs to be encoded here.
+ */
+ while(tmp_str->parent)
+ tmp_str = tmp_str->parent;
+
triton_debug(encoding_dbg_mask, "encoding:triton_string_t:%s\tcptr=%p x=%s\n",
n, triton_buffer_cptr(buf),
- ctstr(x)->const_string ? ctstr(x)->const_string : ctstr(x)->string);
- aer_encode_uint32_t(buf, NULL, &ctstr(x)->size);
- if (ctstr(x)->size > 0)
+ tmp_str->const_string ? tmp_str->const_string : tmp_str->string);
+ aer_encode_uint32_t(buf, NULL, &tmp_str->size);
+ if (tmp_str->size > 0)
{
- assert(ctstr(x)->string != NULL || ctstr(x)->const_string != NULL);
- if(ctstr(x)->string == NULL)
+ assert(tmp_str->string != NULL || tmp_str->const_string != NULL);
+ if(tmp_str->string == NULL)
{
- memcpy(triton_buffer_cptr(buf), ctstr(x)->const_string, ctstr(x)->size);
+ memcpy(triton_buffer_cptr(buf), tmp_str->const_string, tmp_str->size);
}
else
{
- memcpy(triton_buffer_cptr(buf), ctstr(x)->string, ctstr(x)->size);
+ memcpy(triton_buffer_cptr(buf), tmp_str->string, tmp_str->size);
}
- triton_buffer_inc(buf, aer_roundup8(ctstr(x)->size));
+ triton_buffer_inc(buf, aer_roundup8(tmp_str->size));
}
return TRITON_SUCCESS;
}
@@ -771,6 +779,10 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
return TRITON_SUCCESS;
}
+/* WARNING: the following array encoding macros have probably not been tested yet.
+ */
+#if 0
+
#define aer_encode_size_array(__array, __varname, __typename, __asize, __size) do { \
uint32_t __sum = aer_encode_size_uint32_t(__asize); \
uint32_t __i = 0; \
@@ -810,6 +822,8 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
} \
} while(0)
+#endif
+
/* Type: triton_list_t
*
* A list of typed structures. Note the triton_list_t type does not keep
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 15052777b2dab1c1c73026da42155d58bd4f0e8b (commit)
from ee46f04d6025b3a87167fa2336537185f350b39d (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 15052777b2dab1c1c73026da42155d58bd4f0e8b
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 13:59:23 2012 -0400
refine triton_list encoding example
- encoder and decoder now copy data structures and honor aer_destroy and
aer_init functions properly. A side effect is that this should allow
more sophisticated types like triton_buffer_t and triton_string_t to
be handled correctly when embedded in list elements.
-----------------------------------------------------------------------
Summary of changes:
.../aesop/parser/tests/remote/test-remote-list.aer | 60 ++++++++++----------
code/src/remote/encoding-pw.h | 29 +++++++++-
2 files changed, 56 insertions(+), 33 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/parser/tests/remote/test-remote-list.aer b/code/src/aesop/parser/tests/remote/test-remote-list.aer
index b418b80..d3de01d 100644
--- a/code/src/aesop/parser/tests/remote/test-remote-list.aer
+++ b/code/src/aesop/parser/tests/remote/test-remote-list.aer
@@ -33,6 +33,9 @@ triton_ret_t aer_remote_register_test_remote_list(void);
#include "mpi.h"
+/* The type of each element in the example linked list. Must be a __remote
+ * function in order to get encoded properly.
+ */
__remote struct item
{
int32_t x;
@@ -45,8 +48,8 @@ triton_mutex_t test_mutex = TRITON_MUTEX_INITIALIZER;
/* Type: test_remote_list_t
*
- * Format: []
- * Bytes: <0>
+ * Encoding functions for a specific typedef (test_remote_list_t) of the
+ * underlying triton_list_t type.
*/
static inline uint64_t aer_encode_size_test_remote_list_t(
const char *n __unused__, void *x)
@@ -54,8 +57,6 @@ static inline uint64_t aer_encode_size_test_remote_list_t(
uint64_t size;
triton_list_t* tmp_list = *(triton_list_t**)x;
- /* NOTE: grabbing lock to protect data structure while it is encoded */
- triton_mutex_lock(&test_mutex);
aer_encode_size_triton_list_t(tmp_list, NULL, struct item, struct_item, list_link, &size);
return size;
@@ -71,9 +72,6 @@ static inline triton_ret_t aer_encode_test_remote_list_t(
aer_encode_triton_list_t(buf, n, tmp_list, struct item, struct_item,
list_link, &tret);
- /* NOTE: releasing lock that was acquired in the size function */
- triton_mutex_unlock(&test_mutex);
-
return(tret);
}
static inline triton_ret_t aer_decode_test_remote_list_t(
@@ -90,6 +88,7 @@ static inline triton_ret_t aer_decode_test_remote_list_t(
}
static inline triton_ret_t aer_init_null_test_remote_list_t(void *x)
{
+ /* TODO: implement this */
assert(0);
triton_list_t* tmp_list = *(triton_list_t**)x;
triton_list_init(tmp_list);
@@ -97,21 +96,24 @@ static inline triton_ret_t aer_init_null_test_remote_list_t(void *x)
}
static inline triton_ret_t aer_copy_test_remote_list_t(void *x, void *v)
{
- /* TODO: do we need this? */
- assert(0);
- return TRITON_SUCCESS;
+ triton_ret_t tret = TRITON_SUCCESS;
+ assert(x);
+ assert(v);
+ triton_list_t** dest_list = (triton_list_t**)x;
+ triton_list_t** src_list = (triton_list_t**)v;
+
+ aer_copy_triton_list_t((*dest_list), (*src_list), struct item,
+ struct_item, list_link, &tret);
+
+ return tret;
}
static inline void aer_destroy_test_remote_list_t(void *x)
{
assert(x);
triton_list_t** tmp_list = (triton_list_t**)x;
- /* TODO: how do we tell the difference between the server side (where we
- * don't want to free anything; we transmitted a global data structure)
- * and the client side (where the decoder allocated memory)?
- *
- * Maybe just leave it to the rpc caller and do nothing here?
- */
+ aer_destroy_triton_list_t((*tmp_list), struct item, struct_item, list_link);
+
return;
}
@@ -125,13 +127,6 @@ static struct aer_encoder __attribute__ ((unused)) aer_encoder_test_remote_list_
.destroy = aer_destroy_test_remote_list_t
};
-
-/* NOTE: The use case that I am interested in will be one in which the
- * server has a data structure (a linked list of structs, with each struct
- * having a hash table off of it) already in memory, and we want to transmit
- * it in a response. Some questions:
- */
-
__remote struct test_resp
{
test_remote_list_t resp_list;
@@ -142,7 +137,14 @@ __remote __blocking triton_ret_t list_maker(triton_ignore_t* req, struct test_re
__remote __blocking triton_ret_t list_maker(triton_ignore_t* req, struct test_resp* resp)
{
- resp->resp_list = &test_list;
+ test_remote_list_t tmp_list= &test_list;
+
+ /* lock to insure that the list isn't modified while we make a copy to
+ * send in the response.
+ */
+ triton_mutex_lock(&test_mutex);
+ aer_init_struct_test_resp(resp, &tmp_list);
+ triton_mutex_unlock(&test_mutex);
return (TRITON_SUCCESS);
}
@@ -192,15 +194,11 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
struct item, list_link)
{
printf("client got: %d\n", (int)tmp_item->x);
- /* NOTE: manually destroying data structure here; this is
- * not handled by the aer_destroy_XXX() function in this
- * case.
- */
- triton_list_del(&tmp_item->list_link);
- free(tmp_item);
}
- free(resp.resp_list);
+ /* NOTE: the client must make a copy of the data (or do whatever
+ * it wants with it) before calling the destroy function below.
+ */
aer_destroy_struct_test_resp(&resp);
}
}
diff --git a/code/src/remote/encoding-pw.h b/code/src/remote/encoding-pw.h
index 8236b75..b38181b 100644
--- a/code/src/remote/encoding-pw.h
+++ b/code/src/remote/encoding-pw.h
@@ -853,6 +853,33 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
*(__ret) = mret; \
} while(0)
+#define aer_copy_triton_list_t( \
+ __dest_list, __src_list, __real_typename, __enc_typename, __member, __ret) do { \
+ __real_typename *__pos; \
+ __real_typename *__scratch; \
+ __real_typename *__newt; \
+ triton_ret_t mret = TRITON_SUCCESS; \
+ __dest_list = malloc(sizeof(*__dest_list)); \
+ if(!__dest_list) mret = TRITON_ERR_NOMEM; \
+ if(mret == TRITON_SUCCESS) triton_list_init(__dest_list); \
+ if(mret == TRITON_SUCCESS) \
+ { \
+ triton_list_for_each_entry(__pos, __scratch, __src_list, __real_typename, __member) \
+ { \
+ __newt = malloc(sizeof(*__newt)); \
+ if(!__newt) { \
+ mret = TRITON_ERR_NOMEM; \
+ break; \
+ } \
+ aer_copy_##__enc_typename(__newt, __pos); \
+ triton_list_link_clear(&(__newt)->__member); \
+ triton_list_add_back(&(__newt)->__member, __dest_list); \
+ } \
+ } \
+ *(__ret) = mret; \
+} while(0)
+
+
#define aer_decode_triton_list_t( \
__buf, __varname, __list, __real_typename, __enc_typename, __member, __ret) do { \
__real_typename *__newt; \
@@ -883,7 +910,6 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
*(__ret) = mret; \
} while(0)
-#if 0
#define aer_destroy_triton_list_t( \
__list, __real_typename, __enc_typename, __member) do { \
__real_typename *__pos; \
@@ -897,6 +923,5 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
triton_list_destroy(__list); \
free(__list); \
} while(0)
-#endif
#endif /* __ENCODING_PW_H__ */
hooks/post-receive
--
1
0
26 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via ee46f04d6025b3a87167fa2336537185f350b39d (commit)
via b053d77f72357a7eee1c4494d47bc78d4cf8314c (commit)
from 4ff2c812a81b17b19acda99fcda8ac6205d32187 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ee46f04d6025b3a87167fa2336537185f350b39d
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 11:00:31 2012 -0400
testing locking during encoding
commit b053d77f72357a7eee1c4494d47bc78d4cf8314c
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Thu Apr 26 10:52:11 2012 -0400
working decoder for triton_list_t
-----------------------------------------------------------------------
Summary of changes:
.../aesop/parser/tests/remote/test-remote-list.aer | 70 +++++++++++++-------
code/src/remote/encoding-pw.h | 32 ++++++++-
2 files changed, 74 insertions(+), 28 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/parser/tests/remote/test-remote-list.aer b/code/src/aesop/parser/tests/remote/test-remote-list.aer
index b2d6d52..b418b80 100644
--- a/code/src/aesop/parser/tests/remote/test-remote-list.aer
+++ b/code/src/aesop/parser/tests/remote/test-remote-list.aer
@@ -39,6 +39,9 @@ __remote struct item
triton_list_link_t list_link;
};
+triton_list_t test_list;
+triton_mutex_t test_mutex = TRITON_MUTEX_INITIALIZER;
+
/* Type: test_remote_list_t
*
@@ -51,6 +54,8 @@ static inline uint64_t aer_encode_size_test_remote_list_t(
uint64_t size;
triton_list_t* tmp_list = *(triton_list_t**)x;
+ /* NOTE: grabbing lock to protect data structure while it is encoded */
+ triton_mutex_lock(&test_mutex);
aer_encode_size_triton_list_t(tmp_list, NULL, struct item, struct_item, list_link, &size);
return size;
@@ -66,6 +71,9 @@ static inline triton_ret_t aer_encode_test_remote_list_t(
aer_encode_triton_list_t(buf, n, tmp_list, struct item, struct_item,
list_link, &tret);
+ /* NOTE: releasing lock that was acquired in the size function */
+ triton_mutex_unlock(&test_mutex);
+
return(tret);
}
static inline triton_ret_t aer_decode_test_remote_list_t(
@@ -73,37 +81,37 @@ static inline triton_ret_t aer_decode_test_remote_list_t(
{
assert(buf);
assert(x);
- triton_list_t* tmp_list = (triton_list_t*)x;
+ triton_list_t** tmp_list = (triton_list_t**)x;
triton_ret_t tret;
- /* TODO: finish filling this in. The decoder has to malloc space for
- * each item too...
- */
-#if 1
- tmp_list = malloc(sizeof(*tmp_list));
- assert(tmp_list);
- triton_list_init(tmp_list);
- return(TRITON_SUCCESS);
-#else
- aer_decode_triton_list_t(buf, n, tmp_list, struct item, struct_item,
+ aer_decode_triton_list_t(buf, n, (*tmp_list), struct item, struct_item,
list_link, &tret);
return (tret);
-#endif
}
static inline triton_ret_t aer_init_null_test_remote_list_t(void *x)
{
+ assert(0);
triton_list_t* tmp_list = *(triton_list_t**)x;
triton_list_init(tmp_list);
return TRITON_SUCCESS;
}
static inline triton_ret_t aer_copy_test_remote_list_t(void *x, void *v)
{
- /* TODO: what in the world do we do here? */
+ /* TODO: do we need this? */
+ assert(0);
return TRITON_SUCCESS;
}
static inline void aer_destroy_test_remote_list_t(void *x)
{
- /* TODO: what in the world do we do here? */
+ assert(x);
+ triton_list_t** tmp_list = (triton_list_t**)x;
+
+ /* TODO: how do we tell the difference between the server side (where we
+ * don't want to free anything; we transmitted a global data structure)
+ * and the client side (where the decoder allocated memory)?
+ *
+ * Maybe just leave it to the rpc caller and do nothing here?
+ */
return;
}
@@ -117,20 +125,11 @@ static struct aer_encoder __attribute__ ((unused)) aer_encoder_test_remote_list_
.destroy = aer_destroy_test_remote_list_t
};
-triton_list_t test_list;
-/* TODO: The use case that I am interested in will be one in which the
+/* NOTE: The use case that I am interested in will be one in which the
* server has a data structure (a linked list of structs, with each struct
* having a hash table off of it) already in memory, and we want to transmit
* it in a response. Some questions:
- *
- * - If we write a custom encoder, can it lock the data structure while it
- * walks it to do the encoding?
- *
- * - Do the memory rules work right on the response? If we are able to send
- * the data structure in place then we don't want the RPC engine to free
- * it. If we have to copy the data structure then we _do_ want the engine
- * to free it.
*/
__remote struct test_resp
@@ -156,6 +155,7 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
char addr_str[256];
struct test_resp resp;
struct item* tmp_item;
+ struct item* scratch_item;
int i;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
@@ -188,6 +188,19 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
}
else
{
+ triton_list_for_each_entry(tmp_item, scratch_item, resp.resp_list,
+ struct item, list_link)
+ {
+ printf("client got: %d\n", (int)tmp_item->x);
+ /* NOTE: manually destroying data structure here; this is
+ * not handled by the aer_destroy_XXX() function in this
+ * case.
+ */
+ triton_list_del(&tmp_item->list_link);
+ free(tmp_item);
+ }
+ free(resp.resp_list);
+
aer_destroy_struct_test_resp(&resp);
}
}
@@ -210,6 +223,15 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
/* service a single request */
assert(rctx != NULL);
ret = aer_service_requests(rctx, 1);
+
+ /* tear down the data structure */
+ triton_list_for_each_entry(tmp_item, scratch_item, &test_list,
+ struct item, list_link)
+ {
+ triton_list_del(&tmp_item->list_link);
+ free(tmp_item);
+ }
+ triton_list_destroy(&test_list);
}
}
diff --git a/code/src/remote/encoding-pw.h b/code/src/remote/encoding-pw.h
index 824b648..8236b75 100644
--- a/code/src/remote/encoding-pw.h
+++ b/code/src/remote/encoding-pw.h
@@ -858,14 +858,22 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
__real_typename *__newt; \
uint64_t __i = 0; \
uint64_t __c = 0; \
- triton_ret_t mret; \
- triton_list_init(__list); \
- mret = aer_decode_uint64_t(__buf, NULL, &__c); \
+ triton_ret_t mret = TRITON_SUCCESS; \
+ __list = malloc(sizeof(*__list)); \
+ if(!__list) mret = TRITON_ERR_NOMEM; \
+ if(mret == TRITON_SUCCESS) {\
+ triton_list_init(__list); \
+ mret = aer_decode_uint64_t(__buf, NULL, &__c); \
+ } \
if(mret == TRITON_SUCCESS) \
{ \
for(; __i < __c; ++__i) \
{ \
- __newt = (__real_typename *)__buf; \
+ __newt = malloc(sizeof(*__newt)); \
+ if(!__newt) { \
+ mret = TRITON_ERR_NOMEM; \
+ break; \
+ } \
mret = aer_decode_##__enc_typename(__buf, NULL, __newt); \
if(mret != TRITON_SUCCESS) break; \
triton_list_link_clear(&(__newt)->__member); \
@@ -875,4 +883,20 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
*(__ret) = mret; \
} while(0)
+#if 0
+#define aer_destroy_triton_list_t( \
+ __list, __real_typename, __enc_typename, __member) do { \
+ __real_typename *__pos; \
+ __real_typename *__scratch; \
+ triton_list_for_each_entry(__pos, __scratch, __list, __real_typename, __member) \
+ { \
+ triton_list_del(&(__pos)->__member); \
+ aer_destroy_##__enc_typename(__pos); \
+ free(__pos); \
+ } \
+ triton_list_destroy(__list); \
+ free(__list); \
+} while(0)
+#endif
+
#endif /* __ENCODING_PW_H__ */
hooks/post-receive
--
1
0
25 Apr '12
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, master has been updated
via 4ff2c812a81b17b19acda99fcda8ac6205d32187 (commit)
via 4bb8fc7a1964a1b0e772bb5b740c749abfd63194 (commit)
from cffafac86d4e9a27f3c83ff7a0c10525a9e410a5 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 4ff2c812a81b17b19acda99fcda8ac6205d32187
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 25 17:32:44 2012 -0400
fill in more of list encoding example
- encoder works, decoder is incomplete
commit 4bb8fc7a1964a1b0e772bb5b740c749abfd63194
Author: Phil Carns <carns(a)mcs.anl.gov>
Date: Wed Apr 25 17:32:25 2012 -0400
fix/update list encoding macros
-----------------------------------------------------------------------
Summary of changes:
.../aesop/parser/tests/remote/test-remote-list.aer | 57 ++++++++++---
code/src/common/triton-list.h | 2 +-
code/src/remote/encoding-pw.h | 88 ++++++++++++++++----
3 files changed, 118 insertions(+), 29 deletions(-)
Diff of changes:
diff --git a/code/src/aesop/parser/tests/remote/test-remote-list.aer b/code/src/aesop/parser/tests/remote/test-remote-list.aer
index efb76df..b2d6d52 100644
--- a/code/src/aesop/parser/tests/remote/test-remote-list.aer
+++ b/code/src/aesop/parser/tests/remote/test-remote-list.aer
@@ -33,10 +33,10 @@ triton_ret_t aer_remote_register_test_remote_list(void);
#include "mpi.h"
-struct item
+__remote struct item
{
int32_t x;
- triton_list_link_t link;
+ triton_list_link_t list_link;
};
@@ -48,28 +48,62 @@ struct item
static inline uint64_t aer_encode_size_test_remote_list_t(
const char *n __unused__, void *x)
{
- return 0;
+ uint64_t size;
+ triton_list_t* tmp_list = *(triton_list_t**)x;
+
+ aer_encode_size_triton_list_t(tmp_list, NULL, struct item, struct_item, list_link, &size);
+
+ return size;
}
static inline triton_ret_t aer_encode_test_remote_list_t(
triton_buffer_t *buf, const char *n __unused__, void *x)
{
- return TRITON_SUCCESS;
+ assert(buf);
+ assert(x);
+ triton_list_t* tmp_list = *(triton_list_t**)x;
+ triton_ret_t tret;
+
+ aer_encode_triton_list_t(buf, n, tmp_list, struct item, struct_item,
+ list_link, &tret);
+
+ return(tret);
}
static inline triton_ret_t aer_decode_test_remote_list_t(
triton_buffer_t *buf, char **n __unused__, void *x)
{
- return TRITON_SUCCESS;
+ assert(buf);
+ assert(x);
+ triton_list_t* tmp_list = (triton_list_t*)x;
+ triton_ret_t tret;
+
+ /* TODO: finish filling this in. The decoder has to malloc space for
+ * each item too...
+ */
+#if 1
+ tmp_list = malloc(sizeof(*tmp_list));
+ assert(tmp_list);
+ triton_list_init(tmp_list);
+ return(TRITON_SUCCESS);
+#else
+ aer_decode_triton_list_t(buf, n, tmp_list, struct item, struct_item,
+ list_link, &tret);
+ return (tret);
+#endif
}
static inline triton_ret_t aer_init_null_test_remote_list_t(void *x)
{
+ triton_list_t* tmp_list = *(triton_list_t**)x;
+ triton_list_init(tmp_list);
return TRITON_SUCCESS;
}
static inline triton_ret_t aer_copy_test_remote_list_t(void *x, void *v)
{
+ /* TODO: what in the world do we do here? */
return TRITON_SUCCESS;
}
static inline void aer_destroy_test_remote_list_t(void *x)
{
+ /* TODO: what in the world do we do here? */
return;
}
@@ -83,7 +117,7 @@ static struct aer_encoder __attribute__ ((unused)) aer_encoder_test_remote_list_
.destroy = aer_destroy_test_remote_list_t
};
-test_remote_list_t test_list;
+triton_list_t test_list;
/* TODO: The use case that I am interested in will be one in which the
* server has a data structure (a linked list of structs, with each struct
@@ -101,7 +135,7 @@ test_remote_list_t test_list;
__remote struct test_resp
{
- test_remote_list_t* resp_list;
+ test_remote_list_t resp_list;
};
__remote __blocking triton_ret_t list_maker(triton_ignore_t* req, struct test_resp* resp);
@@ -159,6 +193,9 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
}
else
{
+ /* this is the server */
+
+ /* set up global list that we will try to transmit */
triton_list_init(&test_list);
for(i=0; i<3; i++)
@@ -166,12 +203,10 @@ __blocking void do_remote_test(aer_remote_ctx_t rctx)
tmp_item = malloc(sizeof(*tmp_item));
assert(tmp_item);
tmp_item->x = i;
- triton_list_link_clear(&tmp_item->link);
- triton_list_add_back(&tmp_item->link, &test_list);
+ triton_list_link_clear(&tmp_item->list_link);
+ triton_list_add_back(&tmp_item->list_link, &test_list);
}
- /* this is the server */
-
/* service a single request */
assert(rctx != NULL);
ret = aer_service_requests(rctx, 1);
diff --git a/code/src/common/triton-list.h b/code/src/common/triton-list.h
index 2d08d32..a0ac928 100644
--- a/code/src/common/triton-list.h
+++ b/code/src/common/triton-list.h
@@ -8,7 +8,7 @@ typedef struct triton_list triton_list_t;
/* TODO: do not use the test_remote_list_t type!
* This is only here for testing purposes.
*/
-typedef triton_list_t test_remote_list_t;
+typedef triton_list_t* test_remote_list_t;
typedef struct triton_list_link
{
diff --git a/code/src/remote/encoding-pw.h b/code/src/remote/encoding-pw.h
index e8053de..824b648 100644
--- a/code/src/remote/encoding-pw.h
+++ b/code/src/remote/encoding-pw.h
@@ -131,6 +131,55 @@ static struct aer_encoder __attribute__ ((unused)) aer_encoder_triton_ignore_t =
.destroy = aer_destroy_triton_ignore_t
};
+/* Type: triton_list_link_t
+ *
+ * The list_link values don't really need to be transmitted over the wire.
+ * These functions are just stubs to prevent aercc from complaining about
+ * __remote structures that contain list links.
+ *
+ * Format: []
+ * Bytes: <0>
+ */
+static inline uint64_t aer_encode_size_triton_list_link_t(
+ const char *n __unused__, void *x)
+{
+ return 0;
+}
+static inline triton_ret_t aer_encode_triton_list_link_t(
+ triton_buffer_t *buf, const char *n __unused__, void *x)
+{
+ return TRITON_SUCCESS;
+}
+static inline triton_ret_t aer_decode_triton_list_link_t(
+ triton_buffer_t *buf, char **n __unused__, void *x)
+{
+ return TRITON_SUCCESS;
+}
+static inline triton_ret_t aer_init_null_triton_list_link_t(void *x)
+{
+ return TRITON_SUCCESS;
+}
+static inline triton_ret_t aer_copy_triton_list_link_t(void *x, void *v)
+{
+ return TRITON_SUCCESS;
+}
+static inline void aer_destroy_triton_list_link_t(void *x)
+{
+ return;
+}
+
+static struct aer_encoder __attribute__ ((unused)) aer_encoder_triton_list_link_t =
+{
+ .encode = aer_encode_triton_list_link_t,
+ .decode = aer_decode_triton_list_link_t,
+ .encode_size = aer_encode_size_triton_list_link_t,
+ .init_null = aer_init_null_triton_list_link_t,
+ .copy = aer_copy_triton_list_link_t,
+ .destroy = aer_destroy_triton_list_link_t
+};
+
+
+
/* Type: uint128_t
*
@@ -774,26 +823,30 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
* Note the size function (macro) is expensive, as we have to calculate the
* sizes of individual elements. The remote code should avoid using it if possible.
*/
-#define aer_encode_size_triton_list_t(__list, __varname, __typename, __size) do { \
- __typename *__pos; \
- __sum = 0; \
- triton_list_for_each_entry(__pos, __typename, __list) \
+#define aer_encode_size_triton_list_t(__list, __varname, __real_typename, __enc_typename, __member, __size) do { \
+ __real_typename *__pos; \
+ __real_typename *__scratch; \
+ uint32_t __sum = 0; \
+ triton_list_for_each_entry(__pos, __scratch, __list, __real_typename, __member) \
{ \
- __sum += aer_encode_size_##__typename(NULL, __pos); \
+ __sum += aer_encode_size_##__enc_typename(NULL, __pos); \
} \
*(__size) = aer_roundup8(8 + __sum); \
} while(0)
#define aer_encode_triton_list_t( \
- __buf, __varname, __list, __typename, __member, __ret) do { \
- __typename *__pos; \
+ __buf, __varname, __list, __real_typename, __enc_typename, __member, __ret) do { \
+ __real_typename *__pos; \
+ __real_typename *__scratch; \
+ uint64_t __list_count; \
triton_ret_t mret; \
- mret = aer_encode_uint64_t(__buf, NULL, triton_list_size(__list)); \
+ __list_count = triton_list_count(__list); \
+ mret = aer_encode_uint64_t(__buf, NULL, &__list_count); \
if(mret == TRITON_SUCCESS) \
{ \
- triton_list_for_each_entry(__pos, __list, __typename, __member) \
+ triton_list_for_each_entry(__pos, __scratch, __list, __real_typename, __member) \
{ \
- mret = aer_encode_##__typename(__buf, NULL, __pos); \
+ mret = aer_encode_##__enc_typename(__buf, NULL, __pos); \
if(mret != TRITON_SUCCESS) break; \
} \
} \
@@ -801,18 +854,19 @@ static inline triton_ret_t aer_encoding_finish(triton_buffer_t *buffer)
} while(0)
#define aer_decode_triton_list_t( \
- __buf, __varname, __list, __typename, __member, __ret) do { \
- __typename *__newt; \
- uint64_t i = 0, uint64_t c; \
+ __buf, __varname, __list, __real_typename, __enc_typename, __member, __ret) do { \
+ __real_typename *__newt; \
+ uint64_t __i = 0; \
+ uint64_t __c = 0; \
triton_ret_t mret; \
triton_list_init(__list); \
- mret = aer_decode_uint64_t(__buf, NULL, &c); \
+ mret = aer_decode_uint64_t(__buf, NULL, &__c); \
if(mret == TRITON_SUCCESS) \
{ \
- for(; i < c; ++i) \
+ for(; __i < __c; ++__i) \
{ \
- __newt = (__typename *)__buf; \
- mret = aer_decode_##__typename(__buf, NULL, __newt); \
+ __newt = (__real_typename *)__buf; \
+ mret = aer_decode_##__enc_typename(__buf, NULL, __newt); \
if(mret != TRITON_SUCCESS) break; \
triton_list_link_clear(&(__newt)->__member); \
triton_list_add_back(&(__newt)->__member, __list); \
hooks/post-receive
--
1
0