[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34519 - gnunet/src/scalarproduct
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34519 - gnunet/src/scalarproduct |
Date: |
Tue, 9 Dec 2014 22:45:04 +0100 |
Author: grothoff
Date: 2014-12-09 22:45:03 +0100 (Tue, 09 Dec 2014)
New Revision: 34519
Added:
gnunet/src/scalarproduct/perf_scalarproduct.sh
Modified:
gnunet/src/scalarproduct/gnunet-scalarproduct.c
gnunet/src/scalarproduct/scalarproduct_api.c
gnunet/src/scalarproduct/test_scalarproduct.sh
Log:
-running at scale...
Modified: gnunet/src/scalarproduct/gnunet-scalarproduct.c
===================================================================
--- gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-12-09 21:17:46 UTC
(rev 34518)
+++ gnunet/src/scalarproduct/gnunet-scalarproduct.c 2014-12-09 21:45:03 UTC
(rev 34519)
@@ -243,13 +243,20 @@
input_peer_id);
return;
}
-
+ if ( ('\'' == *begin) &&
+ ('\'' == begin[strlen(begin)-1]) )
+ {
+ begin[strlen(begin)-1] = '\0';
+ if (strlen (begin) > 0)
+ begin++;
+ }
for (end = begin; 0 != *end; end++)
if (*end == ';')
element_count++;
- if (0 == element_count) {
+ if (0 == element_count)
+ {
LOG (GNUNET_ERROR_TYPE_ERROR,
- _("Need elements to compute the vectorproduct, got none.\n"));
+ _("Need elements to compute the scalarproduct, got none.\n"));
return;
}
@@ -276,9 +283,8 @@
GNUNET_free (elements);
return;
}
-
+ *separator = 0;
/* read the element's key */
- *separator = 0;
GNUNET_CRYPTO_hash (begin,
strlen (begin),
&element.key);
@@ -316,7 +322,8 @@
&responder_callback,
NULL))) ) )
{
- GNUNET_break (0);
+ fprintf (stderr,
+ _("Failed to initiate computation, were all keys unique?\n"));
GNUNET_free (elements);
return;
}
Added: gnunet/src/scalarproduct/perf_scalarproduct.sh
===================================================================
--- gnunet/src/scalarproduct/perf_scalarproduct.sh
(rev 0)
+++ gnunet/src/scalarproduct/perf_scalarproduct.sh 2014-12-09 21:45:03 UTC
(rev 34519)
@@ -0,0 +1,43 @@
+#!/bin/bash
+# compute a simple scalar product
+# payload for this test:
+SIZE=1000
+INPUTALICE="-k CCC -e '"
+INPUTBOB="-k CCC -e '"
+for X in `seq 1 $SIZE`
+do
+ INPUTALICE="${INPUTALICE}A${X},$X;"
+ INPUTBOB="${INPUTBOB}A${X},$X;"
+done
+INPUTALICE="${INPUTALICE}BC,-20000;RO,1000;FL,100;LOL,24;'"
+INPUTBOB="${INPUTBOB}AB,10;RO,3;FL,3;LOL,-1;'"
+
+# necessary to make the testing prefix deterministic, so we can access the
config files
+PREFIX=/tmp/test-scalarproduct`date +%H%M%S`
+
+# where can we find the peers config files?
+CFGALICE="-c $PREFIX/0/config"
+CFGBOB="-c $PREFIX/1/config"
+
+# launch two peers in line topology non-interactively
+#
+# interactive mode would terminate the test immediately
+# because the rest of the script is already in stdin,
+# thus redirecting stdin does not suffice)
+GNUNET_FORCE_LOG=';;;;ERROR'
+GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c
test_scalarproduct.conf -p 2 &
+PID=$!
+# sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
+echo "Waiting for peers to start..."
+sleep 5
+# get Bob's peer ID, necessary for Alice
+PEERIDBOB=`gnunet-peerinfo -qs $CFGBOB`
+
+echo "Running problem of size $SIZE"
+gnunet-scalarproduct $CFGBOB $INPUTBOB &
+time RESULT=`gnunet-scalarproduct $CFGALICE $INPUTALICE -p $PEERIDBOB`
+
+echo "Terminating testbed..."
+# terminate the testbed
+kill $PID
+
Property changes on: gnunet/src/scalarproduct/perf_scalarproduct.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: gnunet/src/scalarproduct/scalarproduct_api.c
===================================================================
--- gnunet/src/scalarproduct/scalarproduct_api.c 2014-12-09 21:17:46 UTC
(rev 34518)
+++ gnunet/src/scalarproduct/scalarproduct_api.c 2014-12-09 21:45:03 UTC
(rev 34519)
@@ -268,6 +268,40 @@
/**
+ * Check if the keys for all given elements are unique.
+ *
+ * @param elements elements to check
+ * @param element_count size of the @a elements array
+ * @return #GNUNET_OK if all keys are unique
+ */
+static int
+check_unique (const struct GNUNET_SCALARPRODUCT_Element *elements,
+ uint32_t element_count)
+{
+ struct GNUNET_CONTAINER_MultiHashMap *map;
+ uint32_t i;
+ int ok;
+
+ ok = GNUNET_OK;
+ map = GNUNET_CONTAINER_multihashmap_create (2 * element_count,
+ GNUNET_YES);
+ for (i=0;i<element_count;i++)
+ if (GNUNET_OK !=
+ GNUNET_CONTAINER_multihashmap_put (map,
+ &elements[i].key,
+ map,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Keys given to SCALARPRODUCT not unique!\n"));
+ ok = GNUNET_SYSERR;
+ }
+ GNUNET_CONTAINER_multihashmap_destroy (map);
+ return ok;
+}
+
+
+/**
* Used by Bob's client to cooperate with Alice,
*
* @param cfg the gnunet configuration handle
@@ -291,6 +325,8 @@
uint32_t size;
uint16_t possible;
+ if (GNUNET_SYSERR == check_unique (elements, element_count))
+ return NULL;
h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle);
h->cont_status = cont;
h->cont_cls = cont_cls;
@@ -433,6 +469,8 @@
uint32_t size;
uint32_t possible;
+ if (GNUNET_SYSERR == check_unique (elements, element_count))
+ return NULL;
h = GNUNET_new (struct GNUNET_SCALARPRODUCT_ComputationHandle);
h->client = GNUNET_CLIENT_connect ("scalarproduct-alice", cfg);
if (NULL == h->client)
Modified: gnunet/src/scalarproduct/test_scalarproduct.sh
===================================================================
--- gnunet/src/scalarproduct/test_scalarproduct.sh 2014-12-09 21:17:46 UTC
(rev 34518)
+++ gnunet/src/scalarproduct/test_scalarproduct.sh 2014-12-09 21:45:03 UTC
(rev 34519)
@@ -17,7 +17,7 @@
# interactive mode would terminate the test immediately
# because the rest of the script is already in stdin,
# thus redirecting stdin does not suffice)
-GNUNET_FORCE_LOG='scalarproduct*;;;;DEBUG'
+# GNUNET_FORCE_LOG='scalarproduct*;;;;DEBUG'
GNUNET_TESTING_PREFIX=$PREFIX ../testbed/gnunet-testbed-profiler -n -c
test_scalarproduct.conf -p 2 &
PID=$!
# sleep 1 is too short on most systems, 2 works on most, 5 seems to be safe
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34519 - gnunet/src/scalarproduct,
gnunet <=